Creates or modifies a log monitoring metric.
Operation description
In the example of this topic, the cpu_total
log monitoring metric is created. The response shows that the log monitoring metric is created and the metric ID is 16****
.
Debugging
Authorization information
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
LogId | string | No | The ID of the log monitoring metric. | 16**** |
SlsRegionId | string | Yes | The region in which the Simple Log Service project resides. | cn-hangzhou |
SlsProject | string | Yes | The name of the Simple Log Service project. | test-project |
SlsLogstore | string | Yes | The name of the Simple Log Service Logstore. | test-logstore |
MetricName | string | Yes | The metric name. For more information about the metrics for cloud services, see Appendix 1: Metrics. | cpu_total |
MetricExpress | string | No | The extended field. The extended field allows you to perform basic operations on the aggregation results. For example, you have calculated TotalNumber and 5XXNumber by aggregating the data. TotalNumber indicates the total number of HTTP requests, and 5XXNumber indicates the number of HTTP requests whose status code is greater than 499. You can calculate the server error rate by adding the following formula to the extended field: 5XXNumber/TotalNumber*100. JSON format: {"extend":{"errorPercent":"5XXNumber/TotalNumber*100"}}. Description:
| {"extend":{"errorPercent":"5XXNumber/TotalNumber*100"}} |
GroupId | string | No | The ID of the application group. | 7301**** |
ValueFilterRelation | string | Yes | The logical operator that is used between log filter conditions. Valid values:
Note
The ValueFilterRelation and ValueFilter.N.Key parameters must be used in pair.
| and |
Tumblingwindows | string | No | The size of the tumbling window for calculation. Unit: seconds. CloudMonitor performs aggregation for each tumbling window. | 60,300 |
Unit | string | No | The unit. | Percent |
Aggregates | object [] | Yes | The aggregation logic. | |
FieldName | string | Yes | The name of the field to be aggregated. Valid values of N: 1 to 10. | sourceCount |
Function | string | Yes | The function that is 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 | object [] | No | The dimension based on which the data is grouped. This parameter is equivalent to the GROUP BY clause in SQL statements. If no dimension is specified, all data is aggregated based on the aggregate function. | |
FieldName | string | No | The name of the field that is specified as the dimension. Valid values of N: 1 to 10. | cpu |
Alias | string | No | The alias of the dimension based on which the data is grouped. Valid values of N: 1 to 10. | CPUUtilization |
ValueFilter | object [] | No | The condition that is used to filter logs. The ValueFilter and ValueFilterRelation parameters are used in pair. The filter condition is equivalent to the WHERE clause in SQL statements. If no filter condition is specified, all logs are processed. For example, logs contain the Level and Error fields. If you need to calculate the number of times that logs of the Error level appear every minute, you can set the filter condition to Level=Error and count the number of logs that meet this condition. | |
Key | string | No | The name of the log field that is used for matching in the filter condition. Valid values of N: 1 to 10. | lh_source |
Value | string | No | The field value to be matched in the filter condition. Valid values of N: 1 to 10. | test |
Operator | string | No | The method that is used to match the field value. Valid values of N: 1 to 10. Valid values:
| contain |
For more information about common request parameters, see Common parameters.
Response parameters
Examples
Sample success responses
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 | - |
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. |
500 | InternalError | The request processing has failed due to some unknown error. | - |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|