当前位置: 首页 > news >正文

Prometheus运维之路(ES监控接入)

最近公司因为新项目业务需求,接入了ES集群,为了观察ES相关指标所以也接入到了Prometheus当中,这个是我在测试环境中接入单节点的过程。仅供参考。

1. 下载镜像

 root@YD-CN-Service-15963: docker pull quay.io/prometheuscommunity/elasticsearch-exporter:latest

2.连接启动并连接到ES获取状态

root@YD-CN-Service-15963:/usr/local/disk_vdb/elasticsearch# cat docker-compose.yml 
services:elasticsearch:image: elasticsearch:7.17.28container_name: elasticsearchports:- "9200:9200"- "9300:9300"environment:- discovery.type=single-node- ES_JAVA_OPTS=-Xms512m -Xmx2048mvolumes:- /usr/local/disk_vdb/elasticsearch/config:/usr/share/elasticsearch/config- /usr/local/disk_vdb/elasticsearch/data:/usr/share/elasticsearch/data- /usr/local/disk_vdb/elasticsearch/plugins:/usr/share/elasticsearch/plugins- /usr/local/disk_vdb/elasticsearch/logs:/usr/share/elasticsearch/logselasticsearch_exporter:image: quay.io/prometheuscommunity/elasticsearch-exporter:latestcommand:- '--es.uri=http://账号:密码@10.0.0.22:9200'restart: alwaysports:- "9114:9114"

3.在Prometheus中引入exporter

root@YD-CN-Service-15963:/usr/local/disk_vdb# cat docker_project/prometheus_monitor/prometheus/prometheus.yml 
# ...省略配置- job_name: 'elasticsearch7'static_configs:- targets:- 10.0.0.22:9114

4. 在Prometheus引入模板(直接导入Json)

{"graphTooltip": 1,"panels": [{"collapsed": false,"gridPos": {"h": 1,"w": 24,"x": 0,"y": 0},"id": 1,"panels": [ ],"title": "Overview","type": "row"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 8,"x": 0,"y": 1},"id": 2,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "sum(\n  elasticsearch_cluster_health_number_of_nodes{cluster=~\"$cluster\"}\n)\n"}],"title": "Nodes","type": "stat"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 8,"x": 8,"y": 1},"id": 3,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "sum(\n  elasticsearch_cluster_health_number_of_data_nodes{cluster=~\"$cluster\"}\n)\n"}],"title": "Data Nodes","type": "stat"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 8,"x": 16,"y": 1},"id": 4,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "sum(\n  elasticsearch_cluster_health_number_of_pending_tasks{cluster=~\"$cluster\"}\n)\n"}],"title": "Pending Tasks","type": "stat"},{"collapsed": false,"gridPos": {"h": 1,"w": 24,"x": 0,"y": 5},"id": 5,"panels": [ ],"title": "Shards","type": "row"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 4,"x": 0,"y": 6},"id": 6,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "sum(\n  elasticsearch_cluster_health_active_shards{cluster=~\"$cluster\"}\n)\n"}],"title": "Active","type": "stat"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 4,"x": 4,"y": 6},"id": 7,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "sum(\n  elasticsearch_cluster_health_active_primary_shards{cluster=~\"$cluster\"}\n)\n"}],"title": "Active Primary","type": "stat"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 4,"x": 8,"y": 6},"id": 8,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "sum(\n  elasticsearch_cluster_health_initializing_shards{cluster=~\"$cluster\"}\n)\n"}],"title": "Initializing","type": "stat"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 4,"x": 12,"y": 6},"id": 9,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "sum(\n  elasticsearch_cluster_health_reloacting_shards{cluster=~\"$cluster\"}\n)\n"}],"title": "Relocating","type": "stat"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 4,"x": 16,"y": 6},"id": 10,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "sum(\n  elasticsearch_cluster_health_unassigned_shards{cluster=~\"$cluster\"}\n)\n"}],"title": "Unassigned","type": "stat"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 4,"x": 20,"y": 6},"id": 11,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "sum(\n  elasticsearch_cluster_health_delayed_unassigned_shards{cluster=~\"$cluster\"}\n)\n"}],"title": "DelayedUnassigned","type": "stat"},{"collapsed": false,"gridPos": {"h": 1,"w": 24,"x": 0,"y": 10},"id": 12,"panels": [ ],"title": "Documents","type": "row"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 4,"x": 0,"y": 11},"id": 13,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "elasticsearch_indices_docs{cluster=~\"$cluster\"}\n"}],"title": "Indexed Documents","type": "timeseries"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"fieldConfig": {"defaults": {"unit": "bytes"}},"gridPos": {"h": 4,"w": 4,"x": 4,"y": 11},"id": 14,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "elasticsearch_indices_store_size_bytes{cluster=~\"$cluster\"}\n"}],"title": "Index Size","type": "timeseries"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 4,"x": 8,"y": 11},"id": 15,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "rate(elasticsearch_indices_indexing_index_total{cluster=~\"$cluster\"}[$__rate_interval])\n","legendFormat": "{{name}}"}],"title": "Index Rate","type": "timeseries"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 4,"x": 12,"y": 11},"id": 16,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "rate(elasticsearch_indices_search_query_total{cluster=~\"$cluster\"}[$__rate_interval])\n","legendFormat": "{{name}}"}],"title": "Query Rate","type": "timeseries"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 4,"x": 16,"y": 11},"id": 17,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "sum(elasticsearch_thread_pool_queue_count{cluster=~\"$cluster\",type!=\"management\"}) by (type)\n","legendFormat": "{{type}}"}],"title": "Queue Count","type": "timeseries"},{"collapsed": false,"gridPos": {"h": 1,"w": 24,"x": 0,"y": 15},"id": 18,"panels": [ ],"title": "Memory","type": "row"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"fieldConfig": {"defaults": {"unit": "bytes"}},"gridPos": {"h": 4,"w": 6,"x": 0,"y": 16},"id": 19,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "elasticsearch_jvm_memory_used_bytes{cluster=~\"$cluster\"}\n","legendFormat": "{{name}} {{area}}"}],"title": "Memory Usage","type": "timeseries"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"fieldConfig": {"defaults": {"max": 1,"min": 0,"unit": "percentunit"}},"gridPos": {"h": 4,"w": 6,"x": 6,"y": 16},"id": 20,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "avg_over_time(\n  elasticsearch_jvm_memory_used_bytes{cluster=~\"$cluster\"}[15m]\n) /\nelasticsearch_jvm_memory_max_bytes{cluster=~\"$cluster\"}\n","legendFormat": "{{name}} {{area}}"}],"title": "Memory 15m Avg","type": "timeseries"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"fieldConfig": {"defaults": {"unit": "bytes"}},"gridPos": {"h": 4,"w": 6,"x": 12,"y": 16},"id": 21,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "elasticsearch_jvm_memory_max_bytes{cluster=~\"$cluster\"}\n","legendFormat": "{{name}} {{area}}"}],"title": "Memory Max","type": "timeseries"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"fieldConfig": {"defaults": {"unit": "s"}},"gridPos": {"h": 4,"w": 6,"x": 18,"y": 16},"id": 22,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "rate(\n  elasticsearch_jvm_gc_collection_seconds_sum{cluster=~\"$cluster\"}[$__rate_interval]\n)\n","legendFormat": "{{name}} {{gc}}"}],"title": "GC Rate","type": "timeseries"},{"collapsed": false,"gridPos": {"h": 1,"w": 24,"x": 0,"y": 20},"id": 23,"panels": [ ],"title": "Threads","type": "row"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 12,"x": 0,"y": 21},"id": 24,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "elasticsearch_thread_pool_active_count{cluster=~\"$cluster\"}\n","legendFormat": "{{type}}"}],"title": "Thread Pools","type": "timeseries"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"gridPos": {"h": 4,"w": 12,"x": 12,"y": 21},"id": 25,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "elasticsearch_thread_pool_rejected_count{cluster=~\"$cluster\"}\n","legendFormat": "{{name}} {{type}}"}],"title": "Thread Pool Rejections","type": "timeseries"},{"collapsed": false,"gridPos": {"h": 1,"w": 24,"x": 0,"y": 25},"id": 26,"panels": [ ],"title": "Network","type": "row"},{"datasource": {"type": "datasource","uid": "-- Mixed --"},"fieldConfig": {"defaults": {"unit": "bytes"}},"gridPos": {"h": 4,"w": 24,"x": 0,"y": 26},"id": 27,"pluginVersion": "v10.4.0","targets": [{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "rate(\n  elasticsearch_transport_rx_size_bytes_total{cluster=~\"$cluster\"}[$__rate_interval]\n)\n","legendFormat": "{{name}} TX"},{"datasource": {"type": "prometheus","uid": "$datasource"},"expr": "rate(\n  elasticsearch_transport_tx_size_bytes_total{cluster=~\"$cluster\"}[$__rate_interval]\n)\n","legendFormat": "{{name}} RX"}],"title": "Transport Rate","type": "timeseries"}],"refresh": "1m","schemaVersion": 36,"tags": ["elasticsearch-exporter-mixin"],"templating": {"list": [{"name": "datasource","query": "prometheus","type": "datasource"},{"datasource": {"type": "prometheus","uid": "${datasource}"},"name": "cluster","query": "label_values(elasticsearch_cluster_health_status, cluster)","type": "query"}]},"time": {"from": "now-1h","to": "now"},"timezone": "utc","title": "Elasticsearch Exporter /  Cluster"}

5.查看图表

image-20251010200951144

image-20251010200951144

http://www.dtcms.com/a/464752.html

相关文章:

  • OpenAMP专题(一):一文了解OpenAMP全貌
  • C++ 中 rfind 方法详解
  • SpringBoot 教程(十四) SpringBoot之集成 Redis(优化版)
  • 【Linux】线程同步与互斥(上)
  • 图观 模型编辑器
  • Win11 输入延迟与鼠标卡顿:系统化排查与优化指南
  • 【开题答辩全过程】以 爱运动健身小程序的设计与实现为例,包含答辩的问题和答案
  • Linux 内核IIO sensor驱动
  • 《Linux系统编程之入门基础》【Linux的前世今生】
  • 活动汪活动策划网站龙岗建设网站
  • Apache IoTDB 架构特性与 Prometheus+Grafana 监控体系部署实践
  • LLM时代基于unstructured解析非结构化pdf
  • uniapp tab切换及tab锚点效果(wx小程序及H5端)
  • Hadoop面试题及详细答案 110题 (71-85)-- 集群部署与运维
  • 5-1〔OSCP ◈ 研记〕❘ SQL注入攻击▸SQL注入理论基础
  • 南充市企业网站建设wordpress极客主题
  • 企业做小红书关键词搜索排名推广时,怎么找到小红书上有一定搜索量但竞争度低的蓝海词?
  • 数据仓库与数据挖掘基础知识
  • 鸿蒙:使用Rating组件实现五角星打分评价
  • 外国人可以在中国做网站吗做个网站得花多少钱
  • 双均线策略
  • 【vLLM 学习】Neuron
  • 网站做行业认证好处施工企业在施工过程中发现工程设计图纸存在差错的
  • 迅为RK3576开发板挂载Windows以及虚拟机Ubuntu测试
  • 第1篇:创建基础电商AI客服
  • 【MyBatis从入门到入土】告别JDBC原始时代:零基础MyBatis极速上手指南
  • MaxScript 科研绘图教程:从数据到精确的可视化
  • org.apache.http.conn.HttpHostConnectException: Connect to localhost:8086
  • 深度学习入门(一)——从神经元到损失函数,一步步理解前向传播(上)
  • 沧州网站制作公司宁波网站的优化