feat(data): OpenSearch prometheus-exporter sidecar

elasticsearch-exporter v1.7.0 runs as a sidecar, scrapes localhost:9200,
exposes elasticsearch_* metrics on :9114. ServiceMonitor re-enabled.
Alert rules updated to use elasticsearch_* metric names.
Flags: --es.all --es.indices --es.shards --collector.clustersettings
This commit is contained in:
2026-03-25 17:53:59 +00:00
parent 0a322c8a7c
commit 7cb6bb1bd2
5 changed files with 32 additions and 11 deletions

View File

@@ -12,9 +12,10 @@ resources:
- opensearch-service.yaml - opensearch-service.yaml
- opensearch-pvc.yaml - opensearch-pvc.yaml
- barman-vault-secret.yaml - barman-vault-secret.yaml
# opensearch-servicemonitor.yaml removed — OpenSearch 3.x has no prometheus-exporter plugin. - opensearch-servicemonitor.yaml
# TODO: add opensearch-exporter sidecar for Prometheus metrics.
- opensearch-alertrules.yaml - opensearch-alertrules.yaml
- cnpg-podmonitor.yaml
- openbao-servicemonitor.yaml
- postgres-alertrules.yaml - postgres-alertrules.yaml
- openbao-alertrules.yaml - openbao-alertrules.yaml
- searxng-deployment.yaml - searxng-deployment.yaml

View File

@@ -10,7 +10,7 @@ spec:
- name: opensearch - name: opensearch
rules: rules:
- alert: OpenSearchClusterRed - alert: OpenSearchClusterRed
expr: opensearch_cluster_health_status{color="red"} == 1 expr: elasticsearch_cluster_health_status{color="red"} == 1
for: 2m for: 2m
labels: labels:
severity: critical severity: critical
@@ -19,7 +19,7 @@ spec:
description: "OpenSearch cluster {{ $labels.cluster }} health status is red." description: "OpenSearch cluster {{ $labels.cluster }} health status is red."
- alert: OpenSearchClusterYellow - alert: OpenSearchClusterYellow
expr: opensearch_cluster_health_status{color="yellow"} == 1 expr: elasticsearch_cluster_health_status{color="yellow"} == 1
for: 10m for: 10m
labels: labels:
severity: warning severity: warning
@@ -28,10 +28,10 @@ spec:
description: "OpenSearch cluster {{ $labels.cluster }} health status is yellow." description: "OpenSearch cluster {{ $labels.cluster }} health status is yellow."
- alert: OpenSearchHeapHigh - alert: OpenSearchHeapHigh
expr: (opensearch_jvm_mem_heap_used_bytes / opensearch_jvm_mem_heap_max_bytes) > 0.85 expr: (elasticsearch_jvm_memory_used_bytes{area="heap"} / elasticsearch_jvm_memory_max_bytes{area="heap"}) > 0.85
for: 5m for: 5m
labels: labels:
severity: warning severity: warning
annotations: annotations:
summary: "OpenSearch JVM heap usage is high" summary: "OpenSearch JVM heap usage is high"
description: "OpenSearch node {{ $labels.node }} in {{ $labels.namespace }} heap usage is above 85%." description: "OpenSearch node {{ $labels.name }} in {{ $labels.namespace }} heap usage is above 85%."

View File

@@ -24,9 +24,6 @@ spec:
containers: containers:
- name: opensearch - name: opensearch
image: opensearchproject/opensearch:3 image: opensearchproject/opensearch:3
# OpenSearch 3.x has no maintained prometheus-exporter plugin.
# Metrics come from /_cluster/stats JSON API (scraped by dashboard queries).
# TODO: add opensearch-exporter sidecar for native Prometheus metrics.
ports: ports:
- name: http - name: http
containerPort: 9200 containerPort: 9200
@@ -58,6 +55,26 @@ spec:
volumeMounts: volumeMounts:
- name: data - name: data
mountPath: /usr/share/opensearch/data mountPath: /usr/share/opensearch/data
# Prometheus metrics exporter — scrapes OpenSearch REST APIs and
# exposes them as elasticsearch_* metrics on :9114/metrics.
- name: exporter
image: quay.io/prometheuscommunity/elasticsearch-exporter:v1.7.0
args:
- --es.uri=http://localhost:9200
- --es.all
- --es.indices
- --es.shards
- --collector.clustersettings
ports:
- name: metrics
containerPort: 9114
protocol: TCP
resources:
requests:
cpu: 5m
memory: 32Mi
limits:
memory: 64Mi
volumes: volumes:
- name: data - name: data
persistentVolumeClaim: persistentVolumeClaim:

View File

@@ -17,3 +17,7 @@ spec:
port: 9300 port: 9300
targetPort: 9300 targetPort: 9300
protocol: TCP protocol: TCP
- name: metrics
port: 9114
targetPort: 9114
protocol: TCP

View File

@@ -11,6 +11,5 @@ spec:
matchLabels: matchLabels:
app: opensearch app: opensearch
endpoints: endpoints:
- port: http - port: metrics
interval: 30s interval: 30s
path: /_prometheus/metrics