Creating a Recording Rule for a Prometheus Instance
Function
This API is used to create a recording rule for a Prometheus instance.
Calling Method
For details, see Calling APIs.
URI
POST /v1/{project_id}/{prometheus_instance}/aom/api/v1/rules
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Project ID obtained from IAM. Generally, a project ID contains 32 characters. |
| prometheus_instance | Yes | String | Prometheus instance ID. Currently, only common Prometheus instances and Prometheus instances for CCE are supported. |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | User token obtained from IAM. |
| Content-Type | Yes | String | Content type, which is application/json. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| recording_rule | Yes | String | Recording rule. Details of the recording rule to be created. The following sub-parameters are supported:
|
Response Parameters
Status code: 204
No Content: The request is successful, but no content is returned.
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Error code. |
| error_msg | String | Error message. |
| error_type | String | Error type. |
| trace_id | String | Trace ID. |
Example Requests
Create a recording rule for a Prometheus instance.
https://{Endpoint}/v1/{project_id}/{prometheus_instance}/aom/api/v1/rules
{
"recording_rule" : "groups:\n - name: apiserver_request_total\n interval: 60s\n rules:\n - record: job_instance_mode:apiserver_request_total:avg_rate5m\n expr: avg by (job, instance, mode) (rate(apiserver_request_total[5m]))\n labels:\n team: operations\n - record: job:apiserver_request_total:sum_rate10m\n expr: sum by (job)(rate(apiserver_request_total[10m]))\n labels:\n team: operations"
} Example Responses
Status code: 500
The recording rule already exists.
{
"error_code" : "AOM.4001019",
"error_msg" : "recording rule exist for the prometheus instance"
} Status Codes
| Status Code | Description |
|---|---|
| 204 | No Content: The request is successful, but no content is returned. |
| 500 | The recording rule already exists. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.