Create an Auto Scaling Policy

post

/paas/api/v1.1/instancemgmt/{identityDomainId}/services/APAAS/instances/{appName}/autoscaling/policies

Creates and enables the automatic (auto) scaling policy for an Oracle Application Container Cloud Service instance.

The policy defines rules and conditions for when to automatically scale the service instance. Four rules (operations) are supported at this time: scale out, scale in, scale up, and scale down. A maximum and minimum memory can be defined.

At least one rule (operation) must be defined to enable auto scaling for an application instance. If you define the four rules (operations), make sure the conditions do not conflict each other.

Request

Supported Media Types
Path Parameters
Header Parameters
Body ()
The request body defines the auto scaling policy details for the service instance.
Root Schema : autoscalingpolicy-request
Type: object
Show Source
Nested Schema : policies
Type: array
Groups details about the auto scaling policy.
Show Source
Nested Schema : policies-request
Type: object
Show Source
  • alarm
    Groups the conditions for a rule to trigger an alarm.
  • The number of minutes after a scaling activity is completed before any further scaling activities can start. A valid value is a positive integer in the range of 30 to 300.

    If the alarm is still active after the cool down period, the scaling activity is repeated. The process continues until the alarm is no longer active, or the maximum or minimum cluster size is reached.

  • Maximum cluster size supported by the service instance. Required and valid only for a ScaleOut rule.
  • Minimum cluster size supported by the service instance. Required and valid only for a ScaleIn rule.
  • The scaling operation to perform when the alarm is triggered. At least one scaling operation must be defined in the policy. Only scale out and scale in are supported at this time. Valid values: scaleOut, scaleIn,scaleUp, and scaleDown.
Nested Schema : alarm
Type: object
Groups the conditions for a rule to trigger an alarm.
Show Source
  • Whether auto scaling is to be performed when an alarm rule is breached on all VM instances or on any of the VM instances. Valid values:ALL, ANY
  • The arithmetic operation to use when comparing the specified statistic and threshold values. Valid values: GreaterThanOrEqualToThreshold (for scale out), LessThanOrEqualToThreshold (for scale in)
  • Name of the metric set in the alarm. Supported values are:
    • MemoryUtilization - The unit of measurement is percent.
    • Memory - The unit of measurement is MB.

    If you are defining both the scale out and scale in operations in a policy, the same metric must be specified for each operation.

  • Unit of measurement for the alarm's associated metric. Valid values: percent, GB
  • The consecutive number of times data is compared for the given metric. A valid value is a positive integer in the range of 1 to 24.
  • The interval in minutes when data is compared for the given metric. A valid value is a positive integer in the range of 5 to 60.
  • The statistic to apply to the alarm's associated metric. Valid values: AVG, MIN, MAX
  • The value against which the given statistic is compared. A valid value can be a positive integer or float, in the range of 1 to 100 (for a percent value), and between 1 to 240 (for a GB value).
Back to Top

Response

Supported Media Types

202 Response

Accepted.
Body ()
The response body contains the auto scaling policy details when creating, updating, or viewing the policy.
Root Schema : autoscalingpolicy-response
Type: object
The response body contains the auto scaling policy details when creating, updating, or viewing the policy.
Show Source
Nested Schema : policies
Type: array
Groups details about the auto scaling policy.
Show Source
Nested Schema : policy-details
Type: object
Show Source
Nested Schema : alarm
Type: object
Groups the conditions for a rule to trigger an alarm.
Show Source

400 Response

Validation failed. See the response for errors from one or more sources. Make the corrections and try again.
Body ()
Root Schema : validationfailed-response
Type: object
Show Source
Nested Schema : errors
Type: array
Groups the error details.
Show Source
Nested Schema : items
Type: object
Show Source
Back to Top

Examples

The following example shows how to add an auto scaling policy to an Oracle Application Container Cloud Service application instance, by submitting a POST request on the REST resource using cURL.

Note:

  • The command in this example uses the URL structure https://rest_server_url/resource-path, where rest_server_url is the REST server to contact for your identity domain (or Cloud Account). See Send Requests.

  • In the resource path, the service type ../APAAS/.. is case-sensitive.

cURL Command

curl -i -X POST -u username:userPassword1! -d @addpolicy.json -H "Content-Type:application/json" -H "X-ID-TENANT-NAME:ExampleIdentityDomain" https://rest_server_url/paas/api/v1.1/instancemgmt/ExampleIdentityDomain/services/APAAS/instances/ExampleInstance/autoscaling/policies

Example of Request Body

The following shows an example of the request body in JSON format.

{
    "name": "Policy1",
    "description": "Auto Scaling Policy",
    "policies": [
    {
        "operation": "scaleOut",
        "alarm": {
            "metricName": "MemoryUtilitation",
            "metricUnit": "percent",
            "statistic": "AVG",
            "comparisonOperator": "GreaterThanOrEqualToThreshold",
            "threshold": 80,
            "sampleCount": 3,
            "sampleFrequency": 10,
            "breachedOnInstance": "ALL"
        },
        "coolDownPeriod": 30,
        "maxClusterSize": 4
    },
    {
        "operation": "scaleIn",
        "alarm": {
            "metricName": "MemoryUtilitation",
            "metricUnit": "percent",
            "statistic": "AVG",
            "comparisonOperator": "LessThanOrEqualToThreshold",
            "threshold": 40,
            "sampleCount": 3,
            "sampleFrequency": "10",
            "breachedOnInstance": "ANY"
        },       
        "coolDownPeriod": 30,
        "minClusterSize": 2
    }
    ]
} 

In the example:

  • Automatically scale out up to "maxClusterSize"="4" when "AVG" "MemoryUtilitation" is "GreaterThanOrEqualToThreshold" "80" "percent" for "3" consecutive periods of "10" minutes on "ALL" VM instances, and wait for "30" minutes of cool down

  • Automatically scale in to "minClusterSize"="2" when "AVG" "Memory" is "LessThanOrEqualToThreshold" "40" "percent" for "3" consecutive periods of "10" minutes on "ANY" VM instance, and wait for "30" minutes of cool down

The following shows an example using a memory-based metric:

{
    "name": "Policy2",
    "description": "Auto Scaling Policy 2",
    "policies": [
    {
        "operation": "scaleOut",
        "alarm": {
            "metricName": "Memory",
            "metricUnit": "MB",
            "statistic": "AVG",
            "comparisonOperator": "GreaterThanOrEqualToThreshold",
            "threshold": 5.2,
            "sampleCount": 1,
            "sampleFrequency": 5,
            "breachedOnInstance": "ANY"
        },
        "coolDownPeriod": 30,
        "maxClusterSize": 2
    },
    {
        "operation": "scaleIn",
        "alarm": {
            "metricName": "Memory",
            "metricUnit": "MB",
            "statistic": "AVG",
            "comparisonOperator": "LessThanOrEqualToThreshold",
            "threshold": 4.9,
            "sampleCount": 1,
            "sampleFrequency": "5",
            "breachedOnInstance": "ANY"
        },       
        "coolDownPeriod": 30,
        "minClusterSize": 1
    }
    ]
} 

Example of Response Header

The following shows an example of the response header.

HTTP/1.1 202 Accepted
Date: Thu, 19 May 2016 00:53:16 GMT
Content-Length: 0
Content-Type: application/json

Example of Response Body

The following is an example of the response returned in JSON format.

{
    "name": "Policy1",
    "description": "Auto Scaling Policy",
    "policies": [
    {
        "operation": "scaleOut",
        "alarm": {
            "metricName": "MemoryUtilitation",
            "metricUnit": "percent",
            "statistic": "AVG",
            "comparisonOperator": "GreaterThanOrEqualToThreshold",
            "threshold": "80",
            "sampleCount": "3",
            "sampleFrequency": "10",
            "breachedOnInstance": "ALL"
        },
        "coolDownPeriod": "30",
        "maxClusterSize": "4"
    },
    {
        "operation": "scaleIn",
        "alarm": {
            "metricName": "MemoryUtilitation",
            "metricUnit": "percent",
            "statistic": "AVG",
            "comparisonOperator": "LessThanOrEqualToThreshold",
            "threshold": "40",
            "sampleCount": "3",
            "sampleFrequency": "10",
            "breachedOnInstance": "ANY"
        },
        "coolDownPeriod": "30",
        "minClusterSize": "2"
    }
    ],
    "version": 1,
    "status": "Active",
    "startTime": "2016-05-19T07:28:54.422+0000"
}

Example of Response Body (validation failed)

The following shows an example of the response returned in JSON format when there are validation errors in the policy.

{
    "status": "Bad Request",
    "errors": [
    {
        "detail": "[statistic] is invalid, valid values are [AVG,MIN,MAX].",
        "source": "statistic"
    },
    {
        "detail": "[threshold] is invalid, it should be positive integer in the range of [1-100].",
        "source": "threshold"
    }
    ]
}
Back to Top