This repository has been archived by the owner on Dec 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
modify doc for custom metric #536
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ Scaling History API | |
Route | ||
''''' | ||
|
||
GET /v1/apps/8d0cee08-23ad-4813-a779-ad8118ea0b91/scaling\_histories | ||
GET /v1/apps/:guid/scaling\_histories | ||
|
||
Parameters | ||
'''''''''' | ||
|
@@ -133,7 +133,7 @@ Application Metric API | |
Route | ||
''''' | ||
|
||
GET /v1/apps/8d0cee08-23ad-4813-a779-ad8118ea0b91/metric_histories/memoryused | ||
GET /v1/apps/:guid/metric_histories/memoryused | ||
|
||
Parameters | ||
'''''''''' | ||
|
@@ -143,13 +143,13 @@ Parameters | |
+--------------------+-------------------------------------------------------------------------------+---------------------------------------------------------------------+-----------------------+----------------------------------+ | ||
| guid | The GUID of the application | | true | | | ||
+--------------------+-------------------------------------------------------------------------------+---------------------------------------------------------------------+-----------------------+----------------------------------+ | ||
| metric-type | The metric type | String, memoryused,memoryutil,responsetime, throughput | true | metric-type=memoryused | | ||
| metric_type | The metric type | String, memoryused,memoryutil,responsetime, throughput 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 scaling history will be order by timestamp asc or desc. | string,”asc” or "desc" | false. default desc | order-direction=asc | | ||
| 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 | | ||
+--------------------+-------------------------------------------------------------------------------+---------------------------------------------------------------------+-----------------------+----------------------------------+ | ||
|
@@ -229,7 +229,7 @@ Body | |
|
||
] | ||
|
||
*List aggregated metrics of an application** | ||
**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. | ||
|
@@ -243,7 +243,7 @@ AutoScaler collects the instances' metrics of an application, and aggregate the | |
Route | ||
''''' | ||
|
||
GET /v1/apps/8d0cee08-23ad-4813-a779-ad8118ea0b91/aggregated_metric_histories/memoryused | ||
GET /v1/apps/:guid/aggregated_metric_histories/memoryused | ||
|
||
Parameters | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the Parameters definition:
|
||
'''''''''' | ||
|
@@ -253,13 +253,13 @@ Parameters | |
+--------------------+-------------------------------------------------------------------------------+---------------------------------------------------------------------+-----------------------+----------------------------------+ | ||
| guid | The GUID of the application | | true | | | ||
+--------------------+-------------------------------------------------------------------------------+---------------------------------------------------------------------+-----------------------+----------------------------------+ | ||
| metric-type | The metric type | String, memoryused,memoryutil,responsetime, throughput | true | metric-type=memoryused | | ||
| metric_type | The metric type | String, memoryused,memoryutil,responsetime, throughput 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 scaling history will be order by timestamp asc or desc. | string,”asc” or "desc" | false. default desc | order-direction=asc | | ||
| 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 | | ||
+--------------------+-------------------------------------------------------------------------------+---------------------------------------------------------------------+-----------------------+----------------------------------+ | ||
|
@@ -335,7 +335,7 @@ Body | |
Policy API | ||
---------- | ||
|
||
Set Policy | ||
Create Policy | ||
~~~~~~~~~~ | ||
|
||
PUT /v1/apps/:guid/policy | ||
|
@@ -545,7 +545,7 @@ cURL | |
"https://[the-api-server-url]:[port]/v1/apps/8d0cee08-23ad-4813-a779-ad8118ea0b91/policy" \\ | ||
| -d @policy.json \\ | ||
| -X PUT \\ | ||
| -H "Content-Type: application/json" | ||
| -H "Content-Type: application/json" \\ | ||
| -H "Authorization: bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTI5MSIsImVtYWlsIjoiZW1haWwtMTk0QHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NTd9.p3cHAMwwVASl1RWxrQuOMLYRZRe4rTbaIH1RRux3Q5Y" | ||
|
||
Response | ||
|
@@ -989,6 +989,164 @@ Body | |
|
||
} | ||
|
||
|
||
Custom metric API | ||
----------------- | ||
|
||
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. | ||
|
||
**Create credential** | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
**PUT /v1/apps/:guid/credential** | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
Otptional. 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. | ||
zyjiaobj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
**Request** | ||
^^^^^^^^^^^ | ||
|
||
Route | ||
''''' | ||
|
||
PUT /v1/apps/:guid/credential | ||
|
||
Body | ||
'''' | ||
|
||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part of json content is not well-formatted in preview. |
||
|
||
"username": "username", | ||
|
||
"password": "password" | ||
} | ||
|
||
Headers | ||
''''''' | ||
Authorization: bearer | ||
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5\_Iu\_o | ||
|
||
cURL | ||
'''' | ||
| 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" | ||
|
||
|
||
Response | ||
^^^^^^^^ | ||
|
||
Status | ||
'''''' | ||
|
||
200 OK | ||
|
||
Body | ||
'''' | ||
|
||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part of json content is not well-formatted in preview. |
||
"app_id": "<APP_ID>", | ||
|
||
"username": "MY_USERNAME", | ||
|
||
"password": "MY_PASSWORD", | ||
|
||
"url": "<AUTOSCALER METRIC SERVER URL>" | ||
} | ||
|
||
|
||
**Delete credential** | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
**DELETE /v1/apps/:guid/credential** | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
**Request** | ||
^^^^^^^^^^^ | ||
|
||
Route | ||
''''' | ||
|
||
DELETE /v1/apps/:guid/credential | ||
|
||
Headers | ||
''''''' | ||
Authorization: bearer | ||
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidWFhLWlkLTQwOCIsImVtYWlsIjoiZW1haWwtMzAzQHNvbWVkb21haW4uY29tIiwic2NvcGUiOlsiY2xvdWRfY29udHJvbGxlci5hZG1pbiJdLCJhdWQiOlsiY2xvdWRfY29udHJvbGxlciJdLCJleHAiOjE0NDU1NTc5NzF9.RMJZvSzCSxpj4jjZBmzbO7eoSfTAcIWVSHqFu5\_Iu\_o | ||
|
||
cURL | ||
'''' | ||
| 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" | ||
|
||
|
||
Response | ||
^^^^^^^^ | ||
|
||
Status | ||
'''''' | ||
|
||
200 OK | ||
|
||
|
||
**Submit custom metric to Autoscaler metric server** | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
**PUT /v1/apps/:guid/metrics** | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
**Request** | ||
^^^^^^^^^^^ | ||
|
||
Route | ||
''''' | ||
|
||
PUT /v1/apps/:guid/metrics | ||
|
||
Body | ||
'''' | ||
|
||
A JSON payload is required to emit your own metrics with the metric value and the correspondng instance index. | ||
|
||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part of json content is not well-formatted in preview. |
||
"instance_index": <INSTANCE INDEX>, | ||
|
||
"metrics": [ | ||
{ | ||
"name": "<CUSTOM METRIC NAME>", | ||
|
||
"value": <CUSTOM METRIC VALUE> | ||
} | ||
] | ||
} | ||
|
||
Headers | ||
''''''' | ||
Basic authorization of autoscaler credential is required when submitting your own metrics to Autoscaler metric server. | ||
|
||
cURL | ||
'''' | ||
| curl "https://[the-autoscaler-metric-server-url]:[port]/v1/apps/8d0cee08-23ad-4813-a779-ad8118ea0b91/metrics" \\ | ||
| -X PUT \\ | ||
| -d @metric.json \\ | ||
| -H "Content-Type: application/json" \\ | ||
| -H "Authorization: basic xxxx" | ||
|
||
Response | ||
^^^^^^^^ | ||
|
||
Status | ||
'''''' | ||
|
||
200 OK | ||
|
||
Error Response | ||
------------------- | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the Parameters definition:
metric_type
with '_' instead of '-' is used inGET /v1/apps/:guid/metric_histories/:metric_type
The scaling history will be order by timestamp asc or desc.
->The metric history will be order by timestamp asc or desc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zyjiaobj
1 "metric_type" is in path so it is different from query parameters, such as "start-time" or "order-direction".
2 "be order" or "be ordered"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean "scaling history" should be changed to "metric history", as this is
metric_histories
api.Also, "be ordered" should be better.