我如何在普罗米修斯中可视化弹性搜索指标?,两者都安装在 gke 集群中
Posted
技术标签:
【中文标题】我如何在普罗米修斯中可视化弹性搜索指标?,两者都安装在 gke 集群中【英文标题】:How I can visualize elasticsearch metrics in prometheus?, both installed in a gke cluster 【发布时间】:2019-12-13 00:42:05 【问题描述】:我有一个安装了这个 elasticseach 日志记录解决方案的 GKE 集群
https://console.cloud.google.com/marketplace/details/google/elastic-gke-logging
和由helm安装在同一个集群内的prometheus-operator。
我想配置一个 grafana 仪表板来可视化我的 elasticsearch 指标。
我读到 gke 的弹性应用程序安装了 elastic_exporter...https://github.com/GoogleCloudPlatform/click-to-deploy/blob/master/k8s/elastic-gke-logging/README.md
但是,如果我转到我的 Prometheus 面板,我看不到任何有关弹性搜索的指标。我尝试安装另一个 elastic_exporter,但没有。
我错过了什么?我忘记了什么?是否需要配置 prometheus 从 elastic_exporter 读取?
我在对 elastic_exporter 进行端口转发时看到指标,但在 prometheus 面板中看不到指标。
# HELP elasticsearch_breakers_estimated_size_bytes Estimated size in bytes of breaker
# TYPE elasticsearch_breakers_estimated_size_bytes gauge
elasticsearch_breakers_estimated_size_bytesbreaker="accounting",cluster="elastic-gke-logging-1-cluster",es_client_node="true",es_data_node="true",es_ingest_node="true",es_master_node="true",host="10.50.2.54",name="elastic-gke-logging-1-elasticsearch-0" 4.6637464e+07
elasticsearch_breakers_estimated_size_bytesbreaker="fielddata",cluster="elastic-gke-logging-1-cluster",es_client_node="true",es_data_node="true",es_ingest_node="true",es_master_node="true",host="10.50.2.54",name="elastic-gke-logging-1-elasticsearch-0" 0
elasticsearch_breakers_estimated_size_bytesbreaker="in_flight_requests",cluster="elastic-gke-logging-1-cluster",es_client_node="true",es_data_node="true",es_ingest_node="true",es_master_node="true",host="10.50.2.54",name="elastic-gke-logging-1-elasticsearch-0" 0
elasticsearch_breakers_estimated_size_bytesbreaker="parent",cluster="elastic-gke-logging-1-cluster",es_client_node="true",es_data_node="true",es_ingest_node="true",es_master_node="true",host="10.50.2.54",name="elastic-gke-logging-1-elasticsearch-0" 4.6637464e+07
elasticsearch_breakers_estimated_size_bytesbreaker="request",cluster="elastic-gke-logging-1-cluster",es_client_node="true",es_data_node="true",es_ingest_node="true",es_master_node="true",host="10.50.2.54",name="elastic-gke-logging-1-elasticsearch-0" 0
# HELP elasticsearch_breakers_limit_size_bytes Limit size in bytes for breaker
# TYPE elasticsearch_breakers_limit_size_bytes gauge
谢谢
【问题讨论】:
【参考方案1】:您可能缺少ServiceMonitor
,这应该可以:
k apply -f -<<EOF
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations:
labels:
release: prom
name: elasticsearch
spec:
endpoints:
- port: metrics
selector:
matchLabels:
app: es-exporter
EOF
您的 elasticsearch 服务必须定义 metrics
并具有标签 app: es-exporter
,类似于:
apiVersion: v1
kind: Service
metadata:
labels:
app: es-exporter
component: elasticsearch
name: elasticsearch
spec:
ports:
- name: transport
port: 9200
protocol: TCP
targetPort: 9200
- name: metrics
port: 9108
protocol: TCP
targetPort: 9108
selector:
component: elasticsearch
type: ClusterIP
之后,您应该在 Prometheus 中找到指标,以确认您始终可以在 Prometheus 中使用Status -> Targets
选项卡。
【讨论】:
以上是关于我如何在普罗米修斯中可视化弹性搜索指标?,两者都安装在 gke 集群中的主要内容,如果未能解决你的问题,请参考以下文章