Connect to LindormTSDB with Prometheus

更新时间:
复制 MD 格式

LindormTSDB provides remote write and remote read APIs to serve as a remote storage backend for Prometheus. It also features a built-in PromQL API for more efficient metric queries.

Procedure

  1. Create a database to store and query your Prometheus metrics. For more information about the syntax, see CREATE DATABASE.

    CREATE DATABASE my_promdb;
  2. Write metrics. Use the standard Prometheus remote write protocol. For more information, see the Prometheus documentation.

    Configure the Prometheus parameters. Use the db parameter to specify the database that you created. To obtain the LindormTSDB HTTP endpoint, see View endpoints.

    remote_write:
      - url: "<LindormTSDB HTTP endpoint>/api/v2/prom_write?db=db_name"

    Example:

    remote_write:
      - url: "http://ld-bp1q343mws8q9****-proxy-tsdb.lindorm.rds.aliyuncs.com:8242/api/v2/prom_write?db=my_promdb"

    If authentication is enabled for LindormTSDB, include the basic_auth section in your configuration:

    remote_write:
      - url: "<LindormTSDB HTTP endpoint>/api/v2/prom_write?db=db_name"
        basic_auth:
          username: <The username for LindormTSDB>
          password: <The password for LindormTSDB>
  3. Query metrics. You can query Prometheus data stored in LindormTSDB in two ways: by using the Prometheus remote read protocol or by using the built-in PromQL API.

    • Prometheus remote read

      If you use a self-managed Prometheus instance, you can use the standard Prometheus remote read API to query LindormTSDB. To obtain the LindormTSDB HTTP endpoint, see View endpoints.

      remote_read:
        - url: "<LindormTSDB HTTP endpoint>/api/v2/prom_read?db=db_name"

      Example:

      remote_read:
        - url: "http://ld-bp1q343mws8q9****-proxy-tsdb.lindorm.rds.aliyuncs.com:8242/api/v2/prom_read?db=my_promdb"

      If authentication is enabled for LindormTSDB, include the basic_auth section in your configuration:

      remote_read:
        - url: "<LindormTSDB HTTP endpoint>/api/v2/prom_read?db=db_name"
          basic_auth :
            username : <The username for LindormTSDB>
            password : <The password for LindormTSDB>
    • Built-in PromQL API

      LindormTSDB has a built-in PromQL API. You can use PromQL to query data directly without deploying a Prometheus service. This method also offers higher query performance than the remote read method.

      For example, if you use a Grafana monitoring dashboard, you can directly configure LindormTSDB as a Prometheus-type data source in Grafana.

      When configuring the Prometheus data source, set Access to Server (default), HTTP Method to POST, Query timeout to 60s, and Scrape interval to 15s.

      Parameter

      Description

      URL

      Enter the LindormTSDB HTTP endpoint.

      custom query parameters

      Specify the database that you created.

      Example: db=my_promdb.

      For more information about the PromQL query API, see the Prometheus documentation. Use the db parameter to specify the Lindorm database.

      http://ld-bp1q343mws8q9****-proxy-tsdb.lindorm.rds.aliyuncs.com:8242/api/v1/query_range?db=my_promdb
      http://ld-bp1q343mws8q9****-proxy-tsdb.lindorm.rds.aliyuncs.com:8242/api/v1/query?db=my_promdb