-
Notifications
You must be signed in to change notification settings - Fork 47
[amazon-cloudwatch-observability] refactor: single-switch SM/PM scraping under otelContainerInsights.prometheusScrape #332
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
base: main
Are you sure you want to change the base?
Changes from all commits
3e61e2e
b721ec3
0222e9f
a51dc39
072635b
3e51214
48e8330
32b6ae5
ee2df6e
cd3fb5e
7911c6c
8bf3d4e
dee02ff
e753a60
7dd2d8d
1a46b3f
7bfede6
d57f318
d8a49d3
c626240
028a408
e61d4eb
530c019
6d95450
e032f1a
ef3715b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,33 @@ Expand the name of the chart. | |
| {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
| {{- end }} | ||
|
|
||
| {{/* | ||
| Whether to bundle the community ServiceMonitor/PodMonitor CRDs. Honours | ||
| .Values.otelContainerInsights.prometheusScrape.crds.install: | ||
| "always" => true; "never" => empty; | ||
| "auto" (default) => true only when otelContainerInsights.enabled AND | ||
| otelContainerInsights.prometheusScrape.enabled are both true. | ||
| Returns the string "true" when CRDs should be rendered, empty otherwise. | ||
| */}} | ||
| {{- define "amazon-cloudwatch-observability.prometheusCRDsEnabled" -}} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| {{- $install := (dig "prometheusScrape" "crds" "install" "auto" .Values.otelContainerInsights) -}} | ||
| {{- /* Back-compat: honor the legacy top-level prometheusCRDs.install if set (deprecated). */ -}} | ||
| {{- if hasKey .Values "prometheusCRDs" -}} | ||
| {{- $install = (dig "install" $install .Values.prometheusCRDs) -}} | ||
| {{- end -}} | ||
| {{- $scrapeEnabled := (dig "prometheusScrape" "enabled" true .Values.otelContainerInsights) -}} | ||
| {{- if eq $install "always" -}} | ||
| true | ||
| {{- else if eq $install "never" -}} | ||
| {{- else if eq $install "auto" -}} | ||
| {{- if and .Values.otelContainerInsights.enabled $scrapeEnabled -}} | ||
| true | ||
| {{- end -}} | ||
| {{- else -}} | ||
| {{- fail (printf "prometheusCRDs.install must be one of \"auto\", \"always\", or \"never\", got: %s" $install) -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{- define "amazon-cloudwatch-observability.common.tolerations" -}} | ||
| {{- $tolerations := .context.Values.tolerations }} | ||
| {{- if .component }} | ||
|
|
@@ -191,6 +218,56 @@ Logic: | |
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Returns "true" when otelContainerInsights-driven ServiceMonitor/PodMonitor scraping | ||
| applies to the given agent. True when otelContainerInsights is enabled, the agent is | ||
| the configured targetAgent, and at least one of serviceMonitor/podMonitor is enabled. | ||
| Accepts a dict with "agentName" (string) and "context" (root context $). | ||
| */}} | ||
| {{- define "cloudwatch-agent.otelCIScrapeEnabled" -}} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| {{- $ctx := .context -}} | ||
| {{- $agentName := .agentName -}} | ||
| {{- if and $ctx.Values.otelContainerInsights.enabled (eq $agentName $ctx.Values.otelContainerInsights.targetAgent) (dig "prometheusScrape" "enabled" true $ctx.Values.otelContainerInsights) -}} | ||
| true | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Whether ServiceMonitor / PodMonitor discovery is enabled. Honors the legacy | ||
| otelContainerInsights.serviceMonitor.enabled / .podMonitor.enabled if set | ||
| (deprecated), otherwise otelContainerInsights.prometheusScrape.<monitor>.enabled | ||
| (default true). Return "true" when enabled, empty otherwise. | ||
| */}} | ||
| {{- define "cloudwatch-agent.serviceMonitorEnabled" -}} | ||
| {{- $v := dig "prometheusScrape" "serviceMonitor" "enabled" true .Values.otelContainerInsights -}} | ||
| {{- if hasKey .Values.otelContainerInsights "serviceMonitor" -}} | ||
| {{- $v = dig "serviceMonitor" "enabled" $v .Values.otelContainerInsights -}} | ||
| {{- end -}} | ||
| {{- if $v -}}true{{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{- define "cloudwatch-agent.podMonitorEnabled" -}} | ||
| {{- $v := dig "prometheusScrape" "podMonitor" "enabled" true .Values.otelContainerInsights -}} | ||
| {{- if hasKey .Values.otelContainerInsights "podMonitor" -}} | ||
| {{- $v = dig "podMonitor" "enabled" $v .Values.otelContainerInsights -}} | ||
| {{- end -}} | ||
| {{- if $v -}}true{{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Reject a contradictory scraping config. prometheusScrape.enabled=true with BOTH | ||
| ServiceMonitor and PodMonitor discovery disabled would render an idle Target Allocator | ||
| (and bundle CRDs) that discovers nothing. Fail loudly rather than ship a no-op path. | ||
| Invoked from an always-rendered template so it runs regardless of which agents render. | ||
| */}} | ||
| {{- define "cloudwatch-agent.validatePrometheusScrape" -}} | ||
| {{- if and .Values.otelContainerInsights.enabled (dig "prometheusScrape" "enabled" true .Values.otelContainerInsights) -}} | ||
| {{- if and (ne (include "cloudwatch-agent.serviceMonitorEnabled" .) "true") (ne (include "cloudwatch-agent.podMonitorEnabled" .) "true") -}} | ||
| {{- fail "otelContainerInsights.prometheusScrape.enabled=true requires at least one of prometheusScrape.serviceMonitor.enabled or prometheusScrape.podMonitor.enabled to be true; enable one, or set prometheusScrape.enabled=false" -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
| {{- end -}} | ||
|
|
||
| {{/* | ||
| Helper function to modify cloudwatch-agent config | ||
| */}} | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
allocationStrategygainsper-nodeonly in thecrds/copy, which Helm doesn't touch on upgrade, so upgrading a release whose CRD predates the enum makes the API server reject the renderedper-node. Could we move this CRD intotemplates/and gate it like the bundled monitor CRDs?