All Products
Search
Document Center

Time Series Database:Quick Start

Last Updated:Mar 31, 2023

Step 1 Purchase (upgrade) TSDB instance

  • If you have not purchased a TSDB instance before.

  • If the existing instance purchased before April 15, 2019, the TSDB instance upgrade can be performed through the Alibaba Cloud Single System Work Order;

Step 2 Configure the TSDB instance.

  • Obtain the public IP address of the machine where Prometheus is to be installed;

  • Network accessVPC network is open

    • If Promethues is deployed on Alibaba Cloud ECS and no VPC network is configured, then the promethues ECS can be added to the VPC network where the TSDB is located.

      • If Promethues is deployed in a non-Alibaba Cloud environment, you need to enable the TSDB public network to be able to communicate with the TSDB on the cloud. In order to ensure instance access security, you need to configure the TSDB instance to access the whitelist. Apply for the public network address of the TSDB instance and fill in the public IP address of the application environment in the network whitelist.

    • Entry for applying for a public network address in the TSDB instance management interface

      TSDB instance detail
      • Network whitelist configuration interfaceTSDB网络白名单

  • After the TSDB public network address is applied, confirm that the public network domain name can be connected to the TSDB instance from the application environment. The TSDB instance domain name and port will be displayed in the following locations after the public network address is successfully applied:TSDB公共域名

  • Confirm that the machine where Prometheus is located can access the TSDB instance normally. Use http to access the address of the TSDB instance. If you can get the string containing “Welcome to use the TSDB”, it means that the machine where Prometheus is located can access the TSDB instance normally. Set the public network address of the TSDB instance as: ts-xxxxxxxxxxxx.hitsdb.rds.aliyuncs.com:3242 . Here, take the Linux system as an example, execute the command curl ts-xxxxxxxxxxxx.hitsdb.rds.aliyuncs.com:3242, if the network is connected , you can get the following results.

TSDB_Prometheus_network

Step 3 Install Prometheus

Prometheus is implemented in Golang and is therefore natively portable (supports Linux, Windows, macOS, and Freebsd). It is deployed directly from pre-compiled binaries, out of the box.

Prometheus binary installation packages for different operating systems can be downloaded from Prometheus’ GitHub repository. Here, the installation of the Liunx system is taken as an example. The specific steps are as follows.

Prometheus installation

wget https://github.com/prometheus/prometheus/releases/download/v2.3.0/prometheus-2.3.0.linux-amd64.tar.gz
tar -zxvf prometheus-2.3.0.linux-amd64.tar.gz
mv prometheus-2.3.0.linux-amd64 /usr/local/prometheus

Verify installation

cd /usr/local/prometheus/
./prometheus --version

If the following message appears, the installation is successful.

prometheus, version 2.3.0 (branch: HEAD, revision: 290d71791a507a5057b9a099c9d48703d86dc941)
  build user:       root@d539e167976a
  build date:       20180607-08:46:54
  go version:       go1.10.2

Step 4 Prometheus configuration

Modify the Prometheus configuration

Assuming the public network address of the TSDB instance is: ts-xxxxxxxxxxxx.hitsdb.rds.aliyuncs.com:3242 , add the following content to prometheus.yaml.

# Remote write configuration (TSDB).
remote_write:
  - url: "http://ts-xxxxxxxxxxxx.hitsdb.rds.aliyuncs.com:3242/api/prom_write"

# Remote read configuration (TSDB).
remote_read:
  - url: "http://ts-xxxxxxxxxxxx.hitsdb.rds.aliyuncs.com:3242/api/prom_read"
    read_recent: true

In the above configuration, ‘read_recent: true’ means that the recent data should also be read remotely, because Prometheus’ recent data is read locally, anyway. If this flag is turned on, Prometheus will Merge the local and remote data. Turning on this flag makes it easy to verify that the remote TSDB is working properly. If it is officially in production, you can remove ‘read_recent: true’ according to the actual situation, which can improve the query performance of Prometheus. The complete sample configuration for Prometheus is shown below.

# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']
# Remote write configuration (TSDB).
remote_write:
  - url: "http://ts-xxxxxxxxxxxx.hitsdb.rds.aliyuncs.com:3242/api/prom_write"

# Remote read configuration (TSDB).
remote_read:
  - url: "http://ts-xxxxxxxxxxxx.hitsdb.rds.aliyuncs.com:3242/api/prom_read"
    read_recent: true

Note that the configuration here is only for quick start. For different TSDB instances, we provide Prometheus write configuration best practices for implementing Prometheus to smoothly send monitoring sample data to TSDB. Please refer to TSDB for Prometheus The contents of the Prometheus Remote Write configuration in the Best Practices chapter.

Start Prometheus

./promtheus

If the following message appears, it means the startup is successful.

level=info ts=2019-04-15T10:39:12.870828882Z caller=main.go:222 msg="Starting Prometheus" version="(version=2.3.0, branch=HEAD, revision=290d71791a507a5057b9a099c9d48703d86dc941)"
level=info ts=2019-04-15T10:39:12.870926993Z caller=main.go:223 build_context="(go=go1.10.2, user=root@d539e167976a, date=20180607-08:46:54)"
level=info ts=2019-04-15T10:39:12.870971602Z caller=main.go:224 host_details="(Linux 4.9.93-010.ali3000.alios7.x86_64 #1 SMP Fri Apr 20 00:18:51 CST 2018 x86_64 common-dev100081116006.eu95sqa (none))"
level=info ts=2019-04-15T10:39:12.871010623Z caller=main.go:225 fd_limits="(soft=655350, hard=655350)"
level=info ts=2019-04-15T10:39:12.872103134Z caller=main.go:514 msg="Starting TSDB ..."
level=info ts=2019-04-15T10:39:12.87214458Z caller=web.go:426 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2019-04-15T10:39:12.877363461Z caller=main.go:524 msg="TSDB started"
level=info ts=2019-04-15T10:39:12.877417508Z caller=main.go:603 msg="Loading configuration file" filename=prometheus.yml
level=info ts=2019-04-15T10:39:12.879382462Z caller=main.go:500 msg="Server is ready to receive web requests."

Write and read verification

Write verification

You can easily check whether the written TPS changes by using the “Instance Monitoring” interface of the TSDB instance’s management console interface. Generally, when there is no data written at the beginning, the written TPS is 0; if TPS starts to change from 0 to a positive number, it indicates that Prometheus has reported the data to the TSDB, as shown in the following figure.

prometheus_write_validate

Query verification

In this example, the Prometheus monitoring indicator collection target in Prometheus is Promethes itself. Therefore, Prometheus collects its own monitoring indicator ‘go_memstats_gc_cpu_fraction’ as an example for query authentication. The result is shown in the figure below. prometheus_read_validate