This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Grafana

DC1 monitoring dashboards backed by VictoriaMetrics with Vault sign-in

Grafana architecture showing browser access, Vault OIDC, and VictoriaMetricsGrafana architecture showing browser access, Vault OIDC, and VictoriaMetrics

Bazel renders the Mermaid source in light and dark themes.

One Fedora VM in DC1 runs Grafana from the Fedora package under systemd. Terraform provisions the XCP-ng guest through Xen Orchestra with two vCPUs, 4 GiB of RAM, and a persistent 20 GiB disk. Grafana stores its SQLite database at /var/lib/grafana/grafana.db. Ansible configures the guest, installs Grafana through the alwaldend.main.grafana role, and sets up Traefik. VictoriaMetrics scrapes Grafana’s native HTTPS metrics endpoint and Traefik’s separate Prometheus listener.

Open Grafana from the DC1 network with the Vault server CA trusted by your browser. Traefik serves Vault-issued HTTPS, redirects HTTP, and proxies to Grafana on loopback. The firewall allows administrative SSH from any routed source. Select Sign in with Vault to sign in as a member of global_admins. Those users become Grafana server administrators. The guest’s SELinux policy allows the Grafana process to connect to Vault’s OIDC API on TCP 8200.

From outside DC1, use the same hostname with a trusted ingress client certificate. Shared ingress verifies the guest’s Vault-issued certificate and forwards traffic through the dedicated dc1.grafana.alwaldend.com backend name. Grafana still requires application sign-in.

Manage the VictoriaMetrics data source and repository dashboards through the Grafana Terraform root.

  1. Review and apply the Grafana Vault AppRole, then reconcile shared memberships with //infra/vault/tf:tf.apply. Synchronize the AppRole identity and resource set using the Xen Orchestra workflow.

  2. Store the local recovery password and a separate stable Grafana encryption key in Vault. Generate both independently. The example reads protected files containing the values.

    bazel run //infra/grafana:vault.kv_put -- \
      alwaldend.com/vault1/approles/src_infra_grafana/config \
      admin_password=@"$grafana_password_file" secret_key=@"$grafana_secret_key_file"
    
  3. Confirm the address in the DNS declaration is available. Review the VM and DNS plans separately before applying them.

    bazel run //infra/grafana/tf_setup:tf_setup.plan
    bazel run //infra/grafana/tf_setup:tf_setup.apply
    bazel run //infra/grafana/dns:tf.plan
    bazel run //infra/grafana/dns:tf.apply
    
  4. Wait for cloud-init, verify the guest SSH host key out of band, and check that Vault resolves the DC1 DNS record. Deploy with bazel run //infra/grafana/ansible.

  5. With Traefik running, verify Vault can reach guest TCP 80 for ACME HTTP-01. Check the HTTPS certificate and sign in through Vault to verify the server administrator role.

  6. Once Grafana DNS and the guest firewall are ready, deploy shared ingress. Verify that ingress can reach the guest over HTTPS and that the public route requires a trusted client certificate.

  7. Reapply the VictoriaMetrics playbook and check that the Grafana proxy is up in the traefik_dc1 job.

When adding ingress to an existing Grafana VM, apply its AppRole and DNS changes and rerun the Grafana playbook before deploying shared ingress.

Grafana uses the local admin password only when initializing an empty database. Change an existing password through Grafana and update the recovery value in Vault. Keep the encryption key with the database backups to preserve access to encrypted data source settings.

1 - Grafana configuration

This Terraform root manages the VictoriaMetrics Prometheus data source and repository dashboards through the Grafana API. It uses its own Vault HTTP backend and requires DC1 access to the Grafana hostname.

Place dashboard JSON at dashboards/<section>/<project>/<dashboard>.json. For example, dashboards under dashboards/infra/ingress/ appear in Grafana under infra → ingress. Use a distinct, stable dashboard UID and the victoria-metrics Prometheus data source UID. The relative file path is the Terraform instance key. Preserve the UID and move the Terraform address when renaming a file. Folder IDs derive from repository paths.

The dashboard under infra → victoria_metrics renders every panel in VictoriaMetrics’ existing Monitoring overview. Its queries and layout come from the VMUI dashboard source.

  1. Apply the Grafana AppRole changes and deploy the Grafana Ansible playbook. The playbook enables nested folders and allows the Grafana process to reach the VictoriaMetrics HTTPS data source under SELinux.
  2. Review bazel run //infra/grafana/tf:tf.plan, then run bazel run //infra/grafana/tf:tf.apply. The Grafana AppRole supplies the existing Grafana local administrator password and the VictoriaMetrics Basic Auth credentials. Terraform stores the data source password in the protected backend state.
  3. Verify the data source and open the dashboards under infra. The Grafana dashboard requires the collector’s native grafana scrape job.

2 - Grafana Vault AppRole

This root owns the Grafana AppRole, DC1 DNS credential access, guest SSH host signing, Traefik’s ACME enrollment, and the application OIDC client. The OIDC client allows sign-in for global_admins and exposes its client credentials to the deployment AppRole. The AppRole also has read access to the VictoriaMetrics web credential used by the Grafana Terraform data source.

Provision the shared Vault mounts, administrator group, and OIDC scopes first. Review this root using bazel run //infra/grafana/approle:tf.plan. Apply the root before reconciling shared Vault memberships and the Xen Orchestra resource set. The Grafana runbook gives the deployment sequence.