All Products
Search
Document Center

CloudMonitor:PutLogMonitor

Last Updated:Mar 18, 2024

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

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
LogIdstringNo

The ID of the log monitoring metric.

16****
SlsRegionIdstringYes

The region in which the Simple Log Service project resides.

cn-hangzhou
SlsProjectstringYes

The name of the Simple Log Service project.

test-project
SlsLogstorestringYes

The name of the Simple Log Service Logstore.

test-logstore
MetricNamestringYes

The metric name. For more information about the metrics for cloud services, see Appendix 1: Metrics.

cpu_total
MetricExpressstringNo

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: required.
  • errorPercent: the alias of the field generated in the calculation result. You can specify the alias as needed.
  • 5XXNumber/TotalNumber*100: the calculation expression.
{"extend":{"errorPercent":"5XXNumber/TotalNumber*100"}}
GroupIdstringNo

The ID of the application group.

7301****
ValueFilterRelationstringYes

The logical operator that is used between log filter conditions. Valid values:

  • and
  • or
Note The ValueFilterRelation and ValueFilter.N.Key parameters must be used in pair.
and
TumblingwindowsstringNo

The size of the tumbling window for calculation. Unit: seconds. CloudMonitor performs aggregation for each tumbling window.

60,300
UnitstringNo

The unit.

Percent
Aggregatesobject []Yes

The aggregation logic.

FieldNamestringYes

The name of the field to be aggregated. Valid values of N: 1 to 10.

sourceCount
FunctionstringYes

The function that is used to aggregate log data within a statistical period. Valid values of N: 1 to 10. Valid values:

  • count: counts the number.
  • sum: calculates the total value.
  • avg: calculates the average value.
  • max: calculates the maximum value.
  • min: calculates the minimum value.
  • countps: calculates the number of values of the specified field divided by the total number of seconds within a statistical period.
  • sumps: calculates the sum of the values of the specified field divided by the total number of seconds within a statistical period.
  • distinct: calculates the number of unique values of the specified field within a statistical period.
count
AliasstringYes

The alias of the aggregate function. Valid values of N: 1 to 10.

Count
Groupbysobject []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.

FieldNamestringNo

The name of the field that is specified as the dimension. Valid values of N: 1 to 10.

cpu
AliasstringNo

The alias of the dimension based on which the data is grouped. Valid values of N: 1 to 10.

CPUUtilization
ValueFilterobject []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.

KeystringNo

The name of the log field that is used for matching in the filter condition. Valid values of N: 1 to 10.

lh_source
ValuestringNo

The field value to be matched in the filter condition. Valid values of N: 1 to 10.

test
OperatorstringNo

The method that is used to match the field value. Valid values of N: 1 to 10. Valid values:

  • contain: contains
  • notContain: does not contain
  • >: greater than
  • <: less than
  • >=: greater than or equal to
  • <=: less than or equal to
contain

For more information about common request parameters, see Common parameters.

Response parameters

ParameterTypeDescriptionExample
object
Codestring

The HTTP status code.

Note The status code 200 indicates that the request was successful.
200
Messagestring

The returned message.

  • If the request was successful, successful is returned.
  • If the request failed, an error message is returned. Example: alias of aggreate must be set value.
successful
RequestIdstring

The request ID.

91561287-0802-5F9C-9BDE-404C50D41B06
LogIdstring

The ID of the log monitoring metric.

16****
Successboolean

Indicates whether the request was successful. Valid values:

  • true
  • false
true

Examples

Sample success responses

JSONformat

{
  "Code": "200",
  "Message": "successful",
  "RequestId": "91561287-0802-5F9C-9BDE-404C50D41B06",
  "LogId": "16****",
  "Success": true
}

Error codes

HTTP status codeError codeError messageDescription
400ParameterInvalid%s-
400LimitorErrorLog monitor limit is not enough-
403AccessForbiddenUser not authorized to operate on the specified resource.-
404ResourceNotFoundThe specified resource is not found.The specified resource is not found.
500InternalErrorThe request processing has failed due to some unknown error.-

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history