Building grafana+prometheus monitoring resources and rapid deployment based on docker Basic server information
- Service action port (default)
- Prometheus main server 9090
- Node_Exporter is responsible for collecting host hardware information and operating system information 9100
- MySqld_Exporter is responsible for collecting mysql data information 9104
- The Cadvisor is responsible for collecting Docker container information running on the Host8080
- Grafana is responsible for displaying Prometheus monitoring interface 3000
- Altermanager waits to receive the alarm information sent by prometheus, and then sends it to the defined recipient 9093
Prometheus
#Start container setting port docker run -itd --name docker_prometheus --restart=always -p 9090:9090 -v $PWD/prometheus:/etc/prometheus/ prom/prometheus #Docker run #-- name The name of the container #- p Specifies the port mapping of the container #- v Map the local path to the container (so that if the local file is modified, it only needs to restart the container to take effect in the container) #-- restart The container restart policy no does not restart. Always restart when always exits #Prom/prometheus Select the image name to start the container (the latest will be added after the default image if you pull the image you created)
Grafana
#Start container setting port docker run -itd --name=grafana --restart=always -p 3000:3000 -v $PWD/grafana-storage:/var/lib/grafana grafana/grafana #Docker run #-- name The name of the container #- p Specifies the port mapping of the container #- v: Mount the host directory and the directory in the docker container$ PWD/grafana storage: local host absolute directory/ Var/lib/grafana: container directory (mount the container directory locally) #-- restart Container restart policy No: Do not restart, always: Always restart when exiting #Grafana/grafana Select the image name to start the container #Add directory permission (not adding permission is not enough, and the container cannot be started) chmod -R 777 grafana-storage
Node_export is an export of Prometheus, which is mainly used to collect the usage of server hardware resources. So this is often deployed to the monitored server. That is, grafana and Prometheus will be independently deployed on a single machine, and node_export will be deployed on the monitored server to collect the monitored server resource data, send it to Prometheus, and then display it through grafana
node_exporter
##Start node exporter docker run -d --name node-exporter --restart=always -p 9100:9100 -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" prom/node-exporter
Configure Prometheus+node_exporter to collect data
Modify the configuration file (by modifying the file, connect prom and node_exporter together, collect data through the latter, transmit it to the former, and finally present it in grafana)
vim prometheus/prometheus.yml
Here I will give you a general picture. This is the effect picture after all my configurations are completed. You can take what you need and use this picture only later. Here we can see that the parameters of endpoint and labels are actually the parameters configured in prometheus.yml.
Configuring the Granfan Panel
- Login to granfana Username Password defaults to admin
- Settings – Data Source – Add Data Source
- Select Prometheus and add http://ip:9090
- Select data display template and add template
Template address 1: (or direct import ID: 8919)
Template address 2: (or directly import ID: 11074)
I'll fill in the figure later
]]>