All Products
Search
Document Center

Simple Log Service:Query logs across metricstores

Last Updated:Jul 08, 2025

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

  1. Log on to the Simple Log Service console. In the Projects section, click the project that you want to manage.

  2. In the left-side navigation pane, choose Storeview > Storeview for Metricstore. On the page that appears, click the image icon to create a Storeview for Metricstore.

    image

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

    Important
    • A Storeview must contain a Metricstore from the same project.

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

    image

2. Use a PromQL statement to query a Storeview

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

image

Connect a Storeview for Metricstore to Grafana

  1. Install and log on to Grafana. For more information, see Install Grafana. In the left-side navigation pane, choose Configuration > Data Sources.

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

  3. On the Settings tab, configure the parameters. The following table describes the parameters:

    image

    Parameters

    Parameter

    Description

    Name

    Specify a name for the data source based on your business requirements. Example: Prometheus-1.

    HTTP

    • URL: Enter the URL of the Storeview in the https://{project}.{sls-endpoint}/prometheus/{project}/{storeview} format. Replace the {sls-enpoint} parameter with the endpoint of the region in which the Simple Log Service project resides. Replace the {project} and {storeview} parameters with the project name and the Storeview name based on your business requirements. For more information, see Endpoints. Example: https://sls-prometheus-test.cn-hangzhou.log.aliyuncs.com/prometheus/sls-prometheus-test/test.

      Note

      To ensure transmission security, you must use https.

    • Whitelisted Cookies: Add a whitelist. This parameter is optional.

    Auth

    Turn on Basic auth.

    Basic Auth Details

    • User: Enter the AccessKey ID of your Alibaba Cloud account.

    • Password: Enter the AccessKey secret that corresponds to the AccessKey ID.

    We recommend that you use the AccessKey pair of a Resource Access Management (RAM) user who has only the read-only permission on the Simple Log Service project. For more information, see The read-only permission on projects.

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

Instant Queries API

The Instant Queries API operation is used to query metrics 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:

Variable

Required

Description

query

Yes

The 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. Unit: seconds.

You can specify the timeout period in the 1s, 2m, 3h, or 4d format. The value 1s indicates 1 second, the value 2m indicates 2 minutes, the value 3h indicates 3 hours, and the value 4d indicates 4 days. Example: timeout=10s. For more information, see Time Durations.

lookback_delta

No

The maximum lookback period when you call the API operation to identify metrics during PromQL calculation. The default value of 3m is used in Simple Log Service Metricstores. You can use this variable to specify a custom value for the query.lookback-delta flag parameter. The value is valid only for the current query. The value must follow the format for time durations. Example: lookback_delta=1m. For more information, see Time Durations.

Range Queries API

The Range Queries API operation is used to query metrics at multiple points in time within a specific 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 beginning 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. Unit: seconds.

You can specify the timeout period in the 1s, 2m, 3h, or 4d format. The value 1s indicates 1 second, the value 2m indicates 2 minutes, the value 3h indicates 3 hours, and the value 4d indicates 4 days. Example: step=2m. For more information, see Time Durations.

timeout

No

The timeout period for a query. Unit: seconds.

You can specify the timeout period in the 1s, 2m, 3h, or 4d format. The value 1s indicates 1 second, the value 2m indicates 2 minutes, the value 3h indicates 3 hours, and the value 4d indicates 4 days. Example: timeout=10s. For more information, see Time Durations.

lookback_delta

No

The maximum lookback period when you call the API operation to identify metrics during PromQL calculation. The default value of 3m is used in Simple Log Service Metricstores. You can use this variable to specify a custom value for the query.lookback-delta flag parameter. The value is valid only for the current query. The value must follow the format for time durations. Example: lookback_delta=1m. For more information, see Time Durations.

For more information, see API operations for metric queries.

API operations for metadata queries

Query Series API

The Query Series API operation is used to query all Storeviews that meet specific conditions within a specific period of time and the label-based numeric pairs of the Storeviews.

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. Example: match[]=up{instance="demo.*"}.

You can specify one or more conditions.

start

No

The beginning 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 values for the start and end variables, you can call this operation to query only the data that is generated within 5 minutes before the time specified by the end variable.

Query Label Names API

The Query Label Names API operation is used to query all label names that meet specific conditions within a specific period of time.

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:

Variable

Required

Description

match[]

Yes

The filter condition. Example: match[]=up{instance="demo.*"}.

You can specify one or more conditions. You can also leave the variable empty.

start

No

The beginning 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 values for the start and end variables, you can call this operation to query only the data that is generated within 5 minutes before the time specified by the end variable.

Query Label Values API

The Query Label Values API operation is used to query all label values for specific label names that meet specific conditions within a specific period of time.

Important

Replace the <label_name> parameter in the URL of the Query Label Values API operation with the required label name.

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

The following table describes the parameters:

Variable

Required

Description

match[]

Yes

The filter condition. Example: match[]=up{instance="demo.*"}.

You can specify one or more conditions.

start

No

The beginning 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 values for the start and end variables, you can call this operation to query only the data that is generated within 5 minutes before the time specified by the end variable.

For more information, see 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.

image

Modify a Storeview for Metricstore

  1. In the Storeview list, move the pointer over the Storeview you want, and choose image > Modify.

    image

  2. On the Update Storeview panel, modify the Storeview, and click OK.

    image

Delete a Storeview for Metricstore

In the Storeview list, move the pointer over the Storeview you want, and choose image > Delete.

image

References