Docker-安装Prometheus、grafana
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:ro" \ --net="host" \ prom/node-exporter
http://localhost:9100/metrics
# 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/prometheus
http://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/grafana
http://localhost:3000/login
默认用户名密码:admin/admin

分类:
Docker
, Prometheus
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示