GET /v1/apps/:guid/scaling_histories
Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o
-X GET \-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o"
200 OK
{
"total_results": 2,
"total_pages": 1,
"page": 1,
"prev_url": null,
"next_url": "/v1/apps/8d0cee08-23ad-4813-a779-ad8118ea0b91/scaling_histories?start-time=1494989539138350432&end-time=1494989539138399999&order-direction=desc&page=2&results-per-page=10",
"resources": [{
"app_guid": "8d0cee08-23ad-4813-a779-ad8118ea0b91",
"timestamp": 1494989539138350433,
"scaling_type": 1,
"status": 0,
"old_instances": 1,
"new_instances": 2,
"reason": "",
"message": "",
"error": ""
},
{
"app_guid": "8d0cee08-23ad-4813-a779-ad8118ea0b91",
"timestamp": 1494989539138350435,
"scaling_type": 1,
"status": 0,
"old_instances": 1,
"new_instances": 2,
"reason": "",
"message": "",
"error": ""
}]
}
AutoScaler collects the instances' metrics of an application, and aggregate the raw data into an accumulated value for evaluation. This API is used to return the aggregated metric result of an application.
GET /v1/apps/:guid/aggregated_metric_histories/memoryused
Name | Description | Valid values | Required | Example values |
guid | The GUID of the application | true | ||
metric_type | The metric type | String, "memoryused", "memoryutil", "responsetime", "throughput", "cpu" or custom metric's name | true | metric_type=memoryused | |
start-time | The start time | int, the number of nanoseconds elapsed since January 1, 1970 UTC. | false, default 0 | start-time=1494989539138350432 |
end-time | The end time | int, the number of nanoseconds elapsed since January 1, 1970 UTC. | false, default "now" | end-time=1494989549117047288 |
order-direction | The order type. The metric history will be ordered by timestamp asc or desc. | string,”asc” or "desc" | false. default desc | order-direction=asc |
page | The page number to query | int | false, default 1 | page=1 |
results-per-page | The number of results per page | int | false, default 50 | results-per-page=10 |
Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o
-X GET \-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o"
200 OK
[
"total_results": 2,
"total_pages": 1,
"page": 1,
"prev_url": null,
"next_url": "/v1/apps/8d0cee08-23ad-4813-a779-ad8118ea0b91/aggregated_metric_histories?start-time=1494989539138350432&end-time=1494989539138399999&order-direction=asc&page=2&results-per-page=10",
"resources": [{
"app_guid": "8d0cee08-23ad-4813-a779-ad8118ea0b91",
"timestamp": 1494989539138350433,
"metric_type": "memoryused",
"value": "400",
"unit": "megabytes"
},
{
"app_guid": "8d0cee08-23ad-4813-a779-ad8118ea0b91",
"timestamp": 1494989539138350433,
"metric_type": "memoryused",
"value": "400",
"unit": "megabytes"
}]
]
PUT /v1/apps/:guid/policy
Name | Description | Valid values | Required | Example values |
guid | The GUID of the application | true |
A valid JSON input to define scaling policy. Refer to Policy Definition .
Sample request body:
{
"instance_min_count": 1,
"instance_max_count": 4,
"scaling_rules": [{
"metric_type": "memoryused",
"breach_duration_secs": 600,
"threshold": 30,
"operator": "<",
"cool_down_secs": 300,
"adjustment": "-1"
},
{
"metric_type": "memoryused",
"breach_duration_secs": 600,
"threshold": 90,
"operator": ">=",
"cool_down_secs": 300,
"adjustment": "+1"
}],
"schedules": {
"timezone": "Asia/Shanghai",
"recurring_schedule": [{
"start_time": "10:00",
"end_time": "18:00",
"days_of_week": [
1,
2,
3
],
"instance_min_count": 1,
"instance_max_count": 10,
"initial_min_instance_count": 5
},
{
"start_date": "2016-06-27",
"end_date": "2016-07-23",
"start_time": "11:00",
"end_time": "19:30",
"days_of_month": [
5,
15,
25
],
"instance_min_count": 3,
"instance_max_count": 10,
"initial_min_instance_count": 5
},
{
"start_time": "10:00",
"end_time": "18:00",
"days_of_week": [
4,
5,
6
],
"instance_min_count": 1,
"instance_max_count": 10
},
{
"start_time": "11:00",
"end_time": "19:30",
"days_of_month": [
10,
20,
30
],
"instance_min_count": 1,
"instance_max_count": 10
}],
"specific_date": [{
"start_date_time": "2015-06-02T10:00",
"end_date_time": "2015-06-15T13:59",
"instance_min_count": 1,
"instance_max_count": 4,
"initial_min_instance_count": 2
},
{
"start_date_time": "2015-01-04T20:00",
"end_date_time": "2015-02-19T23:15",
"instance_min_count": 2,
"instance_max_count": 5,
"initial_min_instance_count": 3
}]
}
}
Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o
-d @policy.json \-X PUT \-H "Content-Type: application/json" \-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTI5MSIsImVtYWlsIjoiZW1haWwtMTk0QHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NTd9.p3cHAMwwVASl1RWxrQuOMLYRZRe4rTbaIH1RRux3Q5Y"
200 OK
- {
"instance_min_count": 1,
"instance_max_count": 4,
"scaling_rules": [{
"metric_type": "memoryused",
"breach_duration_secs": 600,
"threshold": 30,
"operator": "<",
"cool_down_secs": 300,
"adjustment": "-1"
},
{
"metric_type": "memoryused",
"breach_duration_secs": 600,
"threshold": 90,
"operator": ">=",
"cool_down_secs": 300,
"adjustment": "+1"
}],
"schedules": {
"timezone": "Asia/Shanghai",
"recurring_schedule": [{
"start_time": "10:00",
"end_time": "18:00",
"days_of_week": [
1,
2,
3
],
"instance_min_count": 1,
"instance_max_count": 10,
"initial_min_instance_count": 5
},
{
"start_date": "2016-06-27",
"end_date": "2016-07-23",
"start_time": "11:00",
"end_time": "19:30",
"days_of_month": [
5,
15,
25
],
"instance_min_count": 3,
"instance_max_count": 10,
"initial_min_instance_count": 5
},
{
"start_time": "10:00",
"end_time": "18:00",
"days_of_week": [
4,
5,
6
],
"instance_min_count": 1,
"instance_max_count": 10
},
{
"start_time": "11:00",
"end_time": "19:30",
"days_of_month": [
10,
20,
30
],
"instance_min_count": 1,
"instance_max_count": 10
}],
"specific_date": [{
"start_date_time": "2015-06-02T10:00",
"end_date_time": "2015-06-15T13:59",
"instance_min_count": 1,
"instance_max_count": 4,
"initial_min_instance_count": 2
},
{
"start_date_time": "2015-01-04T20:00",
"end_date_time": "2015-02-19T23:15",
"instance_min_count": 2,
"instance_max_count": 5,
"initial_min_instance_count": 3
}]
}
}
DELETE /v1/apps/:guid/policy
Name | Description | Valid values | Required | Example values |
guid | The GUID of the application | true |
Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o
-X DELETE \-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTI5MSIsImVtYWlsIjoiZW1haWwtMTk0QHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NTd9.p3cHAMwwVASl1RWxrQuOMLYRZRe4rTbaIH1RRux3Q5Y"
200 OK
GET /v1/apps/:guid/policy
Name | Description | Valid values | Required | Example values |
guid | The GUID of the application | true |
Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o
-X GET \-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTI5MSIsImVtYWlsIjoiZW1haWwtMTk0QHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NTd9.p3cHAMwwVASl1RWxrQuOMLYRZRe4rTbaIH1RRux3Q5Y"
200 OK
{
"instance_min_count": 1,
"instance_max_count": 4,
"scaling_rules": [{
"metric_type": "memoryused",
"breach_duration_secs": 600,
"threshold": 30,
"operator": "<",
"cool_down_secs": 300,
"adjustment": "-1"
},
{
"metric_type": "memoryused",
"breach_duration_secs": 600,
"threshold": 90,
"operator": ">=",
"cool_down_secs": 300,
"adjustment": "+1"
}],
"schedules": {
"timezone": "Asia/Shanghai",
"recurring_schedule": [{
"start_time": "10:00",
"end_time": "18:00",
"days_of_week": [
1,
2,
3
],
"instance_min_count": 1,
"instance_max_count": 10,
"initial_min_instance_count": 5
},
{
"start_date": "2016-06-27",
"end_date": "2016-07-23",
"start_time": "11:00",
"end_time": "19:30",
"days_of_month": [
5,
15,
25
],
"instance_min_count": 3,
"instance_max_count": 10,
"initial_min_instance_count": 5
},
{
"start_time": "10:00",
"end_time": "18:00",
"days_of_week": [
4,
5,
6
],
"instance_min_count": 1,
"instance_max_count": 10
},
{
"start_time": "11:00",
"end_time": "19:30",
"days_of_month": [
10,
20,
30
],
"instance_min_count": 1,
"instance_max_count": 10
}],
"specific_date": [{
"start_date_time": "2015-06-02T10:00",
"end_date_time": "2015-06-15T13:59",
"instance_min_count": 1,
"instance_max_count": 4,
"initial_min_instance_count": 2
},
{
"start_date_time": "2015-01-04T20:00",
"end_date_time": "2015-02-19T23:15",
"instance_min_count": 2,
"instance_max_count": 5,
"initial_min_instance_count": 3
}]
}
}
To scale with custom metric, your application need to emit its own metric to App Autoscaler's metric server.
Given the metric submission is proceeded inside an application, an App Autoscaler specific credential is required to authorize the access.
If App Autoscaler is offered as a service, the credential and autoscaler metric server's URL are injected into VCAP_SERVICES by service binding directly.
If App Autoscaler is offered as a Cloud Foundry extension, the credential need to be generated explictly.
Optional. A credential with random username/password will be generated by this API by default. Also it is supported to define credential with a specific pair of username and password with below JSON payload.
PUT /v1/apps/:guid/credential
{
"username": "username",
"password": "password"
}
Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o
curl "https://[the-api-server-url]:[port]/v1/apps/8d0cee08-23ad-4813-a779-ad8118ea0b91/credential" \-X PUT \-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o"
200 OK
- {
"app_id": "<APP_ID>",
"username": "MY_USERNAME",
"password": "MY_PASSWORD",
"url": "<AUTOSCALER METRIC SERVER URL>"
}
DELETE /v1/apps/:guid/credential
Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o
curl "https://[the-api-server-url]:[port]/v1/apps/8d0cee08-23ad-4813-a779-ad8118ea0b91/credential" \-X DELETE \-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o"
200 OK
POST /v1/apps/:guid/metrics
A JSON payload is required to emit your own metrics with the metric value and the correspondng instance index.
- {
"instance_index": <INSTANCE INDEX>,
"metrics": [{
"name": "<CUSTOM METRIC NAME>",
"value": <CUSTOM METRIC VALUE>,
"unit": "<CUSTOM METRIC UNIT>"
}]
}
- <INSTANCE INDEX> is the index of current application instance. You can fetch the index from environment variable CF_INSTANCE_INDEX
- <CUSTOM METRIC NAME> is the name of the emit metric which must be equal to the metric name that you define in the policy.
- <CUSTOM METRIC VALUE> is value that you would like to submit. The value here must be a NUMBER.
- <CUSTOM METRIC UNIT> is the unit of the metric, optional.
Basic authorization of autoscaler credential is required when submitting your own metrics to Autoscaler metric server.
-X PUT \-d @metric.json \-H "Content-Type: application/json" \-H "Authorization: basic xxxx"
200 OK
All error response are presented with a appropriate HTTP response code (like 4xx or 5xx) and a body containing a valid JSON Object.
The error response body is specified as:
{
"error": "error msg"
}