首页
推荐
GitHub加速
IT工具
PDF工具
Search
1
随身wifi刷debian系统
106 阅读
2
debian 系统使用 fail2ban 教程
47 阅读
3
白嫖Cloudflare优选IP给Vercel网站加速
41 阅读
4
centos7.6 部署python3.12环境——实施方案
41 阅读
5
docker-compose快速安装typecho
23 阅读
docker
cloudflare
linux
nginx
typecho
登录
Search
标签搜索
docker-compose
docker
typecho
sqlite
浏览器
Firefox
homebrew
proxy
gh-proxy
prometheus
grafana
vps
us.kg
cloudflare
eu.org
debian
随身 wifi
Gotify
老阳
累计撰写
35
篇文章
累计收到
0
条评论
首页
栏目
docker
cloudflare
linux
nginx
typecho
页面
推荐
GitHub加速
IT工具
PDF工具
搜索到
1
篇与
的结果
2024-06-18
一、使用docker-compose快速部署Prometheus+grafana环境
由于最近公司服务频繁出问题,老板很生气,下面的人都很不好过,于是老大让加一下业务监控,来观察线上数据状态。但是由于 qa 环境数据量太少,所以自己搭建了一套环境做相关监控,并且写了个脚本模仿生产上的数据,并且做了很多指标,写了一些 Grafana 的 PromQL 语法,网上的资料也很少,我就来补充一下,这个下一章再讲。注意:docker 和 docker-compose 请自行下载安装创建相关目录并给予权限,持久化目录需要给 777 权限,否则容器启动失败cd ~ && mkdir prometheus && chmod 777 prometheus cd prometheus && mkdir grafana_data prometheus_data && chmod 777 grafana_data prometheus_data./docker-compose.ymlversion: "3.7" services: node-exporter: image: prom/node-exporter:latest container_name: "node-exporter0" ports: - "9100:9100" restart: always prometheus: image: prom/prometheus:latest container_name: "prometheus0" restart: always ports: - "9090:9090" volumes: - "./prometheus.yml:/etc/prometheus/prometheus.yml" - "./prometheus_data:/prometheus" grafana: image: grafana/grafana container_name: "grafana0" ports: - "3000:3000" restart: always volumes: - "./grafana_data:/var/lib/grafana"注:prometheus 主机需要部署以上容器,其他被监控主机只需要部署 node-exporterprometheus 配置文件(根据自己的服务器 ip 进行修改 targets 内容)./prometheus.ymlglobal: scrape_interval: 15s # 默认抓取周期 external_labels: monitor: 'codelab-monitor' scrape_configs: - job_name: 'node-exporter' #服务的名称 scrape_interval: 5s metrics_path: /metrics #获取指标的url static_configs: - targets: ['139.224.224.229:9100'] # 这个为监听指定服务服务的ip和port,需要修改为自己的ip,貌似云服务必须用公网ipdocker-compose 启动docker-compose up -d # 挂载目录给权限,不然会启动失败如果启动报如下的"没有权限"错误:grafana0 | You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migrate-to-v51-or-later grafana0 | mkdir: can't create directory '/var/lib/grafana/plugins': Permission denied grafana0 | GF_PATHS_DATA='/var/lib/grafana' is not writable. grafana0 | You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migrate-to-v51-or-later grafana0 | mkdir: can't create directory '/var/lib/grafana/plugins': Permission denied grafana0 | GF_PATHS_DATA='/var/lib/grafana' is not writable. grafana0 | You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migrate-to-v51-or-later grafana0 | mkdir: can't create directory '/var/lib/grafana/plugins': Permission denied grafana0 | GF_PATHS_DATA='/var/lib/grafana' is not writable. grafana0 | You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migrate-to-v51-or-later grafana0 | mkdir: can't create directory '/var/lib/grafana/plugins': Permission denied grafana0 | GF_PATHS_DATA='/var/lib/grafana' is not writable. grafana0 | You may have issues with file permissions, more information here: http://docs.grafana.org/installation/docker/#migrate-to-v51-or-later grafana0 | mkdir: can't create directory '/var/lib/grafana/plugins': Permission denied则需要将挂载目录赋予权限,即:chmod 777 grafana_data/ prometheus_data/ #个人根据配置文件中具体的挂在目录进行权限修改访问主机的 9090 端口可以查到 Prometheus 监控到的数据,访问 3000 端口是 grafana 的界面账密admin/admin配置监控,点击齿轮,选择 Data Sources点击 Add data source填写 prometheus 地址 ip+端口或者主机名+端口(需要配置 hosts)点击 save&test点击+号,选择 import输入模板号 9276,点击 load。 8919导入模板完成
2024年06月18日
1 阅读
0 评论
0 点赞