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
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

 

posted @   小学生II  阅读(172)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 百万级群聊的设计实践
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
历史上的今天:
2018-03-28 BlazeMeter+Jmeter 搭建接口测试框架
2018-03-28 nGrinder 简易使用教程
点击右上角即可分享
微信分享提示