当前位置: 首页 > news >正文

Prometheus+grafana配置监控系统

使用docker compose安装

方便拓展, 配置信息都放在在 /docker/prometheus 目录下

1.目录结构如下
.
├── conf
│   └── prometheus.yml
├── grafana_data
├── prometheus_data
└── prometheus_grafana.yaml
2.创建目录文件
mkdir /docker/prometheus && chmod 777 /docker/prometheuscd /docker/prometheus && mkdir grafana_data prometheus_data && chmod 777 grafana_data prometheus_data
2.1 创建docker compose文件
touch prometheus_grafana.yaml

写入

version: "3.7"networks:prometheus:services:node-exporter:image: prom/node-exporter:latestcontainer_name: "node-exporter0"ports:- "9101:9100"  #按需修改, 宿主机端口: 容器端口restart: alwaysnetworks:- prometheusprometheus:image: prom/prometheus:latestcontainer_name: "prometheus0"restart: alwaysports:- "9090:9090"volumes:- "./conf/prometheus.yml:/etc/prometheus/prometheus.yml"- "./prometheus_data:/prometheus"networks:- prometheusgrafana:image: grafana/grafana:latestcontainer_name: "grafana0"ports:- "3000:3000"restart: alwaysvolumes:- "./grafana_data:/var/lib/grafana"networks:- prometheus
2.2在/docker/prometheus 目录下
mkdir conf && touch conf/prometheus.ymlvim mkdir conf && touch conf/prometheus.yml

写入配置, 注意修改中文注释位置

global:scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.# scrape_timeout is set to the global default (10s).# Alertmanager configuration
alerting:alertmanagers:- static_configs:- targets:# - alertmanager:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:- job_name: 'prometheus'static_configs:- targets: [ 'localhost:9090' ]- job_name: test            #按需修改, 任务名static_configs:- targets: ['ip:9101']      #端口, 上面prometheus_grafana的node-exporter的port设置是9101labels:instance: ins-1         #实例名

启动

docker-compose -f prometheus_grafana.yaml up -d
3.prometheus信息

访问http://ip:9090/targets

能看到node-exporter的推送信息

image-20240131135345798

4.登录grafana

访问http://ip:3000

账号密码默认admin

4.1配置数据源

connection–> datasource–> Add data source选择 Prometheus

image-20240131114400736

输入Prometheus地址, 测试成功

image-20240131114621090

4.2. 配置dashboard

回到datasource页面, Build a dashboard–>Import a dashboard–>输入12633选择一个面板, 导入刚刚Prometheus

image-20240131114754096

image-20240131114833484

image-20240131114935424

就能看到监控面板了

image-20240131134719757

http://www.lryc.cn/news/291899.html

相关文章:

  • Linux之安装配置CentOS 7
  • 神经网络与深度学习Pytorch版 Softmax回归 笔记
  • git学习及简单maven打包
  • 如何用MapTalks IDE来发布网站?
  • 我用selenium开发了一个自动创建任务,解放重复性工作
  • 安卓11修改HDMI自适应分辨率
  • Linux实验记录:使用Apache的虚拟主机功能
  • 分布式空间索引了解与扩展
  • Set和Map的应用场景
  • 小白级教程,10秒开服《幻兽帕鲁》
  • IDEA 构建开发环境
  • 归并排序----C语言数据结构
  • 【网站项目】065健康综合咨询问诊平台
  • Adobe Camera Raw forMac/win:掌控原始之美的秘密武器
  • OpenHarmony—开发及引用静态共享包(API 9)
  • 测试面试题常见题
  • 代码随想录算法训练营第六天 - 哈希表part02
  • 【Javaweb程序设计】【C00165】基于SSM的高考志愿辅助填报系统(论文+PPT)
  • 海外云手机为什么吸引用户?
  • 将`List<String>`转换为`List<Long>`
  • 【Unity3D小功能】Unity3D中Text使用超链接并绑定点击事件
  • MyBatis-Plus CRUD 接口
  • 在JVM中,Java对象是如何创建、存储和访问的?
  • C++类和对象之进击篇
  • ElementUI 组件:Container 布局容器
  • 小米商城服务治理之客户端熔断器(Google SRE客户端熔断器)
  • Springboot 校验工具类
  • 编程笔记 html5cssjs 069 JavaScrip Undefined数据类型
  • MySQL 处理JSON字符串
  • python爬虫-多线程-数据库——WB用户