Creates or modifies a log monitoring metric by calling the PutLogMonitor operation.
Operation description
This topic provides an example of how to create a log monitoring metric named cpu_total. The response shows that the log monitoring metric is created. The log monitoring metric ID is 16****.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
cms:PutLogMonitor |
create |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| LogId |
string |
No |
The ID of the log monitoring metric. |
16**** |
| SlsRegionId |
string |
Yes |
The region where the Log Service project resides. |
cn-hangzhou |
| SlsProject |
string |
Yes |
The name of the Log Service project. |
test-project |
| SlsLogstore |
string |
Yes |
The name of the Log Service Logstore. |
test-logstore |
| MetricName |
string |
Yes |
The metric name. For information about the metrics supported by CloudMonitor for Alibaba Cloud services, see Cloud service monitoring metrics. |
cpu_total |
| MetricExpress |
string |
No |
The extended field. The extended field provides arithmetic operations on the results of the statistical methods. For example, if you configure the total number of HTTP status code requests (TotalNumber) and the number of requests with HTTP status codes greater than 499 (5xxNumber) in the statistical methods, you can use the extended field to calculate the server error rate: 5xxNumber/TotalNumber*100. JSON format: {"extend":{"errorPercent":"5xxNumber/TotalNumber*100"}}. Field description:
|
{"extend":{"errorPercent":"5XXNumber/TotalNumber*100"}} |
| GroupId |
string |
No |
The ID of the application group. |
7301**** |
| ValueFilterRelation |
string |
Yes |
The logical operator used to combine log filter conditions. Valid values:
Note
This parameter must be used together with |
and |
| Tumblingwindows |
string |
No |
The tumbling window size for pre-aggregation. Unit: seconds. CloudMonitor performs an aggregation calculation on the data at the specified interval. |
60,300 |
| Unit |
string |
No |
The unit. |
Percent |
| Aggregates |
array<object> |
Yes |
The aggregate function definitions. |
|
|
object |
No |
|||
| FieldName |
string |
Yes |
The name of the original field for aggregation. Valid values of N: 1 to 10. |
sourceCount |
| Function |
string |
Yes |
The statistical method used to aggregate log data within a statistical period. Valid values of N: 1 to 10. Valid values:
|
count |
| Alias |
string |
Yes |
The alias of the aggregate function. Valid values of N: 1 to 10. |
Count |
| Groupbys |
array<object> |
No |
The dimensions used for spatial aggregation. This is equivalent to the Group By clause in SQL, which groups monitoring data by specified dimensions. If no dimension is specified, all monitoring data is aggregated based on the aggregate function. |
|
|
object |
No |
|||
| FieldName |
string |
No |
The name of the Group By field. Valid values of N: 1 to 10. |
cpu |
| Alias |
string |
No |
The alias of the Group By field. Valid values of N: 1 to 10. |
CPUUtilization |
| ValueFilter |
array<object> |
No |
The filter rules, used together with ValueFilterRelation. This is equivalent to the Where clause in SQL. If this parameter is not specified, all data is processed. For example, if the log contains Level and Error fields and you want to count the number of Error occurrences per minute, you can define the statistical method to sum the Level field with the condition Level=Error. |
|
|
object |
No |
|||
| Key |
string |
No |
The name of the log field to match. Valid values of N: 1 to 10. |
lh_source |
| Value |
string |
No |
The value of the log field to match. Valid values of N: 1 to 10. |
test |
| Operator |
string |
No |
The matching method for the field value. Valid values of N: 1 to 10. Valid values:
|
contain |
For more information about common request parameters, see Common parameters.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| Code |
string |
The HTTP status code. Note
200 indicates success. |
200 |
| Message |
string |
The returned message. Results:
|
successful |
| RequestId |
string |
The request ID. |
91561287-0802-5F9C-9BDE-404C50D41B06 |
| LogId |
string |
The ID of the log monitoring metric. |
16**** |
| Success |
boolean |
Indicates whether the operation is successful. Valid values:
|
true |
Examples
Success response
JSON format
{
"Code": "200",
"Message": "successful",
"RequestId": "91561287-0802-5F9C-9BDE-404C50D41B06",
"LogId": "16****",
"Success": true
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | ParameterInvalid | %s | |
| 400 | LimitorError | Log monitor limit is not enough | |
| 500 | InternalError | The request processing has failed due to some unknown error. | |
| 403 | AccessForbidden | User not authorized to operate on the specified resource. | |
| 404 | ResourceNotFound | The specified resource is not found. | The specified resource is not found. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.