GoogleCloudPlatform / prometheus-engine

Google Cloud Managed Service for Prometheus libraries and manifests.
https://g.co/cloud/managedprometheus
Apache License 2.0
196 stars 92 forks source link

Add defaulting logic for OperatorConfig's external labels during collection reconcile #1160

Open pintohutch opened 1 month ago

pintohutch commented 1 month ago

Currently, the collectionReconciler uses either:

  1. The operator's --project-id, --location, and --cluster labels, or
  2. The OperatorConfig.collection.externalLabels argument for project_id, location, and cluster

to enforce the corresponding metric labels on exported time series to Cloud Monitoring, with a preference for (2), given they are not necessarily needed for the operator to function and are more directly exposed to end users.

However, we neither intercept CREATE calls to the OperatorConfig with our defaulting webhooks, nor do we in-memory default the OperatorConfig during the collection reconcile loop (e.g. when a new PodMonitoring is created).

Thus, we should add both webhook-based and reconcile-based defaulting to ensure a more consistent UX when understanding our relabeling.