-
Notifications
You must be signed in to change notification settings - Fork 28
ROSAENG-66259: Adding a billing prometheus #784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Makdaam
wants to merge
2
commits into
openshift-online:main
Choose a base branch
from
Makdaam:ROSAENG-66259
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,4 @@ sla: | |
| hcpAvailability: | ||
| # 99.95% availability target — 0.05% error budget over 30 days | ||
| target: 0.9995 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| apiVersion: v2 | ||
| name: billing-prometheus | ||
| description: Minimal Prometheus that federates billing metrics from Thanos and remote-writes to Telemeter | ||
| type: application | ||
| version: 0.1.0 | ||
| home: https://github.com/openshift-online/rosa-hyperfleet | ||
| maintainers: | ||
| - name: ROSA HyperFleet Team |
23 changes: 23 additions & 0 deletions
23
argocd/config/regional-cluster/billing-prometheus/templates/additional-scrape-config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| {{- if .Values.billing.telemeterUrl }} | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: billing-additional-scrape | ||
| namespace: billing-prometheus | ||
| type: Opaque | ||
| stringData: | ||
| scrape-config.yaml: | | ||
| - job_name: thanos-federate | ||
| scrape_interval: {{ .Values.billing.scrapeInterval }} | ||
| scrape_timeout: 30s | ||
| honor_labels: true | ||
| metrics_path: /federate | ||
| params: | ||
| match[]: | ||
| {{- range .Values.billing.metricAllowList }} | ||
| - '{{ printf "{__name__=%q}" . }}' | ||
| {{- end }} | ||
| static_configs: | ||
| - targets: | ||
| - {{ .Values.billing.thanosQueryAddress }} | ||
| {{- end }} |
47 changes: 47 additions & 0 deletions
47
argocd/config/regional-cluster/billing-prometheus/templates/externalsecret.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| {{- if .Values.billing.telemeterUrl }} | ||
| {{- if not (has .Values.billing.authType (list "bearer" "oauth2")) }} | ||
| {{- fail (printf "billing.authType must be \"bearer\" or \"oauth2\", got: %q" .Values.billing.authType) }} | ||
| {{- end }} | ||
| apiVersion: external-secrets.io/v1 | ||
| kind: ExternalSecret | ||
| metadata: | ||
| {{- if eq .Values.billing.authType "oauth2" }} | ||
| name: {{ .Values.billing.oauth2.credentialsSecretName }} | ||
| {{- else }} | ||
| name: {{ .Values.billing.tokenSecretName }} | ||
| {{- end }} | ||
| namespace: billing-prometheus | ||
| annotations: | ||
| # ExternalSecret CRD may not exist yet when ArgoCD dry-runs this resource | ||
| argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true | ||
| # Apply before the Prometheus CR (wave 0) so the Secret exists before Prometheus starts. | ||
| argocd.argoproj.io/sync-wave: "-1" | ||
| spec: | ||
| refreshInterval: 1h | ||
| secretStoreRef: | ||
| name: aws-secrets-manager | ||
| kind: ClusterSecretStore | ||
| target: | ||
| {{- if eq .Values.billing.authType "oauth2" }} | ||
| name: {{ .Values.billing.oauth2.credentialsSecretName }} | ||
| {{- else }} | ||
| name: {{ .Values.billing.tokenSecretName }} | ||
| {{- end }} | ||
| creationPolicy: Owner | ||
| data: | ||
| {{- if eq .Values.billing.authType "oauth2" }} | ||
| - secretKey: client_id | ||
| remoteRef: | ||
| key: {{ .Values.global.cluster_name }}-telemeter-client | ||
| property: client_id | ||
| - secretKey: client_secret | ||
| remoteRef: | ||
| key: {{ .Values.global.cluster_name }}-telemeter-client | ||
| property: client_secret | ||
| {{- else }} | ||
| - secretKey: {{ .Values.billing.tokenSecretKey }} | ||
| remoteRef: | ||
| key: {{ .Values.global.cluster_name }}-telemeter-client | ||
| property: token | ||
| {{- end }} | ||
| {{- end }} |
8 changes: 8 additions & 0 deletions
8
argocd/config/regional-cluster/billing-prometheus/templates/namespace.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| {{- if .Values.billing.telemeterUrl }} | ||
| apiVersion: v1 | ||
| kind: Namespace | ||
| metadata: | ||
| name: billing-prometheus | ||
| labels: | ||
| kubernetes.io/metadata.name: billing-prometheus | ||
| {{- end }} |
73 changes: 73 additions & 0 deletions
73
argocd/config/regional-cluster/billing-prometheus/templates/prometheus.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| {{- if .Values.billing.telemeterUrl }} | ||
| {{- if not (has .Values.billing.authType (list "bearer" "oauth2")) }} | ||
| {{- fail (printf "billing.authType must be \"bearer\" or \"oauth2\", got: %q" .Values.billing.authType) }} | ||
| {{- end }} | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: Prometheus | ||
| metadata: | ||
| name: billing | ||
| namespace: billing-prometheus | ||
| annotations: | ||
| # Prometheus CRD may not exist yet when ArgoCD dry-runs this resource | ||
| argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true | ||
| spec: | ||
| replicas: 1 | ||
| # Short retention — this is a pass-through forwarder, not long-term storage. | ||
| retention: 2h | ||
| serviceAccountName: billing-prometheus | ||
|
|
||
| # Disable all automatic discovery; only the additionalScrapeConfigs job runs. | ||
| serviceMonitorSelector: {} | ||
| serviceMonitorNamespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: billing-prometheus | ||
| podMonitorSelector: {} | ||
| podMonitorNamespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: billing-prometheus | ||
| ruleSelector: {} | ||
| ruleNamespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: billing-prometheus | ||
|
|
||
| additionalScrapeConfigs: | ||
| name: billing-additional-scrape | ||
| key: scrape-config.yaml | ||
|
|
||
| remoteWrite: | ||
| - url: {{ .Values.billing.telemeterUrl | quote }} | ||
| {{- if eq .Values.billing.authType "oauth2" }} | ||
| oauth2: | ||
| clientId: | ||
| secret: | ||
| name: {{ .Values.billing.oauth2.credentialsSecretName }} | ||
| key: client_id | ||
| clientSecret: | ||
| name: {{ .Values.billing.oauth2.credentialsSecretName }} | ||
| key: client_secret | ||
| tokenUrl: {{ .Values.billing.oauth2.tokenUrl | quote }} | ||
| scopes: | ||
| {{- toYaml .Values.billing.oauth2.scopes | nindent 10 }} | ||
| {{- else }} | ||
| authorization: | ||
| type: Bearer | ||
| credentials: | ||
| name: {{ .Values.billing.tokenSecretName }} | ||
| key: {{ .Values.billing.tokenSecretKey }} | ||
| {{- end }} | ||
| # Forward only billing metrics — drop everything else before sending. | ||
| writeRelabelConfigs: | ||
| - sourceLabels: [__name__] | ||
| regex: {{ .Values.billing.metricAllowList | join "|" | quote }} | ||
| action: keep | ||
|
|
||
| resources: | ||
| requests: | ||
| cpu: 50m | ||
| memory: 256Mi | ||
| limits: | ||
| memory: 512Mi | ||
|
|
||
| # No persistent storage needed — short retention, pass-through only. | ||
| storage: {} | ||
| {{- end }} |
7 changes: 7 additions & 0 deletions
7
argocd/config/regional-cluster/billing-prometheus/templates/serviceaccount.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| {{- if .Values.billing.telemeterUrl }} | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
| metadata: | ||
| name: billing-prometheus | ||
| namespace: billing-prometheus | ||
| {{- end }} |
35 changes: 35 additions & 0 deletions
35
argocd/config/regional-cluster/billing-prometheus/values.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # Injected by ApplicationSet at runtime — defaults here for helm lint only | ||
| global: | ||
| cluster_name: "" | ||
| aws_region: "" | ||
|
|
||
| billing: | ||
| # Telemeter remote-write endpoint. Set per environment in argocd-values-regional-cluster.yaml. | ||
| telemeterUrl: "" | ||
|
|
||
| # Authentication method for Telemeter remote-write: "bearer" or "oauth2". | ||
| authType: bearer | ||
|
|
||
| # Bearer token auth (authType: bearer). | ||
| # Secret name and key must match the ExternalSecret target below. | ||
| tokenSecretName: hypershift-telemeter-client | ||
| tokenSecretKey: token | ||
|
|
||
| # OAuth2 auth (authType: oauth2). | ||
| oauth2: | ||
| tokenUrl: "https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token" | ||
| # Secret created by ExternalSecret holding client_id and client_secret. | ||
| credentialsSecretName: telemeter-oauth-credentials | ||
| scopes: | ||
| - openid | ||
|
|
||
| # Metrics forwarded to Telemeter (regex applied to __name__). | ||
| # Only matched metrics are remote-written; everything else is dropped. | ||
| metricAllowList: | ||
| - hypershift_cluster_vcpus | ||
|
|
||
| # Thanos Query Frontend in-cluster address. Port 9090 served by thanos-operator. | ||
| thanosQueryAddress: "thanos-query-frontend-thanos-query.thanos:9090" | ||
|
|
||
| # Prometheus scrape / evaluation interval for the billing job. | ||
| scrapeInterval: 1m |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Replace the enabled loopback placeholder in all ephemeral configuration sources.
The non-empty URL enables billing Prometheus, but
127.0.0.99is the Prometheus pod's loopback address. Remote write cannot reach Telemeter.config/ephemeral/defaults.yaml#L33-L33: Settelemeter_urlto the real receiver URL, or set it to"".deploy/ephemeral/us-east-1/_merged_config.yaml#L91-L91: Do not render the loopback placeholder into the merged configuration.deploy/ephemeral/us-east-1/argocd-values-regional-cluster.yaml#L14-L14: Do not override the disabled state with the loopback URL.📍 Affects 3 files
config/ephemeral/defaults.yaml#L33-L33(this comment)deploy/ephemeral/us-east-1/_merged_config.yaml#L91-L91deploy/ephemeral/us-east-1/argocd-values-regional-cluster.yaml#L14-L14🤖 Prompt for AI Agents