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.
PrerequisitesMetric data is collected.
- Log on to the Log Service console.
- In the Projects section, click the project that you want to view.
- Choose . On the Metricstore tab, click the Metricstore that you want to view.
- 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.
- 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 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.
- Enter a PromQL statement and click Execute Now.
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.
- 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.
- 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.
- 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 icon to modify the time range.
You can 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, 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.
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.
What to do next
|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.
|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.
|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.
|Choose Data transformation overview.. You can transform data. For more information, see
|Choose. 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 Results
|Choose Import data from Metricstore to Metricstore.. You can use the Scheduled SQL feature to process metric data and store the results to a Metricstore. For more information, see
|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 Configure a 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.
|Click the icon. You can copy the current query statement to add a new section for a query statement.
|Click the icon. You can delete the section of the current query statement.
|Click the 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.
|Click the 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.