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

相关推荐
Elasticsearch15 小时前
Elasticsearch ES|QL 中的近似查询:在数十亿条记录上实现快 100 倍的查询,并内置置信区间
elasticsearch
敖正炀16 小时前
Elasticsearch 特性全景与选型指南
elasticsearch
敖正炀16 小时前
倒排索引与文本分析引擎
elasticsearch
曦夜日长17 小时前
Linux系统篇,开发工具(一):从入门到精通的软件安装yum使用
linux·运维·elasticsearch
逸Y 仙X17 小时前
文章三十:Elasticsearch SQL实战案例
java·大数据·sql·elasticsearch·搜索引擎·全文检索
有梦想的小何17 小时前
Cursor AI 编程实战(篇二):Rules、速查与 Adapter/App 全文
java·大数据·elasticsearch·搜索引擎·ai·ai编程
零壹AI实验室1 天前
用AI 10分钟搭建一个监控系统:Prometheus + Grafana 实战
人工智能·grafana·prometheus
OYangxf2 天前
Git Ignore
大数据·git·elasticsearch
Elastic 中国社区官方博客2 天前
jina-embeddings-v5-omni:用于文本、图像、音频和视频的 embeddings
大数据·人工智能·elasticsearch·搜索引擎·ai·音视频·jina
泓博2 天前
Openclaw-Ubuntu常用命令
大数据·elasticsearch·搜索引擎·ai