All Products
Search
Document Center

Lindorm:Use Prometheus to connect to and use LindormTSDB

Last Updated:Dec 27, 2024

The Lindorm time series engine (LindormTSDB) provides APIs for the remote write and remote read features of Prometheus. You can use these APIs to connect LindormTSDB to Prometheus and specify LindormTSDB as the remote storage of Prometheus. You can also use PromQL to call the APIs to efficiently access data in LindormTSDB.

Procedure

  1. Create a database. The database is used to store and query data in Prometheus. The following statement provides an example on how to create a database. For more information about the syntax used to create a database, see CREATE DATABASE.

    CREATE DATABASE my_promdb;
  2. Write data to the database by using the standard Prometheus remote write protocol. For more information, see Prometheus official documentation.

    Configure parameters related to Prometheus in the format shown in the following example. Set the db parameter to the name of the database that is created in Step 1. For more information about how to obtain the LindormTSDB endpoint for HTTP, see View endpoints.

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

    The following example shows how to configure the parameters in the URL.

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

    The following example shows how to configure the parameters in the URL when authentication is enabled for the Lindorm time series engine.

    remote_write:
      - url: "<LindormTSDB endpoint for HTTP>/api/v2/prom_read?db=db_name"
        basic_auth:
          username: <Username used to connect to LindormTSDB>
          password: <Password used to connect to LindormTSDB> 
  3. Query data that is written to the database from Prometheus. You can use the remote data reading APIs of Prometheus or the built-in PromQL APIs of Lindorm to query data.

    • Use the remote data reading APIs of Prometheus to read data.

      If your Lindorm database is connected to a self-managed Prometheus service, you can use the standard remote data reading APIs of Prometheus in the format shown in the following example to read data from the database. For more information about how to obtain the LindormTSDB endpoint for HTTP, see View endpoints.

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

      The following example shows how to configure the parameters in the URL.

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

      The following example shows how to configure the parameters in the URL when authentication is enabled for the Lindorm time series engine.

      remote_read:
        - url: "<LindormTSDB endpoint for HTTP>/api/v2/prom_read?db=db_name"
          basic_auth :
            username: <Username used to connect to LindormTSDB>
            password: <Password used to connect to LindormTSDB> 
    • Use the built-in PromQL APIs of Lindorm to read data.

      Lindorm provides built-in PromQL APIs that allow you to use PromQL to query data without the need to deploy additional Prometheus services. The query performance is higher than that when you use the remote data reading APIs of Prometheus.

      For example, if you use Grafana to monitor data, you can specify Lindorm as the data source of Prometheus. The following figure shows the parameters that you can configure in Grafana.

      image

      Parameter

      Description

      URL

      Specify the LindormTSDB endpoint for HTTP.

      Custom query parameters

      Specify the database that is created in Step 1.

      Example: db=my_promdb.

      For more information about how to use PromQL APIs to query data, see Prometheus official documentation. Set the db parameter to the name of the database that is created in Step 1. The following URLs provide examples on how to use PromQL APIs to query data.

      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