Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Prometheus Monitoring docker

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Prometheus is an open source system monitoring and alerting toolkit. Docker can be configured as a Prometheus target. Currently, you can only monitor the Docker itself. You cannot use the Docker target monitoring application at this time.

Steps for monitoring docker:

1. Use docker's metrics-address to expose the monitoring port to Prometheus:

Modify the daemon.json file of docker

{"metrics-addr": "192.168.191.18 ip 9323", the configuration on # docker official website is 127.0.0.1 Prometheus can not connect to the ip, manual execution of docker-L 127.0.1 curl 9323 can display docker monitoring indicators, probably due to isolation between containers. "experimental": true}

After that, the container docker service: systemctl restart docker

two。 Edit Prometheus.yml

# my global configglobal: 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). # Attach these labels to any time series or alerts when communicating with # external systems (federation, remote storage, Alertmanager). External_labels: monitor: 'codelab-monitor'# Load rules once and periodically evaluate them according to the global' evaluation_interval'.rule_files: #-"first.rules" #-"second.rules" # 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= `to any timeseries scraped from this config. -job_name: 'prometheus' # metrics_path defaults to' / metrics' # scheme defaults to 'http'. Static_configs:-targets: ['localhost:9090']-job_name:' docker' # metrics_path defaults to'/ metrics' # scheme defaults to 'http'. Static_configs:-targets: ['192.168.191.18purl 9323']

3. Start a container for Prometheus

When the docker environment is used, the swarm cluster mode is used to create services in a different way. Swarm cluster deployment can operate on its own

[root@docker] # docker service create-- replicas 1-- name my-prometheus-- mount type=bind,source=/root/prometheus.yml,destination=/etc/prometheus/prometheus.yml-- publish published=9090,target=9090,protocol=tcp prom/prometheusrgkmwhwqepl1qivlpq8r3nt2noverall progress: 1 out of 1 tasks 1Accord 1: running [= = >] verify: Service converged

View the created service information

[root@docker ~] # docker service ls ID NAME MODE REPLICAS IMAGE PORTSrgkmwhwqepl1 my-prometheus replicated 1amp 1 prom/prometheus:latest *: 9090-> 9090/tcp

View the details of the service

[root@docker ~] # docker service ps my-prometheusID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTSy8akc5dmwjrn my-prometheus.1 prom/prometheus:latest docker Running Running 16 minutes ago

4. Visit the page of Prometheus to view the monitoring values

View of monitoring items

The basic content of prometheus monitoring docker has been deployed and verified. The configuration experiment of Prometheus monitoring docker on docke official website reports an error when viewing Prometheus monitoring target: dial tcp xxxx: connect: connection refused.

Docker official website https://docs.docker.com/config/thirdparty/prometheus/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report