1.需要先添加prometheus的默认配置文件
# my global config
global:
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 configuration
alerting:
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=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
2.直接直接使用官方镜像启动
我这边文件是在/tmp下的
docker run -d --name=promethues -p 9090:9090 -v /tmp/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
默认端口是9090 可以直接ip:prot访问
页面可以正常打开 证明prometheus已经安装完成
3.安装监控节点node_exporter
docker run -d -p 9100:9100 -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" prom/node-exporter
默认端口是9100 可以直接ip:prot访问确认是否已经收集到数据
也可以在prometheus中查看是否有数据
4.安装grafana做页面展示
docker run -d --name=grafana -p 3000:3000 grafana/grafana
默认账号密码均为admin
添加数据源选择prometheus,url选择promethues访问链接,并保存
导入模板选择9276(可以自己选择喜欢的)并保存
查看监控