Prometheus 是一个开放性的监控解决方案,通过 Node Exporter 采集当前主机的系统资源使用情况,并通过 Grafana 创建一个简单的可视化仪表盘。
docker run -d \
-p 9090:9090 \
-v ./prometheus.yml:/etc/prometheus/prometheus.yml \
--name=prometheus \
prom/prometheus:latest \
--web.enable-lifecycle
配置的 prometheus.yml
global:
scrape_interval: 60s
evaluation_interval: 60s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ["localhost:9090"]
labels:
instance: prometheus
- job_name: linux
static_configs:
- targets: ["10.10.20.11:9100", "10.10.20.12:9100", "10.10.20.13:9100"]
labels: appname:'local-linux'
重载配置
curl -X POST http://10.10.20.11:9090/-/reload
docker run -d --name=grafana -p 3000:3000 grafana/grafana
访问:http://10.10.20.11:3000/ admin/admin
添加数据源,导入模板 12884 即可
暴露节点信息给 Prometheus
docker run -d --restart=always \
-p 9100:9100 \
--name node-exporter \
quay.io/prometheus/node-exporter:latest
version: "3"
services:
# prometheus
prom:
restart: unless-stopped
image: prom/prometheus:v2.39.1
container_name: prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
- "--web.console.libraries=/etc/prometheus/console_libraries"
- "--web.console.templates=/etc/prometheus/consoles"
- "--storage.tsdb.retention=200h"
- "--web.enable-lifecycle"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:rw
- ./prometheus_data:/prometheus
ports:
- 9090:9090
# grafana
grafana:
restart: unless-stopped
container_name: grafana
image: grafana/grafana:6.7.2
ports:
- "3000:3000"
volumes:
- ./grafana_data:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
- GF_USERS_ALLOW_SIGN_UP=false
depends_on:
- prom
#设置权限 chmod 777 ./grafana_data&&chmod 777 ./prometheus_data
chmod 777 ./grafana_data && chmod 777 ./prometheus_data
下载地址:https://github.com/prometheus-community/windows_exporter/releases
插件名 DevOpsProdigy KubeGraf
k8s 监控需要安装插件 DevOpsProdigy KubeGraf,版本用 6.7.2,配置 config basic64 解码配置,进入容器中 安装依赖 grafana-cli plugins install grafana-piechart-panel
插件名 vertamedia-clickhouse-datasource
安装 redis_exporter
docker pull oliver006/redis_exporter
运行
docker run -d --restart=always --name redis_exporter -p 9121:9121 oliver006/redis_exporter --redis.addr redis://192.168.0.666:6380
配置 prometheus.yml
- job_name: "redis_exporter_targets"
static_configs:
- targets:
[
"redis://192.168.0.147:6380",
"redis://192.168.0.149:6380",
"redis://192.168.0.150:6380",
]
metrics_path: /scrape
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 192.168.0.149:9121
version:v6.7.2
envoy:11021
windows:12566
Linux:10180
k8s:插件 DevOpsProdigy KubeGraf,配置 config basic64 解码配置,进入容器中 安装依赖 grafana-cli plugins install grafana-piechart-panel
redis:763
clickhouse:2515,需要安装插件并配置数据源 grafana-cli plugins install vertamedia-clickhouse-datasource 1.9.5
通过strimzi部署的kafka集群,如何部署prometheus+grafana去监控呢?官方文档信息量太大,即便照着做也可能失败,这里有一份详细的保姆级操作指南,助您成功部署监控服务