Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Example Analysis of docker-compose Database Monitoring

Shulou Source: shulou.com Published: 2022-06-01 14:20:58 09月24日 Update

This article introduces the relevant knowledge of "docker-compose database monitoring example analysis". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Operation and maintenance monitoring

Monitoring object:

Docker

Redis

Mysql

Nginx

Data acquisition:

Prometheus

Cadvisor

Node-exporter:

Redis-exporter

Mysql-exporter:

Report:

Grafana

Nginx monitoring needs to compile vfs module, note trouble! It is recommended that ELK use filebeat to collect logs directly and kibana to produce reports.

Docker-compose.ymlversion: '2'services: # db server redis: build: redis/ container_name: redis restart: unless-stopped volumes:-~ / docker/redis/data:/data-~ / docker/redis/conf/master/redis.conf:/etc/redis/redis.conf ports:-"6379 build: mysql/ # container_name: mysql # restart: unless- Stopped # volumes: # #-~ / docker/mysql/data:/var/lib/mysql #-~ / docker/mysql/data:/var/lib/mysql #-~ / github/docker_db/mysql/conf.d:/etc/mysql/conf.d # ports: #-"3306 docker/mysql/data:/var/lib/mysql 3306" # environment: # MYSQL_ROOT_PASSWORD: "mysecretpassword" # exporter cadvisor: image: Google/cadvisor:latest container_name: cadvisor restart: unless-stopped ports:-'8080 volumes:-/: / rootfs:ro-/ var/run:/var/run:rw-/ sys:/sys:ro-/ var/lib/docker/:/var/lib/docker:ro node-exporter: image: prom/node-exporter:latest container_name: node-exporter restart: Unless-stopped ports:-'9100 path.procfs=/host/proc' -'-- path.sysfs=/host/sys' -'- collector.filesystem.ignored-mount-points= ^ / (sys | proc | dev | host | etc) ($$| /)'--collector.textfile.directory=/node_exporter/prom' volumes:-/: /: / rootfs:ro-/ proc : / host/proc:ro-/ sys:/host/sys:ro-~ / docker/prometheus_exporter/prom:/node_exporter/prom # mysql exporter # mysql-exporter: # image: prom/mysqld-exporter # container_name: mysql-exporter # hostname: mysql-exporter # user:'0' # restart: always # ports: #-"9104 mysql exporter" # environment: # # DATA_SOURCE_NAME: "root:yunjingtest@ (localhost:3306)" # DATA_SOURCE_NAME: "root:mysecretpassword@ (mysql:23306)" # depends_on: #-mysql # redis exporter redis-exporter: image: oliver006/redis_exporter container_name: redis-exporter hostname: redis-exporter restart: always ports:-"9121 command: -"-- redis.addr=redis : / / redis:6379 "depends_on:-redis prometheus: image: prom/prometheus:latest container_name: prometheus restart: unless-stopped ports:-'9090 image 9090' # user:'0' command:-- config.file=/etc/prometheus/prometheus.yml' -'--storage.tsdb.path=/prometheus/data' -'--storage.tsdb.retention=90d' -'--web.enable-lifecycle' volumes: -. / prometheus/conf/prometheus.yml:/etc/prometheus/prometheus.yml-~ / docker/prometheus/data:/prometheus/data depends_on:-cadvisor-node-exporter grafana: image: grafana/grafana:latest container_name: grafana restart: unless-stopped ports:-'3000 cadvisor 3000' depends_on:-prometheus Volumes:-~ / docker/grafana:/var/lib/grafana environment:-HTTP_USER=admin-HTTP_PASS=yunjingtest #-GF_SECURITY_ADMIN_PASSWORD=yunjingtest #-GF_USERS_ALLOW_SIGN_UP=falsenetworks: db: driver: bridge

Run:

➜docker_db git: (master) docker-compose up-dCreating redis. DoneCreating cadvisor... DoneCreating node-exporter... DoneCreating redis-exporter... DoneCreating prometheus... DoneCreating grafana... Done ➜docker_db git: (master) docker-compose ps Name Command State Ports -- cadvisor / usr/bin/cadvisor-logtostderr Up 0.0.0.0 logtostderr Up 8080-> 8080/tcpgrafana / run.sh Up 0.0.0.0 run.sh Up 3000-> 3000/tcpnode-exporter / bin/node_exporter-- path. ... Up 0.0.0.0 bin/prometheus 9100-> 9100/tcpprometheus / bin/prometheus-- config.f. Up 0.0.0.0 usr/ 90-> 9090/tcpredis docker-entrypoint.sh / 90. Up 0.0.0.0 redis_exporter 6379-> 6379/tcpredis-exporter / redis_exporter-- redis.ad. Up 0.0.0.0 9121/tcp 9121-> 9121/tcp docker_db git: (master) web interface view 1.prometheus interface view job_name

Http://localhost:9090/targets

2.grafana to view specific reports

Redis status report

Prometheus status report dashborad finds the template id on the official website of granfa

Prometheus reids

Official report template

Monitoring indicator template id:8919

Cpu

Memory

Magnetic disk

System call

Network io...

Cpu/ memory:

System load / disk / Network io

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). # Alertmanager configurationalerting: 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= `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:' node-exporter' scrape_interval: 5s static_configs:-targets: ['node-exporter:9100']-job_name:' cadvisor' scrape_interval: 5s static_configs:-targets: ['cadvisor:8080'] #-job_name:' mysql-exporter' # scrape_interval: 5s # static_configs: #-targets: ['mysql-exporter:9104'] #-job_name:' mysql-exporter-100' # scrape_interval: 5s # static_configs: #-targets: ['mysql-exporter-100:9105']-job_name:' redis-exporter' scrape_interval: 5s static_configs:-targets: ['redis-exporter:9121'] "docker-compose Database Monitoring example Analysis" ends here Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Monitoring reports data templates databases analysis memory content more status interface knowledge disk system network practical successful learning next dilemma official Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Docker Xiaomi Microsoft MySQL