Docker-安裝Prometheus、grafana
阿新 • • 發佈:2022-05-11
1.拉取映象包
docker pull prom/node-exporter docker pull prom/prometheus docker pull grafana/grafana
2.啟動node-exporter[方便測試Prometheus]
docker run -d -p 9100:9100 \ -v "/home/fz/docker/node-exporter/proc:/host/proc:ro" \ -v "/home/fz/docker/node-exporter/sys:/host/sys:ro" \ -v "/home/fz/docker/node-exporter/:/rootfs:rohttp://localhost:9100/metrics" \ --net="host" \ prom/node-exporter
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile="0"} 0 go_gc_duration_seconds{quantile="0.25"} 0 go_gc_duration_seconds{quantile="0.5"} 0 go_gc_duration_seconds{quantile="0.75"} 0 go_gc_duration_seconds{quantile="1"} 0 go_gc_duration_seconds_sum 0 go_gc_duration_seconds_count 0 # HELP go_goroutines Number of goroutines that currently exist. # TYPE go_goroutines gauge go_goroutines 8 # HELP go_info Information about the Go environment. # TYPE go_info gauge go_info{version="go1.16.7"} 1 # HELP go_memstats_alloc_bytes Number of bytes allocated and still in use. # TYPE go_memstats_alloc_bytes gauge go_memstats_alloc_bytes 1.346552e+06 # HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed. # TYPE go_memstats_alloc_bytes_total counter go_memstats_alloc_bytes_total 1.346552e+06 # HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table. # TYPE go_memstats_buck_hash_sys_bytes gauge go_memstats_buck_hash_sys_bytes 1.445106e+06 # HELP go_memstats_frees_total Total number of frees. # TYPE go_memstats_frees_total counter go_memstats_frees_total 730 # HELP go_memstats_gc_cpu_fraction The fraction of this program's available CPU time used by the GC since the program started. # TYPE go_memstats_gc_cpu_fraction gauge go_memstats_gc_cpu_fraction 0
3.啟動prometheus
mkdir /home/fz/docker/prometheus
cd /home/fz/docker/prometheus
vim prometheus.yml
global: scrape_interval: 60s evaluation_interval: 60s scrape_configs: - job_name: prometheus static_configs: - targets: ['localhost:9090'] labels: instance: prometheus - job_name: linux static_configs: - targets: ['localhost:9100'] labels: instance: localhost - job_name: clickhouse-1 static_configs: - targets: ['xx1:9363','xx2:9363','xx3:9363'] labels: instance: localhost
此處配置了一個clickhouse叢集,如有沒有直接刪掉相關配置即可。
啟動docker run -d -p 9090:9090 -v /home/fz/docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheushttp://localhost:9090/graph
4.啟動grafana
建立對映的資料卷mkdir /home/fz/docker/grafana-storage chmod 777 -R /home/fz/docker/grafana-storage
啟動
docker run -d -p 3000:3000 --name=grafana -v /home/fz/docker/grafana-storage:/var/lib/grafana grafana/grafanahttp://localhost:3000/login 預設使用者名稱密碼:admin/admin