A Storeview for Metricstore allows you to perform JOIN queries on logs across metricstores. This topic describes how to use PromQL statements to query data in a Storeview, connect a Storeview to Grafana, and call API operations to obtain Storeview information.
Prerequisite
A project and metricstores are created. For more information, see Manage a project and Manage a metricstore.
Create a Storeview for Metricstore and associate metricstores
1. Create a Storeview for Metricstore
Log on to the Simple Log Service console. In the Projects section, click the project that you want to manage.
In the left-side navigation pane, choose
. On the page that appears, click theicon to create a Storeview for Metricstore.
In the Create Storeview panel, specify the Storeview Name parameter, add the Metricstores that you want to associate with the Storeview, and then click OK.
ImportantThe first metricstore in a Storeview must belong to the same project as the Storeview.
A Storeview for Metricstore allows you to perform JOIN queries and analysis on logs across metricstores. To ensure the accuracy of the query and analysis results, take note of the following items:
We recommend that you do not associate metricstores that have duplicate timelines with the same Storeview.
We recommend that you do not associate multiple metricstores that store a large amount of data to perform calculations. For example, the number of shards in a metricstore exceeds 64.
2. Use a PromQL statement to query a Storeview
After you associate multiple metricstores with a Storeview for Metricstore, you can view the query and analysis results across multiple metricstores.
Storeviews for Metricstore do not support SQL statements and predefined processing. You can directly enter a PromQL statement in the search box. The backend computing engine automatically performs calculations across multiple metricstores. For more information, see PromQL.
Connect a Storeview for Metricstore to Grafana
Install and log on to Grafana. For more information, see Install Grafana. In the left-side navigation pane, choose .
On the Data Sources tab, click Add data source. Select Prometheus and click Select.
On the Settings tab, configure the parameters. The following table describes the parameters:
Click Save & Test.
Storeview HTTP API
Overview
Simple Log Service provides multiple API operations that you can use to query a Storeview for Metricstore. The API operations are compatible with the open source Prometheus protocol. The API operations provided by Prometheus and Storeview-related API operations provided by Simple Log Service are both stored in the /api/v1 directory. You can use the following URL to call the Storeview-related API operations provided by Simple Log Service: https://{project}.{sls-endpoint}/prometheus/{project}/{storeview}/api/v1/
. For more information, see HTTP API. The following table describes the parameters:
Parameter | Required | Description |
{project} | Yes | The name of the Simple Log Service project. For more information, see Manage a project. |
{sls-endpoint} | Yes | The endpoint of the region in which the Simple Log Service project resides. For more information, see Endpoint. |
{storeview} | Yes | The Storeview that you created. |
API operations for querying time series metrics
API operations for metadata queries
What to do next
Query a Storeview for Metricstore
In the left-side navigation pane, choose Storeview > Storeview for Metricstore. Here you can view the created Storeviews.
Modify a Storeview for Metricstore
In the Storeview list, move the pointer over the Storeview you want, and choose
> Modify.
On the Update Storeview panel, modify the Storeview, and click OK.
Delete a Storeview for Metricstore
In the Storeview list, move the pointer over the Storeview you want, and choose > Delete.
References
Simple Log Service supports the syntax for query and analysis on time series data. For more information, see Query and analysis syntax on metric data.
Simple Log Service provides multiple APIs to query time series metrics or write metric data to metricstores. For more information, see Details of metricstore-related HTTP API.