tencent cloud

文档反馈

GetAlarmLog

最后更新时间:2024-04-19 10:04:14

    1. API Description

    Domain name for API request: cls.tencentcloudapi.com.

    This API is used to access alarm policy execution details.

    A maximum of 30 requests can be initiated per second for this API.

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common Params. The value used for this API: GetAlarmLog.
    Version Yes String Common Params. The value used for this API: 2020-10-16.
    Region No String Common Params. This parameter is not required for this API.
    From Yes Integer Start time of the execution detail to be queried, Unix timestamp, unit: ms.
    To Yes Integer End time of the execution detail to be queried, Unix timestamp, unit: ms.
    Query Yes String Query filter criteria, for example:
    - Query by alert policy ID: alert_id:"alarm-0745ec00-e605-xxxx-b50b-54afe61fc971"
    - Query by monitoring object ID: monitored_object:"823d8bfa-76a7-xxxx-8399-8cda74d4009b"
    - Query by alarm policy ID and monitoring object ID: alert_id:"alarm-0745ec00-e605-xxxx-b50b-54afe61fc971" AND monitored_object:"823d8bfa-76a7-xxxx-8399-8cda74d4009b"
    - Query by alarm policy ID and monitoring object ID, supports SQL statement: (alert_id:"alarm-5ce45495-09e8-4d58-xxxx-768134bf330c") AND (monitored_object:"3c514e84-6f1f-46ec-xxxx-05de6163f7fe") AND NOT condition_evaluate_result: "Skip" AND condition_evaluate_result:[* TO *] | SELECT count(*) as top50StatisticsTotalCount, count_if(condition_evaluate_result='ProcessError') as top50StatisticsFailureCount, count_if(notification_send_result!='NotSend') as top50NoticeTotalCount, count_if(notification_send_result='SendPartFail' or notification_send_result='SendFail') as top50NoticeFailureCount, alert_id, alert_name, monitored_object, topic_type, happen_threshold, alert_threshold, notify_template group by alert_id, alert_name, monitored_object, topic_type, happen_threshold, alert_threshold, notify_template order by top50StatisticsTotalCount desc limit 1
    Limit No Integer The maximum number of execution details returned in a single query is 1000.
    Context No String Pass the Context value returned by the last API call to retrieve more subsequent logs. A total of up to 10,000 raw logs can be obtained, with an expiration time of 1 hour.Note:* When passing this parameter, do not modify any other parameters except for this one* This is only valid when the retrieval analysis statement (Query) does not contain SQL. For obtaining subsequent SQL results, refer to SQL LIMIT Syntax
    Sort No String Whether the original logs are returned in time order. Optional values are: asc (ascending) or desc (descending). The default is descNote:* This is only valid when the search and analysis statement (Query) does not contain SQL* For SQL result sorting, refer to SQL ORDER BY Syntax
    UseNewAnalysis No Boolean true: Indicates the use of the new retrieval result return method, with valid output parameters AnalysisRecords and Columns.false: Indicates the use of the old retrieval result return method, with valid output parameters AnalysisResults and ColNames.There is a slight difference in encoding format between the two return methods, and it is recommended to use true.

    3. Output Parameters

    Parameter Name Type Description
    Context String Context for loading subsequent details
    ListOver Boolean Whether alarm execution details within a specified time range are fully returned
    Analysis Boolean Whether return value is SQL analysis result or not
    ColNames Array of String Column names of analysis results. If the Query statement contains an SQL query, then column names of the queried fields will be returned;Otherwise, it will be empty.
    Note: This field may return null, indicating that no valid values can be obtained.
    Results Array of LogInfo Execution details query results.
    When there is no SQL statement in the Query field, it returns query results.
    When there is an SQL statement in the Query field, it may return null.
    Note: This field may return null, indicating that no valid values can be obtained.
    AnalysisResults Array of LogItems Execution details statistical analysis results. When there is an SQL statement in the Query field, it returns SQL statistical results; otherwise, it may return null.

    Note: This field may return null, indicating that no valid values can be obtained.
    AnalysisRecords Array of String Execution details statistical analysis results; only valid if UseNewAnalysis is true.Note: This field may return null, indicating that no valid values can be obtained.
    Columns Array of Column Column names of analysis results, valid only if UseNewAnalysis is trueNote: This field may return null, indicating that no valid values can be obtained.
    RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 Querying Logs

    This example shows you how to query the alarm history records of a specified alarm policy.

    Input Example

    POST / HTTP/1.1
    Host: cls.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: GetAlarmLog
    <Common request parameters>
    
    {
        "From": 1702569600000,
        "To": 1702655999999,
        "Query": "(alert_id:\"alarm-5ce45495-09e8-4d58-8f36-768134bf330c\") AND (monitored_object:\"3c514e84-6f1f-46ec-afbf-05de6163f7fe\") AND NOT condition_evaluate_result: \"Skip\" AND condition_evaluate_result:[* TO *] | SELECT count(*) as top50StatisticsTotalCount, count_if(condition_evaluate_result='ProcessError') as top50StatisticsFailureCount, count_if(notification_send_result!='NotSend') as top50NoticeTotalCount, count_if(notification_send_result='SendPartFail' or notification_send_result='SendFail') as top50NoticeFailureCount, alert_id, alert_name, monitored_object, topic_type, happen_threshold, alert_threshold, notify_template group by alert_id, alert_name, monitored_object,topic_type, happen_threshold, alert_threshold, notify_template order by top50StatisticsTotalCount desc limit 1",
        "Limit": 1
    }
    

    Output Example

    {
        "Response": {
            "Analysis": true,
            "AnalysisRecords": [],
            "AnalysisResults": [
                {
                    "Data": [
                        {
                            "Key": "topic_type",
                            "Value": "log"
                        },
                        {
                            "Key": "alert_threshold",
                            "Value": "15"
                        },
                        {
                            "Key": "top50NoticeFailureCount",
                            "Value": "0"
                        },
                        {
                            "Key": "happen_threshold",
                            "Value": "1"
                        },
                        {
                            "Key": "top50StatisticsFailureCount",
                            "Value": "0"
                        },
                        {
                            "Key": "alert_id",
                            "Value": "alarm-5ce45495-09e8-4d58-8f36-768134bf330c"
                        },
                        {
                            "Key": "top50StatisticsTotalCount",
                            "Value": "705"
                        },
                        {
                            "Key": "alert_name",
                            "Value": "EdgeOne Cache Hit Rate Alarm Policy_100001127589"
                        },
                        {
                            "Key": "monitored_object",
                            "Value": "3c514e84-6f1f-46ec-afbf-05de6163f7fe"
                        },
                        {
                            "Key": "top50NoticeTotalCount",
                            "Value": "0"
                        },
                        {
                            "Key": "notify_template",
                            "Value": "notice-8e0660a4-197d-46b0-b1ef-e63571b7a438"
                        }
                    ]
                }
            ],
            "ColNames": [
                "top50StatisticsTotalCount",
                "top50StatisticsFailureCount",
                "top50NoticeTotalCount",
                "top50NoticeFailureCount",
                "alert_id",
                "alert_name",
                "monitored_object",
                "topic_type",
                "happen_threshold",
                "alert_threshold",
                "notify_template"
            ],
            "Columns": [],
            "Context": "",
            "ListOver": true,
            "RequestId": "716f9f96-ed8c-4a20-9e75-dfa27ba9a273",
            "Results": []
        }
    }
    

    Example2 Querying the Alarm History Records of a Specified Alarm Policy and Alarm Object

    This example shows you how to query the alarm history records of a specified alarm policy and alarm object.

    Input Example

    POST / HTTP/1.1
    Host: cls.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: GetAlarmLog
    <Common request parameters>
    
    {
        "From": 1702569600000,
        "To": 1702655999999,
        "Query": "alert_id:\"alarm-5ce45495-09e8-4d58-8f36-768134bf330c\" AND monitored_object:\"3c514e84-6f1f-46ec-afbf-05de6163f7fe\"",
        "Limit": 1,
        "Context": ""
    }
    

    Output Example

    {
        "Response": {
            "Analysis": false,
            "AnalysisRecords": null,
            "AnalysisResults": [],
            "ColNames": [],
            "Columns": null,
            "Context": "Y29udGV4dC0yNmJkYjY1ZS1lODdjLTQ5Y2ItODdiYy0xNmUwNWFlYTYwM2MxNzAyNjEyMzA4MTU1",
            "ListOver": false,
            "RequestId": "aefbd480-35c5-43b7-b1df-d625727abebf",
            "Results": [
                {
                    "FileName": "",
                    "HostName": "",
                    "IndexStatus": "",
                    "LogJson": "{\"reach_trigger\":\"false\",\"label_string\":\"\",\"fire_time\":1702612278007,\"reach_notify\":\"false\",\"record_group_id\":\"\",\"topic_type\":\"log\",\"alert_threshold\":15,\"trigger_result\":\"success\",\"monitored_object\":\"3c514e84-6f1f-46ec-afbf-05de6163f7fe\",\"duration\":0,\"condition_evaluate_result\":\"QueryResultUnmatch\",\"notify_type\":2,\"summary_en\":\"The trigger condition is not met\",\"notification_send_result\":\"NotSend\",\"trigger_time\":1702612278,\"notify_template\":\"notice-8e0660a4-197d-46b0-b1ef-e63571b7a438\",\"summary_cn\":\"If the execution statement result does not meet the trigger conditions \",\"alert_id\":\"alarm-5ce45495-09e8-4d58-8f36-768134bf330c\",\"notify_result\":\"success\",\"topic_name\":\"dyltest2\",\"process_result\":\"fail\",\"notify_failed_reason\":\"\",\"object_param\":\"[{\\\"EndTime\\\":1702612230000,\\\"StartTime\\\":1702608630000,\\\"TopicId\\\":\\\"3c514e84-6f1f-46ec-afbf-05de6163f7fe\\\",\\\"TopicName\\\":\\\"dyltest2\\\",\\\"TopicType\\\":\\\"log\\\",\\\"grammarVersion\\\":\\\"cql\\\"}]\",\"uin\":100001127589,\"topic_id\":\"3c514e84-6f1f-46ec-afbf-05de6163f7fe\",\"record_info\":\"\",\"notify_time\":1702612278,\"level\":\"Warn\",\"process_error_msg\":\"The conditions are not matched, no results\",\"trigger\":\"$1.hit_rate<50\",\"trigger_failed_reason\":\"The conditions are not matched, no results\",\"happen_threshold\":1,\"record_id\":\"9e35be9f-b617-4827-96c5-97a0383aad0f\",\"nick_name\":\"\",\"logset_id\":\"19b6cec0-b80f-4ffe-98de-239670e5b19d\",\"detail\":\"\",\"alert_name\":\"EdgeOne Cache Hit Rate Alarm Policy_100001127589\",\"process_error_type\":\"QueryResultUnmatch\",\"status\":\"QueryResultUnmatch\"}",
                    "PkgId": "",
                    "PkgLogId": "",
                    "RawLog": "",
                    "Source": "",
                    "Time": 1702612278007,
                    "TopicId": "louder",
                    "TopicName": "louder"
                }
            ]
        }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    FailedOperation Operation failed.
    FailedOperation.GetlogReachLimit The number of searched logs has reached the upper limit.
    FailedOperation.InvalidContext The search cursor is invalid or does not exist.
    FailedOperation.QueryError The query statement failed to run.
    FailedOperation.SearchTimeout The query timed out.
    FailedOperation.SyntaxError An error occurred while parsing the query statement.
    FailedOperation.Timeout Operation timed out
    FailedOperation.TopicIsolated The log topic has been isolated.
    InternalError Internal error.
    InternalError.SearchError Retrieval error
    InternalError.SearchFailed Retrieval failed
    InvalidParameter Incorrect parameter.
    LimitExceeded.LogSearch The number of concurrent queries exceeds the limit, which is 15 per topic.
    MissingParameter Missing parameter.
    OperationDenied Operation denied.
    OperationDenied.AccountDestroy The account has been terminated.
    OperationDenied.AccountIsolate The account has overdue payments.
    OperationDenied.AccountNotExists The account does not exist.
    ResourceNotFound.TopicNotExist The log topic does not exist.
    UnsupportedOperation Unsupported operation.
    联系我们

    联系我们,为您的业务提供专属服务。

    技术支持

    如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

    7x24 电话支持