prometheus添加es监控模块

1、helm部署es-exporter

shell 复制代码
helm upgrade --install es-exporter prometheus-community/prometheus-elasticsearch-exporter  --set es.uri=https://elastic:xxx@172.31.107.43:9200 --set es.sslSkipVerify=true -n monitoring

2、编写ServiceMonitor yaml文件并部署

yaml 复制代码
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: elasticsearch-exporter-sm
  namespace: monitoring # 建议与 Prometheus 同命名空间,或根据 Operator 配置决定
  labels:
    release: release-prometheus # 关键:必须匹配 Prometheus 实例的 serviceMonitorSelector
spec:
  jobLabel: app.kubernetes.io/name
  selector:
    matchLabels:
      # 替换为你 exporter Service 的实际标签
      app.kubernetes.io/name: elasticsearch-exporter
      app.kubernetes.io/instance: elasticsearch-exporter
  namespaceSelector:
    any: true # 允许跨命名空间发现
  endpoints:
  - port: http-metrics # 必须匹配 Service 中定义的 port name
    interval: 30s
    scrapeTimeout: 10s
    path: /metrics

3、编写rules yaml文件

yaml 复制代码
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: elasticsearch-alerts
  namespace: monitoring
  labels:
    role: alert-rules
    release: release-prometheus
spec:
  groups:
  - name: elasticsearch-health
    rules:
    - alert: ElasticsearchClusterRed
      expr: elasticsearch_cluster_status{color="red"} == 1
      for: 0m
      labels:
        severity: critical
      annotations:
        summary: "ES 集群状态为 RED"
        description: "集群 {{ $labels.cluster }} 处于红色状态,部分分片不可用。"
    
    - alert: ElasticsearchClusterYellow
      expr: elasticsearch_cluster_status{color="yellow"} == 1
      for: 5m
      labels:
        severity: warning
      annotations:
        summary: "ES 集群状态为 YELLOW"
        description: "集群 {{ $labels.cluster }} 处于黄色状态,副本分片未完全分配。"

    - alert: ElasticsearchNodeDiskFull
      expr: elasticsearch_filesystem_data_free_bytes / elasticsearch_filesystem_data_size_bytes < 0.1
      for: 5m
      labels:
        severity: critical
      annotations:
        summary: "ES 节点磁盘空间不足"
        description: "节点 {{ $labels.instance }} 剩余空间低于 10%。"

4、导入grafana id

4377

13072

14191

3236

相关推荐
Elastic 中国社区官方博客4 小时前
为 Elastic Cloud Serverless 和 Elasticsearch 引入统一的 API 密钥
大数据·运维·elasticsearch·搜索引擎·云原生·serverless
vastsmile6 小时前
(R)26.04.23 hermes agent执行本地命令超级慢的原因
开发语言·elasticsearch·r语言
OtIo TALL11 小时前
Java进阶(ElasticSearch的安装与使用)
java·elasticsearch·jenkins
xmlhcxr13 小时前
基于 HAProxy+Keepalived 构建高可用 ZrLog 博客系统及监控平台实现(Prometheus + Grafana)
架构·grafana·prometheus
Elastic 中国社区官方博客15 小时前
Jina embeddings v3 现已在 Gemini Enterprise Agent Platform Model Garden 上可用
大数据·人工智能·elasticsearch·搜索引擎·ai·全文检索·jina
前端若水16 小时前
Git 撤销与恢复完全指南(超级详细版)
大数据·git·elasticsearch
tonydf16 小时前
日志模块该如何设计
后端·elasticsearch
前端若水16 小时前
Git 可以做的所有操作(完整分类)
大数据·git·elasticsearch
Elasticsearch16 小时前
我们如何构建 Elasticsearch simdvec,使向量搜索成为世界上最快之一
elasticsearch
搬砖天才、17 小时前
es数据备份
大数据·elasticsearch·jenkins