Registry Mirror
Skip to content

Conversation

@ridhoq

@ridhoq Ridwan Hoq (ridhoq) commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Stack

Stacks on #2. The base is postgres-install, not main; this PR contains the monitoring commit and its review fixes. Merge #2 first, then rebase/retarget this PR onto main.

Summary

  • Add opt-in Azure Managed Prometheus and Standard Managed Grafana provisioning, including scoped reader/admin roles and AKS collection wiring. Monitoring stays disabled by default and is excluded from registry-only provisioning. Installs without monitoring send no Azure Monitor profile, so they leave the cluster's metrics setting as it is.
  • Enable upstream Substrate OTLP metrics through a pinned, non-root, metrics-only collector with bounded resources, scoped ingress, and Azure PodMonitors. Only the OTLP metrics endpoint is set, so logs and traces, including Envoy's, stay disabled.
  • Reconcile grouped Substrate/AKS and Azure dependency dashboards. PostgreSQL panels use native Azure Monitor metrics for the selected Flexible Server and its actual region; no SQL exporter or database credentials are required.
  • Verify ingestion through Grafana's authenticated backend before marking installation complete. Preserve named-installation settings, billing disclosures, ownership/retry guards, and the Grafana link in the final setup receipt.
  • Document costs, collection limits, troubleshooting, and destructive teardown. Monitoring serves routine operations as well as benchmark workloads; benchmark automation is outside this PR.

For a new installation:

bin/substrate-aks setup monitored --monitoring

Monitoring adds ongoing charges. Endpoints are publicly reachable and authenticated, the collector is a single in-memory replica, and teardown deletes the monitoring workspace and its data. This does not make the experimental installer production-ready.

Must fix

No blocking correctness issues found in the monitoring-only diff after reviewing configuration, infrastructure, lifecycle, upstream contracts, dashboard queries, tests, and docs. Rebased onto #2's current head (b154c62). As #2 does for database, records omit the monitoring section when monitoring is off. #2 no longer includes HorizonDB, so the rebase drops the HorizonDB text from docs/monitoring.md and adapts the monitoring tests to #2's installer API. The dashboard code's HorizonDB branch is unchanged and is now unreachable.

Consider

  • cmd/substrate-aks/setup_test.go:89-100: the receipt fixture supplies a simulated Grafana URL. TestSetupMonitoringReceipt checks line/workspace receipt behavior, but would not catch removal of the real runCommand result assignment. Direct coverage of that handoff would strengthen the regression; the wiring was reviewed by inspection.

Unverified

  • No fresh Azure installation was performed during this review. Earlier HorizonDB and Flexible Server monitoring smoke validation predates the latest named-installation/TUI rebases and is not current end-to-end acceptance.
  • Current live service availability, IAM propagation, and real managed ingestion still require an opt-in installation and its runtime acceptance checks.

Existing monitored installations

Installs made with an earlier build of this branch pick up the tracing fix in two steps: rerun bin/substrate-aks install NAME, which updates ate-otel-config, then run kubectl -n ate-system rollout restart deployment/atenet-router. Don't restart other components: the next ate-controller restart rolls each worker pool once through eviction, so let that happen in a quiet window. Records those builds wrote with monitoring off still carry a monitoring section, which builds without this PR reject.

Checks run

All passed on d8a901a:

  • make build verify test-unit test-contract bicep -- binary build, formatting, vet, module hygiene, the full race-enabled unit and TUI suite, infrastructure compilation, and the race-enabled integration selection in test-contract: pinned upstream, monitoring, managed PostgreSQL, image-check/publisher/Podman contracts; deployment-history query; managed network/vault scopes and database SKU; and the actual PostgreSQL bootstrap script in Docker.
  • make test-monitoring -- actual pinned OpenTelemetry collector pipeline in Docker.

make test-contract now evaluates the Bicep templates locally with az bicep snapshot, which needs Bicep CLI 0.41.2 or later (see CONTRIBUTING); no Azure sign-in is needed.

@aramase Anish Ramasekar (aramase) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One issue I think needs to change (inline on settings.yaml): monitoring mode turns on Envoy tracing toward a collector that only has a metrics pipeline. The other inline comments are non-blocking. Since this builds on #2, changes there may need a re-check here.

$patch: replace
{{ if .MonitoringEnabled }}
OTEL_SDK_DISABLED: "false"
OTEL_EXPORTER_OTLP_ENDPOINT: http://substrate-aks-otel.ate-system.svc.cluster.local:4317

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Setting OTEL_EXPORTER_OTLP_ENDPOINT in ate-otel-config also turns on Envoy tracing: atenet-router reads this ConfigMap through envFrom and defaults --otlp-collector-address to that variable (cmd/atenet/internal/router/cmd.go:108 at the pinned substrate commit; upstream notes this at manifests/ate-install/atenet-router.yaml:281), then configures HCM tracing with 1% sampling. OTEL_TRACES_EXPORTER=none only affects the Go SDK. The collector in deploy/monitoring.yaml has only a metrics pipeline, so the OTLP receiver doesn't register the trace service and every sampled span export fails. That contradicts "OTLP logs and traces stay disabled" in docs/monitoring.md:78 and deploy/README.md:23. Could monitoring mode pass --otlp-collector-address= to the router (upstream does the same for egress in atenet-egress.yaml) and extend TestPinnedUpstreamMonitoringContract to assert it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 7bb03eb. Monitoring now sets only OTEL_EXPORTER_OTLP_METRICS_ENDPOINT, so the router's --otlp-collector-address default is empty and Envoy tracing stays off without patching the router. TestPinnedUpstreamMonitoringContract now checks that no generic, traces or logs endpoint is set and that the router's args match upstream.

Comment thread infra/resources.bicep Outdated
dnsPrefix: clusterName
kubernetesVersion: kubernetesVersion
enableRBAC: true
azureMonitorProfile: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Non-blocking: azureMonitorProfile.metrics.enabled is now sent on every install, so a disabled install PUTs enabled: false where the base sent nothing. On a cluster where managed Prometheus was enabled outside the installer, a re-provision would turn it off. Could the block be emitted only when monitoring is enabled, with a conditional spread like the one at line 320?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in f1c0bbc: the profile is sent only when monitoring is enabled, so installs without monitoring leave the cluster's setting alone. A contract test evaluates the template both ways.

Comment thread infra/monitoring.bicep
}
}

resource grafanaAdmin 'Microsoft.Authorization/roleAssignments@2022-04-01' = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Non-blocking: the grafanaAdmin role assignment sets no principalType, unlike the asset publisher assignment in resources.bicep. A newly created service principal can hit PrincipalNotFound during replication; passing the same conditional principalType avoids that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 75286d0: the publisher's principal type is passed through and set on the Grafana admin assignment when it's known.

return fmt.Errorf("Azure Monitor-managed resource group %q remains for workspace %q, but the tagged installation resource group %q was not found; refusing target reuse or image-reference reset. Wait for any in-progress teardown to finish, then retry. If it persists, inspect Azure for incomplete teardown or changed ownership tags before reusing this configuration", group.Name, group.ManagedBy, a.Config.Azure.ResourceGroup)
}
if group.ManagedBy != "" {
return fmt.Errorf("resource group %q is managed by %q, which does not match configured AKS cluster %q; refusing to reuse this installation ID. Restore aks.clusterName and azure.resourceGroup to this installation's original values for management or teardown; use a new configuration for a separate installation", group.Name, group.ManagedBy, clusterID)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Non-blocking: if a monitoring-enabled install is later edited to monitoring.enabled=false, the existing MA_ managed group falls through to "managed by ... does not match configured AKS cluster", which points the operator at the wrong fix. inspectOwnedGroup has the right message, but guardTarget runs first. Could this detect a Monitor-account managedBy and report a monitoring-mode mismatch instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done in 19c2b85: with monitoring off, the installation's own Monitor-managed group now gets a monitoring-mode mismatch message. Foreign or malformed managers are still refused as before.

}
}

func transientGrafanaError(err error) bool {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Non-blocking, not verified live: transientGrafanaError doesn't retry a Grafana 400 or 500 from the datasource query endpoint. While the Grafana identity's Monitoring Data Reader assignment is still propagating, the query may surface as a 400 that wraps the upstream 403, and verifyMetrics would fail right away instead of waiting. Consider retrying query-level errors within the existing 10-minute budget.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Leaving this as is for now. I'd like to see how the propagation error actually surfaces on a fresh install before widening the retries, and I'll follow up then.

Provision opt-in managed monitoring with scoped Grafana access and a metrics-only OTLP collector.

Wire upstream telemetry and managed scrape targets, verify ingestion through Grafana, and provide grouped Substrate, AKS, storage and PostgreSQL dashboards.

Cover configuration, lifecycle, pinned upstream contracts and the actual collector pipeline, and document costs and operational limits.

Signed-off-by: Ridwan Hoq <943533+ridhoq@users.noreply.github.com>
The router uses OTEL_EXPORTER_OTLP_ENDPOINT as the default for Envoy's
trace collector, so setting it for metrics also turned on Envoy tracing
toward a collector that has only a metrics pipeline. Set
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT instead, with the same URL and
protocol. Control-plane components export metrics directly and workers
through atelet's relay.

Monitored source checkouts move to a new cache generation, so a checkout
prepared with the generic endpoint is fetched and adapted again.

Signed-off-by: Ridwan Hoq <943533+ridhoq@users.noreply.github.com>
…abled

The cluster template sent azureMonitorProfile.metrics.enabled on every
deployment, so a deployment with monitoring disabled explicitly asked
for enabled: false where earlier versions sent nothing. On a cluster
whose managed Prometheus was turned on outside the installer, that
request could turn it off.

Send the profile, with metrics enabled, only when monitoringEnabled is
true and omit it otherwise. The installer still refuses to switch
monitoring mode on an existing installation. The docs describe the
direct template behavior without promising how Azure treats an omitted
profile, which has not been verified.

A new contract test evaluates resources.bicep locally with
az bicep snapshot for both values.

Signed-off-by: Ridwan Hoq <943533+ridhoq@users.noreply.github.com>
…min role

The Grafana Admin role assignment in monitoring.bicep set no
principalType, unlike the asset publisher's storage assignment, so Azure
had to resolve the principal itself. A newly created service principal
can fail that lookup with PrincipalNotFound while it replicates.

Add an optional grafanaAdminPrincipalType parameter to the monitoring
module, with the same allowed values as the root templates and an
empty default that keeps the property out, and forward
assetPublisherPrincipalType to it from resources.bicep.

Signed-off-by: Ridwan Hoq <943533+ridhoq@users.noreply.github.com>
… managed group

If an installation provisioned with monitoring is later run with
monitoring.enabled=false, the Azure Monitor workspace's managed resource
group still carries the installation tag. The target guard runs before
the recorded-mode check and reported that the group's manager did not
match the configured AKS cluster, pointing at the cluster and resource
group settings instead of the monitoring setting.

When monitoring is disabled and a group is managed by a Monitor account
that is valid for the configured subscription and resource group,
refuse with a monitoring-mode mismatch and ask for the original
monitoring settings. The refusal itself is unchanged, and managers that
are foreign or malformed still get the existing message.

Signed-off-by: Ridwan Hoq <943533+ridhoq@users.noreply.github.com>
The monitoring template contracts evaluate the templates with
az bicep snapshot, which needs Bicep CLI 0.41.2 or later. List it with
the contract prerequisites, with a version check and the upgrade
command, and make the tests say so when the command is missing instead
of reporting only an exit status.

Signed-off-by: Ridwan Hoq <943533+ridhoq@users.noreply.github.com>
encoding/json ignores omitempty on struct fields, so every installation
record carried a monitoring section, including records with monitoring
off. Builds without managed monitoring reject unknown fields, so they
could no longer read those records. Use omitzero, as the database
section does, so only monitored installations need this build.

Signed-off-by: Ridwan Hoq <943533+ridhoq@users.noreply.github.com>
@ridhoq Ridwan Hoq (ridhoq) changed the title Add opt-in managed Prometheus and Grafana monitoring feat: add opt-in managed Prometheus and Grafana monitoring Nov 20, 2026

@aramase Anish Ramasekar (aramase) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two blocking error-path issues inline (install reported failed after it finished; status drops pods/PVCs without the PodMonitor API). Optional nits:

  • deploy/monitoring.yaml:94-95: the pinned upstream ate-system-observability policy allows any source on any port named metrics, so the ama-metrics-only rule doesn't restrict anything. Not a defect since upstream opens these on purpose, but renaming the port (e.g. otel-metrics) would make the "scoped ingress" claim in the PR body true; otherwise drop that claim.
  • internal/installer/monitoring.go:161-167: the data-source update matches only by uid, so a hand-made source with the same name fails with a 409 that isn't retried. Match by name too, or document the names as reserved.
  • docs/monitoring.md:89-92: when Grafana Admin goes to a group, say to sign in as a group member.
  • monitoring_dashboards.go:168-180: the HorizonDB branch is unreachable (database.go:59 accepts only Flexible Server); could go along with its synthetic test row.
  • source.go:55-61: the "Earlier builds also used -v3" history could come out of the comment.

Comment thread cmd/substrate-aks/main.go Outdated
dashboardURL, err := a.MonitoringDashboardURL(ctx)
if err != nil {
return err
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Install has already recorded deployed (cluster.go:425) when this calls MonitoringDashboardURL, which reads Azure again (ownedGroup plus the subscription deployment listing). A transient Azure error or a cancel here makes a finished install return an error, and guided setup (setup.go:537-560) then stops before the receipt or offers to rerun the whole install. Could the URL come from the infrastructure details Install already validated, so nothing after deployed can fail?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 1c21b4d. Install now returns the dashboard URL built from the infrastructure it validated before deploying, and the CLI prints that, so nothing runs after the deployed record; MonitoringDashboardURL is gone. TestInstallReturnsDashboardWithoutReadingAzureAfterDeployment scripts a full monitored install that ends at the deployed record, so any later Azure read fails it.

}
}
a.progress("Fetching Substrate pods and persistent volumes")
_, err = a.runKubectl(ctx, nil, true, "get", "pods,pvc", "--namespace=ate-system", "--output=wide")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When the podmonitors listing fails, this returns before the pod/PVC listing. That happens when install timed out waiting for the PodMonitor CRD (monitoring.go:63-70) after recording installing:, which is exactly when someone runs status, and also if the metrics add-on is disabled later. Could pods and PVCs always be listed, with the monitoring error reported separately?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 12aed65. status now always lists pods and PVCs. A failed deployments,podmonitors listing is kept as a separate "listing monitoring workloads" error and returned together with the pod/PVC result. TestStatusListsPodsWhenPodMonitorsAreUnavailable covers the missing PodMonitor API.

@aramase Anish Ramasekar (aramase) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Marking the two error-path issues from my earlier review as blocking; the other items there stay optional.

Comment thread cmd/substrate-aks/main.go Outdated
dashboardURL, err := a.MonitoringDashboardURL(ctx)
if err != nil {
return err
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Blocking: the dashboard URL lookup runs after deployed is recorded, so a transient Azure error or cancel here reports a finished install as failed (details in my earlier comment on this line).

}
}
a.progress("Fetching Substrate pods and persistent volumes")
_, err = a.runKubectl(ctx, nil, true, "get", "pods,pvc", "--namespace=ate-system", "--output=wide")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Blocking: status returns before listing pods and PVCs when the PodMonitor API is missing (details in my earlier comment on this line).

…zure read

install recorded the deployed phase and then read the infrastructure
again to print the dashboard URL, so a transient Azure error or a cancel
made a finished installation fail and stopped guided setup before its
receipt. Install now returns the URL from the infrastructure it
validated before deploying.

Signed-off-by: Ridwan Hoq <943533+ridhoq@users.noreply.github.com>
status returned before listing pods and PVCs when the PodMonitor API was
missing, which happens after install times out waiting for that API or
when the metrics add-on is disabled later. status now always lists pods
and PVCs and reports the monitoring listing failure alongside.

Signed-off-by: Ridwan Hoq <943533+ridhoq@users.noreply.github.com>
Upstream's ate-system observability policy admits any source on ports
named metrics, so the collector's ama-metrics-only ingress rule did not
restrict its application metrics port. The contract test now checks
that no collector scrape port is one upstream opens.

Signed-off-by: Ridwan Hoq <943533+ridhoq@users.noreply.github.com>
Managed PostgreSQL is always a Flexible Server, so the HorizonDB panels
and their synthetic test rows could not be reached.

Signed-off-by: Ridwan Hoq <943533+ridhoq@users.noreply.github.com>
Document that the installer's data-source names are reserved because it
matches its data sources by UID, say to sign in as a group member when
the Grafana admin is a group, and drop cache-generation history from a
source comment.

Signed-off-by: Ridwan Hoq <943533+ridhoq@users.noreply.github.com>
@ridhoq

Copy link
Copy Markdown
Member Author

Thanks, all the nits are taken. 71166af renames the collector port to otel-metrics, and the contract test now fails if a collector scrape port is one upstream's observability policy opens. b62246e drops the HorizonDB branch and its test rows. 0f6758f documents the two data-source names as reserved (keeping uid matching), says to sign in as a group member, and drops the -v3 history.

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