Prometheus 监控与告警
🤖

Prometheus 监控与告警

介绍

官网文档地址:

特征

Prometheus的主要特点是:
  • 具有由指标名称和键/值对标识的时间序列数据的多维数据模型
  • 不依赖分布式存储;单个服务器节点是自主的
  • 时间序列收集通过 HTTP 上的拉取模型进行
  • 通过服务发现或静态配置发现目标
  • 多种图形和仪表板支持模式

架构

notion image

配置

最简单的配置文件
global: scrape_interval: 15s evaluation_interval: 15s rule_files: # - "first.rules" # - "second.rules"scrape_configs: - job_name: prometheus static_configs: - targets: ['localhost:9090']
一共分为三部分:
  • 时间间隔(抓取间隔和评估间隔)
  • 规则位置
  • 监控目标

详细配置文件说明

快速部署

docker-compose 部署方式
1、创建文件[docker-compose.yml]
version: '3' services: prometheus: image: docker.chenby.cn/prom/prometheus:latest ports: - "9090:9090" volumes: - ./prometheus.yml:/etc/prometheus/prometheus.yml
2、创建配置文件[prometheus.yml]
global: scrape_interval: 15s evaluation_interval: 15s scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090']

表达语句

 

语法检测

promtool check rules /path/to/example.rules.yml

规则测试

promtool test rules test.yml