A StoreView for Metricstore allows you to query data across multiple metricstores. You can query data in a StoreView by using PromQL, connect a StoreView to Grafana, and retrieve StoreView information by using the API.
Prerequisites
A project and a metricstore have been created. For more information, see Manage projects and Manage a metricstore.
Create a StoreView and associate metricstores
1. Create a Storeview for Metricstore
-
Log on to the Simple Log Service console. In the Projects list, click the target project.
-
In the navigation pane on the left, choose . On the StoreView page, click
to create a Storeview for Metricstore. -
In the Create StoreView panel, enter a Storeview Name, add the associated metricstores, then click OK.
Important-
A Storeview for Metricstore must contain a metricstore from the same project.
-
A StoreView for Metricstore supports queries and analysis across multiple metricstores. To ensure accurate results, follow these recommendations:
-
Do not associate metricstores that have overlapping time series with the same StoreView.
-
Do not associate multiple large-scale metricstores for computation. For example, avoid associating metricstores where the shard count is greater than 64.
-
Set Storeview Type to Metric.
-
2. Query a StoreView with PromQL
-
After you associate multiple metricstores with a StoreView, query and analysis results are aggregated from all associated metricstores.
-
A StoreView for Metricstore does not support SQL or predefined processing. Enter a PromQL statement directly in the query editor. The backend engine automatically performs computations across all associated metricstores.
In the dataset panel on the left, select the test dataset. In the query editor, enter the PromQL statement cpu_count{}, and then click Run in the upper-right corner. The line chart for the metric appears in the results area.
Connect a StoreView to Grafana
-
Install and log on to Grafana. In the navigation pane on the left, choose .
-
On the Data Sources tab, click Add data source. Then, select Prometheus and click Select.
-
On the Settings tab, configure the data source.
-
Click Save & Test.
StoreView HTTP API
Overview
Simple Log Service provides multiple APIs for querying a StoreView for Metricstore. These APIs are compatible with the open-source Prometheus protocol and follow the same /api/v1 directory convention. The complete URL is https://{project}.{sls-endpoint}/prometheus/{project}/{storeview}/api/v1/.
|
Parameter |
Required |
Description |
|
{project} |
Yes |
The name of the Simple Log Service project. For more information, see Manage projects. |
|
{sls-endpoint} |
Yes |
The endpoint of the region where the project is located. |
|
{storeview} |
Yes |
The name of the StoreView. |
Metric query APIs
Metadata query APIs
Next steps
Query a StoreView
In the navigation pane on the left, choose to view your created StoreViews.
Update a StoreView
-
In the StoreView list, hover over the target StoreView, click the
icon, then click Modify. -
In the Modify StoreView panel, you can modify the associated metricstores, then click OK.
Each store includes a project and metricstore drop-down list. You can click + STORE to associate more metricstores.
Delete a StoreView
In the StoreView list, hover over the target StoreView, click the
icon, then click Delete.
Related documentation
-
For the query and analysis syntax for time-series data, see Query and analysis syntax for time-series data.
-
Simple Log Service provides APIs for querying time-series metrics and writing metric data to a metricstore. For more information, see Metricstore HTTP API reference.