This topic describes how to query and analyze metric data in a Metricstore of 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 Log Service console.
  2. In the Projects section, click the project that you want to view.
  3. Choose Time Series Storage > Metricstore. On the Metricstore tab, click the Metricstore that you want to view.
  4. In the upper-right corner of the page that appears, 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. Log Service displays the results of multiple query statements in a time series chart.

    • Click Metrics Explorer. In the dialog box that appears, click the Plus icon icon for the metric that you want to use for the query. Log Service automatically generates a query statement.

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

    Query and analysis in a 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.

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.

    Correct syntax
  • 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.

    Incorrect syntax
During the verification, you can perform the following operations:
  • Click the Refresh icon to refresh the syntax parsing tree.
  • Click the More icon to display the node information about the syntax parsing tree.
  • Click the Show or Hide icon to show or hide nodes.
  • Click the Enable or Disable Automatic Tree Resolution icon to enable or disable the automatic tree resolution feature.

Metric exploration

After you click Metrics Explorer, Log Service displays metrics and allows you to configure the labels of the metrics. Metric exploration
In the dialog box of Metrics Explorer, 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 the Select Time icon to modify the time range.

    You can click the Reset 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 Copy a query statement 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 Plus icon 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, Count Distinct Values, and Tag Value Example.

    You can click Filter to specify label values. 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 or Add to Search Box to execute the query statement.

    Metric exploration

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. Legend Format

What to do next

OperationDescription
Metric StatisticsClick 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 GovernanceClick 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 DataIf you turn on Table Data, the system displays the query and analysis results in a table.
Preview Raw DataClick the View raw data icon. The system displays the raw metric data.
Data TransformationChoose More > Data Transformation. You can transform data. For more information, see Data transformation overview.
Custom AnalysisChoose 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.
Schedule to Save Analysis ResultsChoose More > Schedule to Save Analysis Results. You can use the Scheduled SQL feature to process metric data and store the results to a Metricstore. For more information, see Import data from Metricstore to Metricstore.
Add to New DashboardClick 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 Configure a time series chart.

Save as AlertClick Save as Alert. You can configure alerts for the query and analysis results. For more information, see Configure an alert rule.
CopyClick the Copy a query statement icon. You can copy the current query statement to add a new section for a query statement.
DeleteClick the Delete icon. You can delete the section of the current query statement.
Refresh dataClick the Refresh icon to the right of Execute Now. You can specify a refresh interval. Log Service automatically refreshes the Metricstore based on the interval that you specify.
ShareClick the Share 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.