Skip to content

feat(monitoring): add Azure Monitor datasource for shared Postgres - #89

Merged
hakan-persson merged 3 commits into
mainfrom
feat/grafana-azure-monitor
Jul 26, 2026
Merged

feat(monitoring): add Azure Monitor datasource for shared Postgres#89
hakan-persson merged 3 commits into
mainfrom
feat/grafana-azure-monitor

Conversation

@hakan-persson

Copy link
Copy Markdown
Member

Summary

  • Adds Grafana Azure Monitor datasource so we can dashboard/alert on psql-j26apps-shared-sdc (shared Postgres flexible server) load. Currently there is no continuous monitoring of that server — this closes that gap.
  • New dedicated App Registration j26-grafana-azure-monitor-reader, scoped to Monitoring Reader on rg-j26apps-shared-sec only (read-only, resource-group scoped).
  • Client secret stored in kv-j26apps-shared-sdc (grafana-azure-monitor-* keys), delivered to the Grafana pod via the standard KV CSI pattern (secret-provider-class.yaml), never committed to git.
  • Grafana resolves the secret at runtime via envFromSecret + $__env{AZURE_CLIENT_SECRET} in the datasource's secureJsonData — standard Grafana provisioning mechanism for keeping secrets out of git.

Test plan

  • helm template verified the full render: CSI volume mount, envFrom secretRef, and datasource ConfigMap (picked up by kube-prometheus-stack's built-in datasource sidecar) all wire together correctly with consistent naming.
  • SecretProviderClass applied live to monitoring ns; confirmed CSI materialized grafana-azure-monitor-secrets with the correct client secret value.
  • Post-merge: confirm Grafana picks up the "Azure Monitor" datasource and can query psql-j26apps-shared-sdc metrics (cpu_percent, memory_percent, active_connections, cpu_credits_remaining, etc.) — follow-up dashboard/alerts PR to come.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 26, 2026 11:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an Azure Monitor datasource to the cluster’s Grafana (kube-prometheus-stack) so Grafana can query/alert on metrics from the shared Postgres Flexible Server (psql-j26apps-shared-sdc). Secrets are intended to be provided via the existing Azure Key Vault CSI pattern.

Changes:

  • Adds a SecretProviderClass in the monitoring namespace to materialize AZURE_CLIENT_SECRET for Grafana.
  • Provisions a new Grafana datasource (“Azure Monitor”) configured to use $__env{AZURE_CLIENT_SECRET}.
  • Mounts the Secrets Store CSI volume and wires envFromSecret so Grafana can resolve the client secret at runtime.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
k8s/infra-manifest/monitoring/secret-provider-class.yaml New SecretProviderClass to sync the Azure Monitor client secret from Key Vault into a Kubernetes Secret.
k8s/infra-manifest/monitoring/helm-values.yaml Adds Grafana Azure Monitor datasource provisioning plus secret env/CSI mount wiring.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread k8s/infra-manifest/monitoring/secret-provider-class.yaml
Comment thread k8s/infra-manifest/monitoring/secret-provider-class.yaml Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread k8s/argocd/infra-apps/monitoring.yaml
Wires Grafana to Azure Monitor via a dedicated service principal
(Monitoring Reader on rg-j26apps-shared-sec only) so we can dashboard
and alert on psql-j26apps-shared-sdc load. Client secret delivered via
KV CSI + envFromSecret, never stored in git.
- spec.source was dead: ArgoCD ignores it once spec.sources is set,
  so the SecretProviderClass would never have been GitOps-managed.
  Move it into sources[] as a proper git manifest source.
- Rename KV object to match the {app}-{env-var} naming convention
  (grafana-azure-monitor-azure-client-secret). Old KV secret
  soft-deleted; new one verified live via CSI sync.
…urce

Copilot flagged that the new git directory source over
k8s/infra-manifest/monitoring would also try to apply the Helm
values files (helm-values.yaml, loki-values.yaml, alloy-values.yaml)
as raw manifests, risking sync errors. Scope it to only
secret-provider-class.yaml via directory.include.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@hakan-persson
hakan-persson merged commit 5702c23 into main Jul 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants