OpenSearch metrics 을 Prometheus에서 가져오는 방법이다.
현재기준 OpenSearch 가 2.19.1 이 나왔는데 아직 플러그인은 2.17.1 이므로 버전을 맞춰주어야한다.
Git Issue 에 누가 상세히 설명해주어서 따라한다.(https://github.com/Aiven-Open/prometheus-exporter-plugin-for-opensearch/issues/330)
1. 플러그인 신규 버전 생성
우선 플러그인 git url에 접속한다
https://github.com/Aiven-Open/prometheus-exporter-plugin-for-opensearch
최신 소스를 다운받고 gradle.properties 파일의 version부분을 OpenSearch 버전과 맞춰준다
#group = org.opensearch.plugin.prometheus
# An actual version of plugin
#### 이 부분을 변경해준다. ####
version = 2.19.1.0
# Leave this property empty, it is assigned during the gradle build execution (yes, it is a hack! see issue #324)
opensearch_version =
# A version of OpenSearch cluster to run BWC tests against
BWCversion = 2.17.1
# A version of plugin to deploy to BWC clusters
BWCPluginVersion = 2.17.1.0
pluginName = prometheus-exporter
pluginClassname = org.opensearch.plugin.prometheus.PrometheusExporterPlugin
pluginDescription = Prometheus exporter plugin for OpenSearch
#github_token = secret
#github_owner = TBD
#github_repo = prometheus-exporter
그 후 빌드해주면 prometheus-exporter-2.19.1.0.zip 플러그인이 나타난다.
# 빌드
./gradlew clean build
# 빌드된 파일
./build/distributions/prometheus-exporter-2.19.1.0.zip
2. OpenSearch 및 ServiceMonitor 를 위한 role 배포
## ServiceMonitor에 사용될 패스워드
apiVersion: v1
kind: Secret
metadata:
name: opensearch-admin
namespace: logging
type: Opaque
data:
username: YWRtaW4=
password: c2luZ2xlTm9kZTEh
## 생성한 플러그인
kubectl create configmap opensearch-plugin --from-file prometheus-exporter-2.19.1.0.zi -n logging
## ClusterRole and Binding
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: opensearch-metrics
namespace: logging
rules:
- apiGroups: [""]
verbs: ["get", "list", "watch"]
resources: ["services", "endpoints", "pods"]
- nonResourceURLs: ["/_prometheus/metrics"]
verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRolebinding
metadata:
name: opensearch-metrics
namespace: logging
subjects:
- kind: ServiceAccount
namespace: monitor
name: prometheus-k8s
roleRef:
kind: ClusterRole
name: opensearch-metrics
apiGroup: rbac.authorization.k8s.io
## opensearch 및 prometheus plugin, ServiceMontior 설치
helm install opensearch-single opensearch/opensearch --namespace logging \
--set singleNode=true \
--set persistence.enabled=false \
--set-json 'extraEnvs=[{"name": "OPENSEARCH_INITIAL_ADMIN_PASSWORD", "value": "singleNode1!"}]' \
--set plugins.enabled=true \
--set plugins.installList[0]='file:/usr/share/opensearch/prometheus-export-2.19.1.0.zip' \
--set-json 'extraVolumes=[{"name": "plugin", "configMap": {"name": "opensearch-plugin"}}]' \
--set-json 'extraVolumeMounts=[{"mountPath": "/usr/share/opensearch/prometheus-export-2.19.1.0.zip", "name": "plugin", "subPath": "prometheus-exporter-2.19.1.0.zip"}]' \
--set serviceMonitor.enabled=true \
--set serviceMonitor.basicAuth.enabled=true \
--set serviceMonitor.basicAuth.existingSecret=opensearch-admin \
--set serviceMonitor.path='/_prometheus/metrics' \
--set serviceMonitor.scheme=https \
--set serviceMonitor.tlsConfig.insecureSkipVerify=true
'Develop > OpenSearch / FluentBit' 카테고리의 다른 글
OpenSearch Dashboards API Console Proxy (0) | 2025.03.13 |
---|---|
OpenSearch, OpenSearch Dashboard helm 설치 정리 (0) | 2025.03.06 |
OpenSearch SingleNode (0) | 2025.03.06 |
OpenSearch Operator Coordinator (0) | 2025.02.18 |
Fluent-Bit Systemd Logging (0) | 2025.02.18 |