Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
1004 lines (580 sloc) 32.2 KB

API Server Public Rest API

Scaling History API

List scaling history of an application

GET /v1/apps/:guid/scaling_histories

Request

Route
GET /v1/apps/8d0cee08-23ad-4813-a779-ad8118ea0b91/scaling_histories
Parameters
Headers
Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o
cURL
-X GET \
-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o"

Response

Status
200 OK
Body

{

"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": ""

}]

}

Application Metric API

List instance metrics of an application

GET /v1/apps/:guid/metric_histories/:metric_type

Request

Route
GET /v1/apps/8d0cee08-23ad-4813-a779-ad8118ea0b91/metric_histories/memoryused
Parameters
Headers
Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o
cURL
-X GET \
-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o"

Response

Status
200 OK
Body

[

"total_results": 2,

"total_pages": 1,

"page": 1,

"prev_url": null,

"next_url": "/v1/apps/8d0cee08-23ad-4813-a779-ad8118ea0b91/metric_histories/memoryused?start-time=1494989539138350432&end-time=1494989539138399999&order-direction=asc&page=2&results-per-page=10",

"resources": [{

"app_guid": "8d0cee08-23ad-4813-a779-ad8118ea0b91",

"instanceIndex": 0,

"timestamp": 1494989539138350433,

"collected_at": 1494989539138350000,

"metric_type": "memoryused",

"value": "400",

"unit": "megabytes"

},

{

"app_guid": "8d0cee08-23ad-4813-a779-ad8118ea0b91",

"instance_index": 1,

"timestamp": 1494989539138350433,

"collected_at": 1494989539138350000,

"metric_type": "memoryused",

"value": "400",

"unit": "megabytes"

}]

]

List aggregated metrics of an application*

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/:metric_type

Request

Route
GET /v1/apps/8d0cee08-23ad-4813-a779-ad8118ea0b91/aggregated_metric_histories/memoryused
Parameters
Headers
Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o
cURL
-X GET \
-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o"

Response

Status
200 OK
Body

[

"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"

}]

]

Policy API

Set Policy

PUT /v1/apps/:guid/policy

Request

Route
PUT /v1/apps/:guid/policy
Parameters
Name Description Valid values Required Example values
guid The GUID of the application   true  
Body

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

}]

}

}

Headers

Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o

cURL
-d @policy.json \
-X PUT \
-H "Content-Type: application/json"
-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTI5MSIsImVtYWlsIjoiZW1haWwtMTk0QHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NTd9.p3cHAMwwVASl1RWxrQuOMLYRZRe4rTbaIH1RRux3Q5Y"

Response

Status
200 OK
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

}]

}

}

Delete Policy

Delete /v1/apps/:guid/policy

Request

Route
DELETE /v1/apps/:guid/policy
Parameters
Name Description Valid values Required Example values
guid The GUID of the application   true  
Headers
Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o
cURL
-X DELETE \
-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTI5MSIsImVtYWlsIjoiZW1haWwtMTk0QHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NTd9.p3cHAMwwVASl1RWxrQuOMLYRZRe4rTbaIH1RRux3Q5Y"

Response

Status
200 OK

Get Policy

GET /v1/apps/:guid/policy

Request

Route
GET /v1/apps/:guid/policy
Parameters
Name Description Valid values Required Example values
guid The GUID of the application   true  
Headers
Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5_Iu_o
cURL
-X GET \
-H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTI5MSIsImVtYWlsIjoiZW1haWwtMTk0QHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NTd9.p3cHAMwwVASl1RWxrQuOMLYRZRe4rTbaIH1RRux3Q5Y"

Response

Status
200 OK
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

}]

}

}

Error Response

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"

}