Skip to content

Instantly share code, notes, and snippets.

@stand-sure
Created March 5, 2024 19:24
Show Gist options
  • Save stand-sure/94787feb49df3c151be51127f4a623c7 to your computer and use it in GitHub Desktop.
Save stand-sure/94787feb49df3c151be51127f4a623c7 to your computer and use it in GitHub Desktop.
Kube Stack Prometheus Grafana Datasource with Secrets

Grafana Datasource with Secrets

  1. Create a secret
  2. Add the secrets as environment variables to the Grafana section of the Prometheus yaml
  3. Use the environment values (secureJsonData)
apiVersion: v1
kind: ConfigMap
metadata:
name: clickhouse-datasources
namespace: monitoring
labels:
grafana_datasource: "1"
data:
clickhouse-datasources.yaml: |-
apiVersion: 1
datasources:
- name: otel-clickhouse-datasource
type: grafana-clickhouse-datasource
typeName: ClickHouse
typeLogoUrl: "/public/plugins/grafana-clickhouse-datasource/img/logo.svg"
access: proxy
jsonData:
defaultDatabase: otel
defaultTable: otel_traces
host: clickhouse-service-name.observability.svc
logs:
defaultDatabase: otel
defaultTable: otel_logs
otelEnabled: true
otelVersion: latest
port: 9000
protocol: native
tlsSkipVerify: false
traces:
defaultDatabase: otel
defaultTable: otel_traces
durationUnit: nanoseconds
otelEnabled: true
otelVersion: latest
username: "${CLICKHOUSE_USER}"
secureJsonData:
password: "${CLICKHOUSE_PASSWORD}"
apiVersion: v1
kind: Secret
metadata:
name: clickhouse-user-otel
namespace: observability
stringData:
username: "some user name"
password: "some password"
type: Opaque
grafana:
plugins:
- grafana-clickhouse-datasource
- grafana-clock-panel
- redis-datasource
envValueFrom:
CLICKHOUSE_USER:
secretKeyRef:
name: clickhouse-user-otel
key: userName
CLICKHOUSE_PASSWORD:
secretKeyRef:
name: clickhouse-user-otel
key: password
prometheus:
prometheusSpec:
thanos:
objectStorageConfig:
existingSecret:
key: thanos.yaml
name: thanos-objectstore-config
thanosService:
enabled: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment