Dashboard Setup

How to provision Grafana datasources and dashboards for the Sophonz infrastructure.

Sophonz uses file-based provisioning to register Grafana datasources and dashboards automatically. In v2, the Grafana Provisioning service dynamically generates and synchronizes dashboards based on Sophonz service and namespace metadata. This page explains the structure of the provisioning files and how to customize them.

Directory structure

Grafana provisioning files are mounted at the following paths inside the container.

/etc/grafana/provisioning/
├── dashboards/
│   ├── dashboards.yml                      # provisioning policy
│   ├── sophonz-service.json                # Web dashboard
│   ├── sophonz-service-ios.json            # iOS dashboard
│   └── sophonz-service-test-payload.json   # payload validation dashboard
└── datasources/
    └── datasources.yml                     # datasource definitions

Dashboard provisioning config

dashboards.yml defines how Grafana discovers and loads JSON files.

configs/grafana/provisioning/dashboards/dashboards.yml
apiVersion: 1
 
providers:
  - name: 'default'
    type: file
    updateIntervalSeconds: 10
    options:
      path: /etc/grafana/provisioning/dashboards
      foldersFromFilesStructure: true
  • updateIntervalSeconds: 10 — Grafana scans the directory every 10 seconds and picks up new or changed dashboards automatically.
  • foldersFromFilesStructure: true — Subdirectory names become Grafana folder names.

Adding a new dashboard

Copy a dashboard JSON file into the provisioning directory and Grafana imports it automatically.

cp my-dashboard.json /etc/grafana/provisioning/dashboards/

In Kubernetes, the Sophonz app writes JSON files directly to the shared-dashboards volume, which Grafana watches via the same mount point.

NOTE — Editing provisioned dashboards

Dashboards registered via file provisioning show a warning when you try to save edits in the Grafana UI. To make permanent changes, update the source JSON file instead.

Datasource configuration

datasources.yml defines the datasources Grafana loads on startup. Dynamic values such as the ClickHouse FQDN are interpolated at deploy time via Terraform templatefile() or an equivalent tool. The ${clickhouse_fqdn} placeholders in the actual config files are replaced with cluster-internal service addresses at deployment.

configs/grafana/provisioning/datasources/datasources.yml
apiVersion: 1
 
datasources:
  # ClickHouse (official plugin) — default datasource
  - name: ClickHouse
    type: grafana-clickhouse-datasource
    uid: clickhouse
    access: proxy
    url: http://clickhouse.your-cluster.svc.cluster.local:8123
    database: sophonz
    user: default
    isDefault: true
    jsonData:
      defaultDatabase: sophonz
      protocol: http
      host: clickhouse.your-cluster.svc.cluster.local
      port: 8123
      logs:
        defaultDatabase: sophonz
        defaultTable: sophonz_logs
        otelEnabled: true
        otelVersion: "latest"
      traces:
        defaultDatabase: sophonz
        defaultTable: sophonz_traces
        otelEnabled: true
        otelVersion: "latest"
 
  # ClickHouse (Altinity plugin) — supplementary datasource
  - name: ClickHouse-Altinity
    type: vertamedia-clickhouse-datasource
    uid: clickhouse-altinity
    access: proxy
    url: http://clickhouse.your-cluster.svc.cluster.local:8123
    database: sophonz
    user: default
    jsonData:
      defaultDatabase: sophonz
      usePOST: false
      addCorsHeader: true
 
  # Prometheus
  - name: Prometheus
    type: prometheus
    uid: prometheus
    access: proxy
    url: http://prometheus.your-cluster.svc.cluster.local:9090
    jsonData:
      httpMethod: POST
      timeInterval: "15s"
 
  # PostgreSQL
  - name: PostgreSQL
    type: postgres
    uid: postgres
    access: proxy
    url: postgresql.your-cluster.svc.cluster.local:5432
    database: sophonz
    user: sophonz
    jsonData:
      sslmode: disable
      postgresVersion: 1500
      timescaledb: false
    secureJsonData:
      password: your-db-password

CAUTION — Secrets management

Sensitive values such as secureJsonData.password should be injected via Kubernetes Secrets or a secrets manager. Do not store them as plain text in the config file.

Installing Grafana plugins

The ClickHouse datasources require third-party plugins. Set the GF_INSTALL_PLUGINS environment variable on the Grafana container.

env:
  - name: GF_INSTALL_PLUGINS
    value: "grafana-clickhouse-datasource,vertamedia-clickhouse-datasource"

When using the grafana/grafana:11.2.0 image, both plugins are downloaded and activated automatically on startup.

OAuth2 authentication (OIDC)

Grafana is configured for SSO via Generic OAuth (OIDC). The variable names below are Grafana's own, so they have to be used as written. Set the following environment variables on the Grafana container.

env:
  - name: GF_AUTH_GENERIC_OAUTH_ENABLED
    value: "true"
  - name: GF_AUTH_GENERIC_OAUTH_NAME
    value: "Sophonz"
  - name: GF_AUTH_GENERIC_OAUTH_CLIENT_ID
    value: "grafana"
  - name: GF_AUTH_GENERIC_OAUTH_SCOPES
    value: "openid email profile"
  - name: GF_AUTH_GENERIC_OAUTH_AUTH_URL
    value: "https://auth.example.com/realms/sophonz/protocol/openid-connect/auth"
  - name: GF_AUTH_GENERIC_OAUTH_TOKEN_URL
    value: "https://auth.example.com/realms/sophonz/protocol/openid-connect/token"
  - name: GF_AUTH_GENERIC_OAUTH_API_URL
    value: "https://auth.example.com/realms/sophonz/protocol/openid-connect/userinfo"
  - name: GF_AUTH_GENERIC_OAUTH_ALLOW_SIGN_UP
    value: "true"

Store GF_AUTH_GENERIC_OAUTH_CLIENT_SECRET in a Kubernetes Secret rather than inline in the Deployment manifest.

Deploying dashboards via Kubernetes ConfigMap

Without Terraform, use kubectl to create the ConfigMaps directly.

# Dashboard provisioning policy
kubectl create configmap grafana-dashboards \
  --from-file=dashboards.yml \
  -n observability
 
# Dashboard JSON files
kubectl create configmap grafana-dashboard-files \
  --from-file=sophonz-service.json \
  --from-file=sophonz-service-ios.json \
  --from-file=sophonz-service-test-payload.json \
  -n observability
 
# Datasource definitions
kubectl create configmap grafana-datasources \
  --from-file=datasources.yml \
  -n observability

Mount the ConfigMaps in the Grafana Pod under the appropriate provisioning paths.

volumeMounts:
  - name: grafana-datasources
    mountPath: /etc/grafana/provisioning/datasources
  - name: shared-dashboards
    mountPath: /etc/grafana/provisioning/dashboards

Dynamic dashboard sharing via shared volume

The Sophonz app can generate dashboard JSON at runtime and deliver it to Grafana through the shared-dashboards volume.

sophonz-app:/app/provisioned-dashboard  ←→  shared-dashboards  ←→  grafana:/etc/grafana/provisioning/dashboards

Any JSON file written to /app/provisioned-dashboard by the Sophonz app is detected by Grafana within 10 seconds and imported automatically — no restart or manual action required.

v2: Grafana Provisioning service

NOTE — v2 plan

The content below describes the v2 roadmap. The current deployment uses static file provisioning only.

In v2, a dedicated Grafana Provisioning microservice replaces static JSON files. It is responsible for:

  • Automatic sync — reads service and namespace metadata from the Sophonz Management service and creates or updates Grafana datasources, folders, and dashboards (POST /provision/sync).
  • Template dashboards — provides standard templates (service detail, RUM summary, error trends) and auto-creates a dashboard whenever a new service is registered.
  • Embed URL issuance — issues signed URLs so that individual Grafana panels can be embedded inside the Sophonz Dashboard (POST /dashboards/embed-url).
  • Change-triggered re-provisioning — re-synchronizes dashboards automatically when service metadata changes, following a GitOps-style pattern.

In on-premises deployments, the service can connect to a customer-managed Grafana instance and apply the same provisioning flow.