Mac-Grafana+Prometheus+node_exporter+process_exporter
前言
背景:在校本科生,因为作业的原因需要用到 Prometheus
设备:Macbook air M2
CPU:arm64
涉及:brew、Docker、Grafana、Prometheus、node-exporter、process-exporter
默认:已经配置好 Homebrew 和Docker
1. 下载 Grafana
brew install Grafana
brew services start grafana
打开:localhost:3000
默认账户密码都是 admin,第一次登陆会要求修改密码
2. 下载 node_exporter
brew install node_exporter
brew services start node_exporter
打开:localhost:9100
3. 下载 process-exporter
wget -c https://github.com/ncabatoff/process-exporter/releases/download/v0.5.0/process-exporter-0.5.0.linux-arm64.tar.gz
tar -zxvf process-exporter-*.tar.gz
4. 配置 process-exporter.yaml
cd process-exporter-0.5.0.linux-arm64
vim process-exporter.yaml
里面写入
process_names:
- name: "{{.Comm}}"
cmdline:
- '.+'
打开 docker 并运行 (直接运行好像有问题)
docker run -d --rm -p 9256:9256 --privileged -v /proc:/host/proc -v ` pwd `:/config ncabatoff/process-exporter --procfs /host/proc -config.path /config/process-exporter.yaml
5. 下载 Prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.20.1/prometheus-2.20.1.linux-arm64.tar.gz`
cd ~
tar -zxvf prometheus-*.tar.gz
打开 localhost:9090
6. 配置 prometheus.yml 文件
cd prometheus-2.20.1.linux-arm64
vim prometheus.yml
在里面写入
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'linux-node-cluster'
static_configs:
- targets: ['localhost:9100']
- job_name: 'process'
static_configs:
- targets: ['localhost:9256']
运行 prometheus
prometheus --config.file=prometheus.yml
再次打开 localhost: 9090,进入Targets
如果打开刷新后内容如下,则配置成功了
7. 设置 Grafana 及模板