diff --git a/base/data/kustomization.yaml b/base/data/kustomization.yaml index f0e900a..5da44ce 100644 --- a/base/data/kustomization.yaml +++ b/base/data/kustomization.yaml @@ -12,9 +12,10 @@ resources: - opensearch-service.yaml - opensearch-pvc.yaml - barman-vault-secret.yaml - # opensearch-servicemonitor.yaml removed — OpenSearch 3.x has no prometheus-exporter plugin. - # TODO: add opensearch-exporter sidecar for Prometheus metrics. + - opensearch-servicemonitor.yaml - opensearch-alertrules.yaml + - cnpg-podmonitor.yaml + - openbao-servicemonitor.yaml - postgres-alertrules.yaml - openbao-alertrules.yaml - searxng-deployment.yaml diff --git a/base/data/opensearch-alertrules.yaml b/base/data/opensearch-alertrules.yaml index ded8dbf..455ee86 100644 --- a/base/data/opensearch-alertrules.yaml +++ b/base/data/opensearch-alertrules.yaml @@ -10,7 +10,7 @@ spec: - name: opensearch rules: - alert: OpenSearchClusterRed - expr: opensearch_cluster_health_status{color="red"} == 1 + expr: elasticsearch_cluster_health_status{color="red"} == 1 for: 2m labels: severity: critical @@ -19,7 +19,7 @@ spec: description: "OpenSearch cluster {{ $labels.cluster }} health status is red." - alert: OpenSearchClusterYellow - expr: opensearch_cluster_health_status{color="yellow"} == 1 + expr: elasticsearch_cluster_health_status{color="yellow"} == 1 for: 10m labels: severity: warning @@ -28,10 +28,10 @@ spec: description: "OpenSearch cluster {{ $labels.cluster }} health status is yellow." - 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 labels: severity: warning annotations: 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%." diff --git a/base/data/opensearch-deployment.yaml b/base/data/opensearch-deployment.yaml index 0a065c1..210a218 100644 --- a/base/data/opensearch-deployment.yaml +++ b/base/data/opensearch-deployment.yaml @@ -24,9 +24,6 @@ spec: containers: - name: opensearch 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: - name: http containerPort: 9200 @@ -58,6 +55,26 @@ spec: volumeMounts: - name: 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: - name: data persistentVolumeClaim: diff --git a/base/data/opensearch-service.yaml b/base/data/opensearch-service.yaml index 62b18a3..1069e84 100644 --- a/base/data/opensearch-service.yaml +++ b/base/data/opensearch-service.yaml @@ -17,3 +17,7 @@ spec: port: 9300 targetPort: 9300 protocol: TCP + - name: metrics + port: 9114 + targetPort: 9114 + protocol: TCP diff --git a/base/data/opensearch-servicemonitor.yaml b/base/data/opensearch-servicemonitor.yaml index d3f982d..1616e9f 100644 --- a/base/data/opensearch-servicemonitor.yaml +++ b/base/data/opensearch-servicemonitor.yaml @@ -11,6 +11,5 @@ spec: matchLabels: app: opensearch endpoints: - - port: http + - port: metrics interval: 30s - path: /_prometheus/metrics