Mac搭建Grafana+Prometheus+NodeExporter+mysqld-exporter
转载:https://www.jianshu.com/p/67087e164144
安装启动Grafana
brew install Grafana
brew services start grafana
启动后,通过http://localhost:3000/访问,用户名和密码都是admin,如图:

Grafana
安装启动Prometheus
brew install prometheus
brew services start prometheus
安装启动node_exporter
brew install node_exporter
brew services start node_exporter
启动后,可以通过http://localhost:9100/查看,如图:

node_exporter
安装启动mysqld_exporter
docker pull prom/mysqld-exporter
docker run -d -p 9104:9104 -e DATA_SOURCE_NAME="username:passwd@(localhost:3306)/dbname" prom/mysqld-exporter
安装启动cadvisor
#安装
docker pull google/cadvisor:latest
#启动
docker run \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:rw \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--volume=/dev/disk/:/dev/disk:ro \
--publish=8080:8080 \
--detach=true \
--name=cadvisor \
google/cadvisor:latest
启动后,访问http://localhost:8080/metrics,查看暴露给Prometheus的数据。
访问http://localhost:8080/containers/,查看各个container的数据,如图:

containers
配置Prometheus
配置文件默认放在/usr/local/etc/prometheus.yml,重启服务生效
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
labels:
instance: prometheus
- job_name: "node_exporter"
static_configs:
- targets: ["localhost:9100"]
labels:
instance: node_exporter
- job_name: mysqld_exporter
static_configs:
- targets: ['localhost:9104']
labels:
instance: mysqld_exporter
- job_name: 'cadvisor'
static_configs:
- targets: ['127.0.0.1:8080']
labels:
instance: cadvisor
启动后,可以通过http://localhost:9090/打开,查询go_threads语句,如图:

Prometheus
配置Grafana的Prometheus数据源
首先找到Configuration的Data Sources,

Configuration
然后Add data source,添加Prometheus

Add data source
设置Prometheus的URL,Save&Test,添加完成。

Prometheus
添加dashboard
直接import Prometheus Stats等dashboard

dashboard
点击进入Prometheus Stats,如图:

作者:土豆特别想爬山
链接:https://www.jianshu.com/p/67087e164144
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。