What is Prometheus

Prometheus is an open source system monitoring and alert kit originally built on SoundCloud. It’s a time series database. Time series data: a continuous set of data stored in the time dimension in the same sequence (same name and label). Note: Adding, deleting, or modifying labels on the same metric name will result in a new time series. If we configure a series of alerts for the time series, the alerts depend on the indicator’s label to judge. If the label is changed or added, the alert becomes invalid.

Features of Prometheus

  1. Multidimensional data model
  2. Flexible query language PromQL
  3. Does not rely on distributed storage; A single server node is autonomous
  4. Time series collection is done through a pull model over HTTP
  5. Support for pushing time series through intermediate gateways
  6. Discover targets through service discovery or static configuration
  7. Multiple graphics and dashboard modes are supported

3. Supported indicator types

1, Counter Counter

Used to hold monotonically increasing values, can only be positive, cannot be negative, cannot be reduced, but can be reset to 0. For example, the number of accesses to an HTTP request.

2, Gauge panel

Used to hold fluctuating values, which can be increased or reduced. For example, memory usage

3) as is shown in the Histogram

The histogram samples observed values (typically things like request duration or response size) and counts them in a configurable bucket. It also provides the sum of all observations.

4, Summary

Like a histogram, a summary samples observations (typically things like request duration and response size). Although it also provides the total number of observations and the sum of all observations, it calculates configurable quantiles in a sliding time window

4. Single-node deployment of Prometheus

1, download

Prometheus Download address

2. After downloading, decompress and rename the folder

1, folder content

├── Console_libraries │ ├── menu. Lib │ ├─ PROM. ├─ Consoles │ ├── Example │ ├── node-cpu. HTML │ ├── node-disk.html │ ├─ node.overview. HTML │ ├─ Node.html │ ├─ Node.html Prometheus -overview. HTML │ ├── Prometheus. HTML ├── PrometheusCopy the code

2. Prometheus is the startup file. By default, the startup will load the Prometheus. 3. Prometheus. Yml is the configuration file

3, start Prometheus

1. Display all command-line parameters supported by the Prometheus command

./prometheus -h
Copy the code

2. Specify the run configuration file

./prometheus --config.file="prometheus.yml"
Copy the code

3. Modify the running port

. / Prometheus - web. Listen - address = "0.0.0.0:9080"Copy the code

Note:If you change the default9090Port, you need to change itprometheus.ymlMonitors its own port by default.

4. Change the data store directory and data retention time

./prometheus --storage.tsdb.path="data/" --storage.tsdb.retention.time="15d" 
Copy the code

5. View the version number

./prometheus --version
Copy the code

6. Verify that the configuration file is correct

./promtool check config prometheus.yml
Copy the code

Start command:

/ Users/huan/soft/Prometheus/Prometheus - 2.25.0 / Prometheus \ -- config. The file ="/ Users/huan/soft/Prometheus/Prometheus - 2.25.0 / Prometheus. Yml" \
--web.listen-address="0.0.0.0:9080" \
--storage.tsdb.retention.time="15d" \
&
Copy the code

5. Startup interface

1. Access the indicator data

http://localhost:9080/metrics
Copy the code

2. Access the graphical interface (Expression Browser)

http://localhost:9080/graph
Copy the code

Vi. Configure node_exporter to monitor the system host

1. Download and unzip it

Wget # https://github.com/prometheus/node_exporter/releases/download/v1.1.1/node_exporter-1.1.1.darwin-amd64.tar.gz
# tar - ZXVF node_exporter - 1.1.1. Darwin - amd64. Tar. Gz
# mv node_exporter - 1.1.1. Darwin - amd64 node_exporter - 1.1.1
Copy the code

2. Start node_exporter

./node_exporter --web.listen-address=": 9081"
Copy the code

1. Run the –help command to view the available command line configuration items. 2

3. Access metrics data

http://localhost:9081/metrics
Copy the code

4. Integrated into Prometheus

Modify Prometheus. Yml file, add:

scrape_configs:
- job_name: 'node-exporter'
  static_configs:
  - targets: ['localhost:9081']
Copy the code

5. Check whether node_exporter is successfully integrated

Vii. Reference documents

  1. Prometheus. IO/docs/concep…
  2. prometheus.io/download/