Simple Log Service provides intelligent analysis capabilities that can be used to analyze basic data such as logs, metrics, and traces. You can call the GetMLServiceResults operation to obtain the analysis results of a model. You can call the operation in the following scenarios: Named Entity Recognition (NER) tasks on logs, anomaly detection on time series, and root cause analysis on high-latency traces.
Operation description
You must obtain the following basic permissions before you call this operation:
{
"Version": "1",
"Statement": [
{
"Action": [
"log:Get*"
],
"Resource": [
"acs:log:*:*:mlservice/sls_builtin_*"
],
"Effect": "Allow"
}
]
}
Debugging
Authorization information
Request syntax
POST /ml/service/{serviceName}/analysis HTTP/1.1
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
serviceName | string | No | The name of the service. Valid values:
| sls_builtin_service_log_struct |
version | string | No | The version of the algorithm. The algorithm varies based on the version. | v1 |
body | MLServiceAnalysisParam | No |
The parameters for a request vary based on the scenarios.
NER tasks on logs (sls_builtin_service_log_struct)
Parameters related to body.parameter
{
"is_struct": "true",
"use_gpu": "true/false",
"max_fields": "1"
}
- is_struct specifies the format of logs. If you set is_struct to true, logs are in the JSON format. You must set the value to true.
- use_gpu specifies whether to use GPU resources.
- max_fields specifies the maximum number of fields that can be analyzed when logs are in the JSON format. By default, only one field is analyzed.
Parameters related to body.input
[
{
"{column_name}": "{column_value}"
}
]
The specified content is a JSON array-formatted log whose fields consist of column_name and column_value.
- column_name specifies the name of a log field.
- column_value specifies the value of a log field.
Anomaly detection on time series (sls_builtin_service_metric_anomaly)
Parameters related to body.parameter
{
"isOrdered": "true/false",
"keys": "[]",
"timeColumnName": "",
"analysisColumnNames": "[]",
"interval": "-1"
}
- isOrdered specifies whether the data is sorted in order. If the data is sorted in chronological order, set isOrdered to true. Otherwise, set isOrdered to false.
- interval specifies the interval of time series. Unit: seconds. For example, if the interval of time series is 1 minute, which is equivalent to 60 seconds, set interval to 60. If the interval of time series cannot be identified, set interval to -1.
- timeColumnName specifies the name of the time dimension in the time series.
- analysisColumnNames specifies the feature dimension used for data analysis in the time series. The value is an array and must be serialized into a string.
- keys specifies the names of the fields for the time series data. The value is an array and must be serialized into a string.
Parameters related to body.input
[
{
"{column_name}": "{column_value}"
}
]
The specified content is a time series array whose fields consist of column_name and column_value.
- column_name specifies the name of a field in the time series.
- column_value specifies the value of a field in the time series. If the value of {column_name} is equal to the value of {timeColumnName}, the value of column_value is a timestamp in seconds.
High-latency trace analysis (sls_builtin_service_trace_rca)
Parameters related to body.parameter
{
"project": "",
"logstore": "",
"endpoint": "",
"role_arn": ""
}
- project specifies the name of the Simple Log Service project that stores the traces for analysis.
- logstore specifies the name of the Simple Log Service Logstore that stores the traces for analysis.
- endpoint specifies the endpoint for the region where your project resides. You must specify a public endpoint. This operation does not support data access by using an internal endpoint.
- role_arn specifies the Alibaba Cloud Resource Name (ARN) of the role that is granted the required permissions on resources. You must specify the ARN of the ETLRole or AuditRole role.
Parameters related to body.input
[
{
"service": "",
"name": "",
"from_ts_sec": "",
"to_ts_sec": "",
"slo_ts_micro": "",
"batch_id": "",
"trace_ids": "[]"
}
]
The specified content is a trace array and the length of the array is 1. The following list describes the fields in the array.
- service specifies the service name for a trace ID or trace IDs that you want to analyze. You can obtain the service name from the Logstore.
- name specifies the operation name for a trace ID or trace IDs that you want to analyze. You can obtain the operation name from the Logstore.
- from_ts_sec specifies the start timestamp of trace analysis. Unit: seconds.
- to_ts_sec specifies the end timestamp of trace analysis. Unit: seconds.
- batch_id specifies the batch of trace IDs that you want to analyze in the request.
- trace_ids specifies the trace IDs that you want to analyze in the request. Serialize the trace IDs into a JSON-formatted string.
Response parameters
The return value varies based on different scenarios. Examples:
NER tasks on logs (sls_builtin_service_log_struct)
Return value related to data
[
{
"{column_name}": "{column_value}"
}
]
The JSON-formatted data in the return value corresponds to the JSON-formatted log data that you specify in the request. The fields of the specified JSON-formatted log data consist of column_name and column_value.
- column_name indicates the name of the field that is analyzed. max_fields indicates the maximum number of fields that are analyzed.
- column_name indicates the value of the field that is analyzed. The results of NER tasks in the field value are enclosed by the tag <ml_ner_${ner_type}></ml_ner_${ner_type}>, in which ${ner_type} indicates the type of NER.
Anomaly detection on time series (sls_builtin_service_metric_anomaly)
Return value related to data
[
{
"start": "",
"end": "",
"label": ""
}
]
-
start indicates the start time of the time range during which anomalies are detected.
-
end indicates the end time of the time range during which anomalies are detected.
-
label indicates the types of anomalies that are detected within the specified query time range.
- SPIKE_UP_TYPE
- SPIKE_DOWN_TYPE
- TREND_UP_TYPE
- TREND_DOWN_TYPE
- MEANSHIFT_UPWARD_TYPE
- MEANSHIFT_DOWNWARD_TYPE
High-latency trace analysis (sls_builtin_service_trace_rca)
Return value related to data
[
{
"traceID": "",
"service": "",
"name": "",
"rootCauses": "[{}]"
}
]
- trace ID indicates the ID of the trace that is analyzed.
- service indicates the service name for the root node of the trace.
- name indicates the operation name for the root node of the trace.
- rootCauses indicates the spans that cause high latency for the trace. The value is a serialized string. The following code shows the body of the parameter value after the value is deserialized:
[
{
"spanID": "",
"service": "",
"name": "",
"host": "xxxx",
"predicateDuration": 10
}
]
Examples
Sample success responses
JSON
format
{
"status": {
"key": "200"
},
"data": [
{
"key": "{'marker': ''}"
}
]
}
Error codes
For a list of error codes, visit the Service error codes.