ServiceMonitor for elastic cluster with operator
Good day i already installed prometheus exporter plugin while deploy and elastic with operator. now i stuck on how deploy a servicemonitor to export target to prometheus ` apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: name: elastic-cluster #namespace: monitoring spec: endpoints:
- interval: 20s
path: "/_prometheus/metrics"
port: https
scheme: https
tlsConfig:
insecureSkipVerify: true
basicAuth:
password:
name: secrets-values
key: basic_auth_password
username:
name: secrets-values key: basic_auth_user namespaceSelector: matchNames: - elastic-cluster selector: matchLabels: common.k8s.elastic.co/type: elasticsearch elasticsearch.k8s.elastic.co/cluster-name: elastic-cluster`
maybe someone tell how to deploy the password and the user of elastic to service monitor? dev tool show that plugin installed elastic-cluster-es-node-1 prometheus-exporter 7.17.0.0 elastic-cluster-es-coordinator-0 prometheus-exporter 7.17.0.0 elastic-cluster-es-node-0 prometheus-exporter 7.17.0.0 elastic-cluster-es-node-2 prometheus-exporter 7.17.0.0 elastic-cluster-es-coordinator-1 prometheus-exporter 7.17.0.0
Did you create "secrets-values" already ? you need create "secrets-values" first
be like
apiVersion: v1
kind: Secret
metadata:
name: secrets-values
data:
username: $(echo -n "${USERNAME}" | base64)
password: $(echo -n "${PASSWORD}" | base64)
The service monitor does not need the secrets for elasticsearch. The service monitor is for prometheus to find the exporter which will not have the same auth as elasticsearch. You want the deployment for the elasticsearch exporter to have the secrets for the elasticsearch cluster plugged into the environment variables.