Prometheus overview and deployment integration services

1. Prometheus Overview

Prometheus is a combination of open source monitoring, alarming and time series databases. Suitable for monitoring Docker containers. Because the popularity of Kubernetes has driven the development of Prometheus,
official website: https://prometheus.io/

2. Time series data

1. What is sequence data?

Time Series Data: Data that records changes in system and equipment status in chronological order is called time series data.
There are many application scenarios: such as

  • The longitude, latitude, speed, direction, distance to the side, etc. that need to be recorded during the operation of the driverless vehicle.
  • Driving trajectory data of each vehicle in a certain area
  • Real-time transaction data of traditional securities industry
  • Real-time operation and maintenance monitoring data, etc.

2. Characteristics of time series data

  • Good performance:
    Relational databases have poor performance for processing large-scale data. NoSQL can handle large-scale data better, but it is still not as good as time series databases.
  • Low storage cost and
    efficient compression algorithm, saving storage space and effectively reducing IO

3.Main features of Prometheus

  • Multidimensional data model
  • flexible query language
  • Does not rely on distributed storage, individual server nodes are autonomous
  • Use HTTP to pull time series data through the Pull model
  • Push models can also be supported through intermediate gateways
  • Discover target service objects through service discovery or static configuration
  • Supports a variety of icons and interface displays

4. Prometheus principle architecture diagram

Service deployment steps (based on docker environment, deploy and monitor local containers and cross-local monitoring container resources)

Requires two virtual machines

The first

root@ubuntu20:~# docker pull google/cadvisor

Run container

root@ubuntu20:~# docker run \

> --volume=/var/run:/var/run:ro \

> --volume=/sys:/sys:ro \

> --volume=/var/lib/docker/:/var/lib/docker:ro \

> --volume=/dev/disk/:/dev/disk:ro \

> --publish=8080:8080 \

> --detach=true \

> --name=cadvisor \

> --privileged \

> --device=/dev/kmsg \

> google/cadvisor

 View port status

 Browser access

 Come to the second channel

root@ubuntu20:~# docker run --volume=/:/rootfs:ro --volume=/var/run:/var/run:ro --volume=/sys/:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --volume=/dev/disk/:/dev/disk:ro --publish=8080:8080 --detach=true --name=cadvisor --privileged --device=/dev/kmsg google/cadvisor

Download image

Operations that must be performed on both hosts

root@ubuntu20:~# docker pull prom/node-exporter

The first:

Download image

root@ubuntu20:~# docker pull prom/Prometheus

root@ubuntu20:~# docker pull grafana/grafana

 root@ubuntu20:~# docker run -d -p 9100:9100 --volume /proc/:/host/proc --volume /sys:/host/sys --volume /:/roofs --name node-exporter prom/node-exporter --path.procfs /host/proc --path.sysfs /host/sys --collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($$|/)"

View port status 

 Second station:

Perform the same

docker run -d -p 9100:9100 --volume /proc/:/host/proc --volume /sys:/host/sys --volume /:/roofs --name node-exporter prom/node-exporter --path.procfs /host/proc --path.sysfs /host/sys --collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($$|/)"

 

 View port

 The first

root@ubuntu20:~# vim prometheus.yml

Add to:

global:

  scrape_interval:     15s # By default, scrape targets every 15 seconds.

  # Attach these labels to any time series or alerts when communicating with  # external systems (federation, remote storage, Alertmanager).

  external_labels:

    monitor: 'codelab-monitor'

# 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'

    static_configs:

            - targets: ['192.168.0.143:9090','192.168.0.143:9100','192.168.0.143:8080','192.168.0.141:8080','192.168.0.141:9100']

run

root@ubuntu20:~# docker run -d -p 9090:9090 --volume /root/prometheus.yml:/etc/prometheus/prometheus.yml --name prometheus prom/Prometheus

 View port

Browser access

http://192.168.0.143:9090/

 

 

 Build successful

Next we continue to deploy the graphical page (deployed on the first server)

root@ubuntu20:~# docker run -d -p 3000:3000 -e "GF_SECURITY_ADMIN_PASSWORD=123456" grafana/grafana

 Check the port status

 

Default account: admin   

The password is: 123456

 

Click on the first prometheus to configure it

 

 

Save at the bottom

 Then go to the grafana official website to download the monitoring dial json file

​​​​​​Dashboards | Grafana Labs

 

Search dashboards

 

 

 

Download json file to local

Go back to prometheus and search for import, configure and add the json file

 

 

 

ok 

Guess you like

Origin blog.csdn.net/weixin_53053517/article/details/132407447