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 小时前
搜索倍增器:推动收入、生产力和 AI 实现规模化
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
Elasticsearch8 小时前
Microsoft Foundry 的 AI agent 可观测性:两个环境变量,无需采集器
elasticsearch
Elastic 中国社区官方博客10 小时前
OpenTelemetry Java 扩展:无需分叉 agent 即可自定义追踪
java·大数据·运维·开发语言·数据库·人工智能·elasticsearch
Elasticsearch14 小时前
从告警到根因仅需 3 分钟:使用 Elastic Agent Builder 实现自动化根因分析
elasticsearch
xiaoxiang960914 小时前
Git 分支同步实战:`merge -X theirs` 与完全合并方案
数据库·git·elasticsearch
Elasticsearch14 小时前
驯服 PUNKs:ES|QL 如何查询 Elasticsearch 从未被告知的字段
elasticsearch
阿里云大数据AI技术14 小时前
技术揭秘:阿里云 Elasticsearch 云原生向量引擎如何登顶 VectorDBBench
人工智能·elasticsearch
就叫_这个吧15 小时前
RabbitMQ+elasticsearch+Redis,实现新增内容并异步到es中,是否消费成功检测
redis·elasticsearch·rabbitmq
ylj_dev16 小时前
从 0 构建 AI Workload Platform(七):可观测性、故障注入与性能验证
go·prometheus·可观测性·opentelemetry·故障注入
醉颜凉17 小时前
Elasticsearch核心架构:集群(Cluster)原理详解与核心作用
elasticsearch·架构·jenkins