All Products
Search
Document Center

Simple Log Service:Query and analyze metric data

Last Updated:Mar 22, 2024

This topic describes how to query and analyze metric data in a Metricstore of Simple Log Service. This topic also describes how to configure the format of legend items in a time series chart.

Prerequisites

Metric data is collected.

Procedure

Note

You can use only the PromQL syntax on the query and analysis page of a Metricstore. If you want to use the standard SQL syntax or the combination of SQL and PromQL, you can choose More > Custom Analysis on the query and analysis page of the Metricstore to go to the query and analysis page of the Logstore that is automatically created for the Metricstore.

  1. Log on to the Simple Log Service console.

  2. In the Projects section, click the project that you want to manage.

    image

  3. On the Metric Storage > Metricstores tab, click the Metricstore that you want to manage.

  4. In the upper-right corner of the page, click 15 Minutes(Relative) to specify a time range for the query.

    Note

    The query and analysis results may contain metric data that is generated 1 minute earlier or later than the specified time range.

  5. Execute a query statement.

    You can use the following methods to add a query statement:

    • Enter a PromQL statement and click Execute Now.

      You can add multiple query statements. Simple Log Service displays the results of multiple query statements in a time series chart.

    • Click Metrics Explore. In the dialog box that appears, find the metric that you want to use for the query and click the 加号 icon in the Actions column. Simple Log Service automatically generates a query statement.

      In the dialog box of Metrics Explore, you can also find a metric and click Continue to Explore in the Actions column to specify label values. Simple Log Service automatically generates query statements based on your settings. For more information, see Metric exploration.

    Metricstore查询分析

Verification of the PromQL syntax

If the automatic tree resolution feature is enabled, the system prompts information when you enter a PromQL statement. The information includes PromQL functions, aggregate functions, metric names, label keys, label values, and time ranges. For more information, see Prometheus documentation.

Simple Log Service also supports real-time syntax verification when you enter a PromQL statement.

  • Correct syntax

    If the message The syntax is valid. is displayed, the syntax passes the verification. A syntax parsing tree is generated.

    正确语法

  • Incorrect syntax

    If an error message is displayed, the syntax fails the verification. A syntax parsing tree is generated only for partial syntax, and the position and cause of the error are displayed.

    错误语法

During the verification, you can perform the following operations:

  • Click the 刷新 icon to refresh the syntax parsing tree.

  • Click the 更多 icon to display the node information about the syntax parsing tree.

  • Click the 展开 or 收起 icon to show or hide nodes.

  • Click the 开启 or 关闭自动树状解析功能 icon to enable or disable the automatic tree resolution feature.

Metric exploration

After you click Metrics Explore, Simple Log Service displays metrics and allows you to configure the labels of the metrics. Metric探索

In the dialog box of Metrics Explore, you can perform the following operations:

  • Specify a query time range. The default query time range for metric exploration is the previous 5 minutes. This helps ensure the response speed. If the time interval of data in your Metricstore is large or you want to specify a custom time range, you can click Change to modify the time range

    Click the 重置 icon to restore the query time range to the default setting.

  • Filter metrics. You can enter a metric name in the search box to filter metrics.

  • Copy a metric name. You can click the 复制查询分析 icon to copy a metric name.

  • Add a metric name to the field in which you can enter a query statement. You can click the 加号 icon to add a metric name to the field.

  • Continue to explore data. You can click the Continue to Explore button to view the label data of a metric, including Tag Name, Unique Number, and Example.

    You can click Filter to specify label values. Simple Log Service supports four operators of the PromQL syntax for the filter mechanism. You can select an operator and select or enter a filter condition. Regular expressions are supported.

    After the configuration is complete, the system automatically displays a query statement that is generated based on the configuration. You can click Copy Query Statement or Add to Search Box to execute the query statement.

    指标探索

Configure the format of legend items in a time series chart

After you execute a query statement, you can configure the display names of legend items in the time series chart.

By default, the name of a legend item in a time series chart consists of a metric name and the labels of the metric. You can use a variable to reference a label value as the name of a legend item. Format: {{Key of a label value}}. For example, a label is {ip="192.0.2.1"}. If you enter {{ip}} in the Legend Format field, the name of the legend item in the time series chart is displayed as 192.0.2.1. 图例格式化

What to do next

Operation

Description

Metric Statistics

Click Metric Statistics. You are redirected to the Metric Statistics dashboard. The dashboard displays the important statistics about the Metricstore, including the data volume, number of metrics, number of timelines, changes in data entries, and the quick location and comparison of top-level metrics.

Metric Governance

Click Metric Governance. You are redirected to the Metric Governance dashboard. The dashboard displays the analysis results of time series scenarios for important metrics, changes of important metrics in time series charts, and summary statistics of metrics in kanbans. You can also view a solution that involves native statistics, data analysis, performance optimization, and exception diagnostics.

Table Data

If you turn on Table Data, the system displays the query and analysis results in a table.

Preview Raw Data

Click the 查看原始数据 icon. The system displays the raw metric data.

Data Transformation

Choose More > Data Transformation. You can transform data. For more information, see Overview of data transformation.

Custom Analysis

Choose More > Custom Analysis. You are redirected to the query and analysis page of the Logstore that is automatically created for the Metricstore. On this page, you can use the SQL syntax or the combination of SQL and PromQL for queries.

Save as Scheduled SQL Job

Choose More > Save as Scheduled SQL Job. You can use the Scheduled SQL feature to process metric data and store the results to a Metricstore. For more information, see Process and save data from a Metricstore to another Metricstore.

Add to New Dashboard

Click Add to New Dashboard. You can add the query and analysis results to a dashboard. For more information, see Add a chart (Pro) to a dashboard.

After you add a time series chart to a dashboard, you can modify the attributes of the chart based on your business requirements. For more information, see Time series chart.

Save as Alert

Click Save as Alert. You can configure alerts for the query and analysis results. For more information, see Configure an alert rule.

Copy

Click the 复制查询分析 icon. You can copy the current query statement to add a new section for a query statement.

Delete

Click the 删除 icon. You can delete the section of the current query statement.

Refresh

Click the 刷新数据 icon to the right of Execute Now. You can specify a refresh interval. Simple Log Service automatically refreshes the Metricstore based on the interval that you specify.

Share

Click 分享 icon. You can copy the URL of the query and analysis page of the current Metricstore. You can send the URL to other users who have permissions to view the Metricstore. The URL points to a query and analysis page that uses the settings of the original page at the time when you copy the URL.