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

相关推荐
Elasticsearch4 小时前
一个字段,覆盖所有模态:Elasticsearch 的 semantic 字段如何自动索引和搜索图像、音频、视频和 PDF
elasticsearch
Elastic 中国社区官方博客5 小时前
使用 Elasticsearch open inference API 对 OpenAI chat completions 进行支持
大数据·elasticsearch·搜索引擎·全文检索·jenkins
Elasticsearch7 小时前
jina-reranker-v3.5:通过混合 Attention 和自蒸馏实现更快的 Listwise Reranking
elasticsearch
Elasticsearch8 小时前
Elasticsearch 转型为 Agent 基础设施:混合搜索、长期记忆与工程化框架
elasticsearch
Elasticsearch9 小时前
在隔离网络和断开连接的环境中部署 Elastic
elasticsearch
Elasticsearch10 小时前
从搜索到结账只需 20 行代码:使用 OpenTelemetry 构建四阶段转化漏斗
elasticsearch
Elasticsearch11 小时前
你的堆内存图表看不到的隐藏压力:AutoOps 现已监控向量堆外内存
elasticsearch
程序员小八7771 天前
一篇文章讲透 Elasticsearch:从倒排索引到实战落地
大数据·elasticsearch·搜索引擎