Mac部署Prometheus + Grafana监控

步骤一:安装prometheus

$ brew install prometheus
可能会报错(没有权限):
Error: The following directories are not writable by your user:
/usr/local/lib/pkgconfig
$ sudo chown -R $(whoami) /usr/local/lib/pkgconfig
$ chmod u+w /usr/local/lib/pkgconfig

步骤二:编写配置文件 prometheus.yml

vim /usr/local/etc/prometheus.yml
global:
  scrape_interval: 15s

scrape_configs:
  - job_name: "prometheus"
    static_configs:
    - targets: ["localhost:9090"]

步骤三:后台运行(&)prometheus

$ prometheus --config.file=/usr/local/etc/prometheus.yml &

浏览器访问localhost:9090就可以看到prometheus的监控页面
在这里插入图片描述
targets能看到被监控主机状态
在这里插入图片描述

步骤四:安装Grafana

$ brew install grafana

步骤五:运行Grafana

$ brew services start grafana

浏览器访问http://localhost:3000就可以看到Grafana页面
在这里插入图片描述

步骤六:创建数据图形
选择监控数据来源
在这里插入图片描述
这里创建的是prometheus在这里插入图片描述
定义监控名、url
在这里插入图片描述
添加图形
在这里插入图片描述
在这里插入图片描述
选择被监控名
在这里插入图片描述
选择监控项
在这里插入图片描述
展示监控数据
在这里插入图片描述

发布了24 篇原创文章 · 获赞 2 · 访问量 1106

猜你喜欢

转载自blog.csdn.net/Kammingo/article/details/105225838