All Products
Search
Document Center

Simple Log Service:Query across metricstores

Last Updated:Jun 17, 2026

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

  1. Log on to the Simple Log Service console. In the Projects list, click the target project.

  2. In the navigation pane on the left, choose Data View > Time Series Data View. On the StoreView page, click image to create a Storeview for Metricstore.

  3. 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

Note
  • 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

  1. Install and log on to Grafana. In the navigation pane on the left, choose Configuration > Data Sources.

  2. On the Data Sources tab, click Add data source. Then, select Prometheus and click Select.

  3. On the Settings tab, configure the data source.

    Data source parameters

    Parameter

    Description

    Name

    Enter a custom name for the data source. For example, Prometheus-1.

    HTTP

    • URL: The URL for the StoreView in Simple Log Service, in the format https://{project}.{sls-endpoint}/prometheus/{project}/{storeview}. Replace {sls-endpoint} with the endpoint of the region where the project is located. Replace {project} and {storeview} with your project and StoreView names. For example: https://sls-prometheus-test.cn-hangzhou.log.aliyuncs.com/prometheus/sls-prometheus-test/test.

      Note

      To ensure secure data transmission, you must use https.

    • Whitelisted Cookies: Optional. Adds cookies to the allowlist for requests.

    Auth

    Turn on the Basic auth switch.

    Basic Auth Details

    • User: The AccessKey ID of your Alibaba Cloud account.

    • Password: The AccessKey secret of your Alibaba Cloud account.

    We recommend that you use the AccessKey pair of a RAM user with read-only permissions on the specified project. For more information, see Grant read-only permissions on a specified project.

  4. 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

Instant queries

The Instant Queries API queries metric data at a specific point in time.

GET https://{project}.{sls-endpoint}/prometheus/{project}/{storeview}/api/v1/query
POST https://{project}.{sls-endpoint}/prometheus/{project}/{storeview}/api/v1/query

The following table describes the parameters.

Parameter

Required

Description

query

Yes

The Prometheus Query Language (PromQL) statement. For more information, see PromQL syntax.

time

No

The point in time to query. The value is a Unix timestamp that is accurate to the second. The default value is the current time.

timeout

No

The timeout period for a query in seconds.

You can also use formats such as 1s, 2m, 3h, and 4d. For example, `timeout=10s`. For more information, see Time Durations.

lookback_delta

No

Lets you customize the `query.lookback-delta` flag parameter in Prometheus for the current query only. The value must follow the Time Durations format. For example, `lookback_delta=1m`. For more information, see Time Durations. This parameter specifies the maximum lookback period for finding data points during PromQL calculation. The default value in an SLS Metricstore is `3m`.

Range queries

The Range Queries API queries metric data over a specified time range.

GET https://{project}.{sls-endpoint}/prometheus/{project}/{storeview}/api/v1/query_range
POST https://{project}.{sls-endpoint}/prometheus/{project}/{storeview}/api/v1/query_range

The following table describes the parameters.

Variable

Required

Description

query

Yes

The PromQL statement. For more information, see PromQL syntax.

start

No

The start of the time range to query. The value is a Unix timestamp that is accurate to the second.

end

No

The end of the time range to query. The value is a Unix timestamp that is accurate to the second.

step

No

The interval at which queries are performed in seconds.

You can also use formats such as 1s, 2m, 3h, and 4d. For example, `step=2m`. For more information, see Time Durations.

timeout

No

The timeout period for a query in seconds.

You can also use formats such as 1s, 2m, 3h, and 4d. For example, `timeout=10s`. For more information, see Time Durations.

lookback_delta

No

Lets you customize the `query.lookback-delta` flag parameter in Prometheus for the current query only. The value must follow the Time Durations format. For example, `lookback_delta=1m`. For more information, see Time Durations. This parameter specifies the maximum lookback period for finding data points during PromQL calculation. The default value in an SLS Metricstore is `3m`.

For configuration examples, see Metric query APIs.

Metadata query APIs

Query series

The Query Series API returns all time series and labels that match a set of label selectors within a specified time range.

GET https://{project}.{sls-endpoint}/prometheus/{project}/{storeview}/api/v1/series
POST https://{project}.{sls-endpoint}/prometheus/{project}/{storeview}/api/v1/series

The following table describes the parameters.

Variable

Required

Description

match[]

Yes

The filter condition. For example, `match[]=up{instance="demo.*"}`.

You can set one or more values.

start

No

The start of the time range to query. The value is a Unix timestamp that is accurate to the second.

The default value is 5 minutes before the current time.

end

No

The end of the time range to query. The value is a Unix timestamp that is accurate to the second.

The default value is the current time.

Important

If you specify custom values for the start and end parameters, this API can query data only from the 5-minute interval before the end time, which is the (end - 5 minutes, end) interval.

x-sls-disable-range-limit

No

If set to `true`, this parameter removes the 5-minute query limit. The query then uses the provided `start` and `end` times.

forceMaxMetaTimeRangeSeconds

No

The unit of this parameter is seconds. It limits the maximum query range. If (end - start) > `forceMaxMetaTimeRangeSeconds`, the query range is adjusted to (end - `forceMaxMetaTimeRangeSeconds`, end).

For query efficiency, include this parameter by default.

Query label names

Queries all label names that meet the specified conditions within a time range.

GET https://{project}.{sls-endpoint}/prometheus/{project}/{storeview}/api/v1/labels
POST https://{project}.{sls-endpoint}/prometheus/{project}/{storeview}/api/v1/labels

The following table describes the parameters.

Parameter

Required

Description

match[]

Yes

The filter condition. For example, `match[]=up{instance="demo.*"}`.

You can set zero, one, or more values.

start

No

The start of the time range to query. The value is a Unix timestamp that is accurate to the second.

The default value is 5 minutes before the current time.

end

No

The end of the time range to query. The value is a Unix timestamp that is accurate to the second.

The default value is the current time.

Important

If you specify custom values for the start and end parameters, this API can query data only from the 5-minute interval before the end time, which is the (end - 5 minutes, end) interval.

x-sls-disable-range-limit

No

If set to `true`, this parameter removes the 5-minute query limit. The query then uses the provided `start` and `end` times.

forceMaxMetaTimeRangeSeconds

No

The unit of this parameter is seconds. It limits the maximum query range. If (end - start) > `forceMaxMetaTimeRangeSeconds`, the query range is adjusted to (end - `forceMaxMetaTimeRangeSeconds`, end).

For query efficiency, include this parameter by default.

Query label values

The Query Label Values API returns all values for a specific label that match the specified selectors within a time range.

Important

You must replace <label_name> in the API URL with a specific label name.

GET https://{project}.{sls-endpoint}/prometheus/{project}/{storeview}/api/v1/label/<label_name>/values

The following table describes the parameters.

Parameter

Required

Description

match[]

Yes

The filter condition. For example, `match[]=up{instance="demo.*"}`.

You can set one or more values.

start

No

The start of the time range to query. The value is a Unix timestamp that is accurate to the second.

The default value is 5 minutes before the current time.

end

No

The end of the time range to query. The value is a Unix timestamp that is accurate to the second.

The default value is the current time.

Important

If you specify custom values for the start and end parameters, this API can query data only from the 5-minute interval before the end time, which is the (end - 5 minutes, end) interval.

x-sls-disable-range-limit

No

If set to `true`, this parameter removes the 5-minute query limit. The query then uses the provided `start` and `end` times.

forceMaxMetaTimeRangeSeconds

No

The unit of this parameter is seconds. It limits the maximum query range. If (end - start) > `forceMaxMetaTimeRangeSeconds`, the query range is adjusted to (end - `forceMaxMetaTimeRangeSeconds`, end).

For query efficiency, include this parameter by default.

For configuration examples, see Metadata query APIs.

Next steps

Query a StoreView

In the navigation pane on the left, choose Data View > Time Series Data View to view your created StoreViews.

Update a StoreView

  1. In the StoreView list, hover over the target StoreView, click the image icon, then click Modify.

  2. 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 image icon, then click Delete.

Related documentation