Repository navigation
feat(chart): Add namespace filters for OTel Container Insights - #393
Conversation
| {{- fail (printf "otelContainerInsights.filters.%s.namespaces.%s must be a list" $signal $list) }} | ||
| {{- end }} | ||
| {{- range $entries }} | ||
| {{- if not (and (kindIs "string" .) (regexMatch "^([a-z0-9][-a-z0-9]*\\*?|\\*)$" .)) }} |
There was a problem hiding this comment.
^([a-z0-9][-a-z0-9]*\*?|\*)$ lets an exact name end in a hyphen, which no namespace can, if it's used as include rule, it wouldn't match anything
There was a problem hiding this comment.
Fixed: an exact name must now end in a letter or digit, so team- fails the render with a clear message. A prefix such as team-* still works.
7fcaceb to
ee8d7af
Compare
| - transform/cw_k8s_ci_v0_promote_node_name | ||
| {{- if include "otel-container-insights.metricsNamespaceFilterEnabled" . }} | ||
| - filter/cw_k8s_ci_v0_metrics_namespaces | ||
| {{- end }} |
There was a problem hiding this comment.
values.yaml lists EFA among the "workload metrics" filtered by namespace and says "Records without a Kubernetes namespace are never filtered."
helm-charts/charts/amazon-cloudwatch-observability/values.yaml
Lines 1263 to 1270 in 149e7b3
But efa_promote runs per datapoint and writes each card's namespace onto the resource the whole node shares, so the last card's namespace wins.
As a result, this filter judges every EFA card on the node by that one namespace. Cards used by pods in other namespaces, and cards used by no pod, are kept or dropped along with it. Was the single-namespace EFA attribution intentional? If not, splitting by pod with groupbyattrs the way Neuron does would fix both.
There was a problem hiding this comment.
Thanks, fixed. The EFA pipeline now groups datapoints by pod with groupbyattrs, as Neuron does, so each card keeps its own pod and namespace when the filter runs.
eebaed1 to
8381dec
Compare
|
Both now apply the namespace filter: |
8381dec to
e5ad3cb
Compare
…ent when its otelConfig changes
e5ad3cb to
79e2ec2
Compare
Description
Adds the top-level
otelFiltersblock with its first filter,otelFilters.namespaces. The filter has oneincludelist and oneexcludelist, and the OTel Container Insights metrics and logs share them. The chart also restarts the pods of an agent when the finalotelConfigof that agent changes.*, or*alone. An empty include list, or one that contains*, includes every namespace. Exclude wins over include. A duplicate entry renders once, and an entry cannot be in both lists. Records withoutk8s.namespace.namealways pass.filter/cw_k8s_ci_v0_metrics_namespacesruns in the kube-state-metrics, cAdvisor, kubelet stats, vLLM and Knative data plane pipelines, after the namespace promotion and beforek8sattributes.filter/cw_k8s_ci_v0_logs_namespacesruns in the application logs pipeline, beforek8sattributes.transform/cw_k8s_ci_v0_device_namespacesruns in the same place, with the same conditions. When the pod of a device is in a filtered namespace, it deletesk8s.pod.name,k8s.container.nameandk8s.namespace.namefrom the resource, and the rawpod,namespaceandcontainercopies from the DCGM datapoints. So the device keeps its metrics with its node attributes only, andk8sattributesfinds no pod for it. The Neuron runtime tag stays.groupbyattrs/cw_k8s_ci_v0_efamoves the pod, namespace and container of each card to one resource per pod, before the device transform. Onmainit runs only whenotelContainerInsights.enableDRACorrelationis true. This PR runs it always and removestransform/cw_k8s_ci_v0_efa_promote, which copied the pod of one card onto the resource of the whole node. When the group step runs first, as onmainby default,efa_promotefinds no pod keys on the datapoints and does nothing. The datapoints of a card without a pod keep the node resource.otelConfig. So the chart adds the pod annotationcloudwatch-agent/otel-config-sha256to each agent that has anotelConfig. Its value is the SHA-256 of the finalotelConfig, after the merge withagents[].otelConfig. When that configuration changes, the operator rolls the pods of that agent. The annotation joins thepodAnnotationsof the agent.cloudwatch-agent.modify-otel-configreturns unquoted YAML, so the hash covers the same text that the custom resource gets.templates/_otel-container-insights-filters.tpl, whichvalidate-flagscalls.helm installfails, with a message that names the setting, for a wrong shape or an unknown key underotelFilters(so a typo such asexcludesfails), an entry that is not a DNS-1123 label, an entry in both lists,otelContainerInsights.filters(with a pointer tootelFilters), andpodAnnotationsthat are not a map.Customer-visible:
otelFilters.namespacesis a new opt-in value. With default values and Container Insights off, the rendered agent configurations are the same as onmain. With Container Insights on, there are two changes. Thecloudwatch-agentandcloudwatch-agent-cluster-scraperagents get the restart annotation, so the first upgrade to this chart restarts their pods once. After that, every change to the finalotelConfigof an agent restarts its pods. Also, withotelContainerInsights.enableDRACorrelation=false, the EFA metrics of each card now carry the pod and namespace of the pod that uses that card, and a card without a pod carries none. Before, with that setting, every card on a node carried the pod of one card. With the default (true), the EFA metrics are the same as onmain. With a namespace filter, the GPU, Neuron and EFA metrics of a pod in a filtered namespace stay, without the pod, namespace and container attributes.Testing
tests/otel_ci_filters.sh(make helm-otel-ci-filters): 67 new cases, all pass. They cover the rendered processors and their place in every pipeline, the restart annotation and every validation error.helm-lint,helm-flag-matrix,helm-yaml-injection,helm-neuron-shape,helm-kserve-shape,helm-vllm-shape,helm-knative-shape,helm-otel-ci-filters,helm-availability-zoneandhelm-dcgm-metrics-csv.main: the same with Container Insights off. With it on, only the restart annotation changes, andtransform/cw_k8s_ci_v0_efa_promoteis gone from the EFA pipeline. A scratch render check (not committed) also coversotelContainerInsights.enableDRACorrelation=falseanddcgmExporter.enableDRACorrelation=false, with and without a namespace filter.k8sattributesadded none back.This is the first of three stacked PRs: this PR, then #394 (pod and node label filters), then #395 (metric name filters). aws/amazon-cloudwatch-agent-test#782 merges after all three.
PR Checklist
makepasses locally (build, unit tests, lint)