组件名称:elasticsearch-exporter
github地址:GitHub - prometheus-community/elasticsearch_exporter: Elasticsearch stats exporter for Prometheus
监控目标:192.168.0.100、192.168.0.101、192.168.0.102集群
组件部署位置:192.168.0.39
docker-cpmpose启动
cat /data/docker-compose_dir/elastic/docker-compose.yml
version: '3'
services:
sticsearch_exporter-192.168.0.100:
image: quay.io/prometheuscommunity/elasticsearch-exporter:latest
command:
- '--es.uri=http://192.168.0.100:9200'
restart: always
ports:
- "0.0.0.0:9600:9114"
sticsearch_exporter-192.168.0.101:
image: quay.io/prometheuscommunity/elasticsearch-exporter:latest
command:
- '--es.uri=http://192.168.0.101:9200'
restart: always
ports:
- "0.0.0.0:9601:9114"
sticsearch_exporter-192.168.0.102:
image: quay.io/prometheuscommunity/elasticsearch-exporter:latest
command:
- '--es.uri=http://192.168.0.102:9200'
restart: always
ports:
- "0.0.0.0:9602:9114"
启动
docker-compose up -d
prometheus集成组件
# elasticsearch_exporter
- job_name: elastic-192.168.0.100
scrape_interval: 15s
static_configs:
- targets: ['192.168.0.39:9600']
- job_name: elastic-192.168.0.101
scrape_interval: 15s
static_configs:
- targets: ['192.168.0.39:9601']
- job_name: elastic-192.168.0.102
scrape_interval: 15s
static_configs:
- targets: ['192.168.0.39:9602']
告警配置
# cat elastic-rules.yaml
groups:
- name: ElasticSearch-监控告警
rules:
- alert: 集群节点数减少告警
expr: elasticsearch_cluster_health_number_of_nodes < 4
for: 5m
labels:
severity: warning
status: 非常严重
annotations:
summary: "ES集群节点数减少:{{$.Labels.job}}"
description: "ES集群节点数减少:{{$.Labels.job}},(当前:{{$value}})"
- alert: jvm内存使用率告警
expr: elasticsearch_jvm_memory_used_bytes{area="heap"} / elasticsearch_jvm_memory_max_bytes{area="heap"} > 0.9
for: 5m
labels:
severity: warning
status: 非常严重
annotations:
summary: "jvm内存使用率过高:{{$.Labels.job}}"
description: "jvm内存使用率过高:{{$.Labels.job}} => 0.9,(当前:{{$value}})"
重启prometheus
docker restart prometheus
grafana图形:
2322
具体需要微调一下



