Skip to content

Commit 8b18b6e

Browse files
committed
feat: Append existing Pod labels to all Pod related metrics
1 parent 89c1bc3 commit 8b18b6e

File tree

7 files changed

+255
-166
lines changed

7 files changed

+255
-166
lines changed

docs/cli-arguments.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Flags:
5656
--metric-annotations-allowlist string Comma-separated list of Kubernetes annotations keys that will be used in the resource' labels metric. By default the metric contains only name and namespace labels. To include additional annotations provide a list of resource names in their plural form and Kubernetes annotation keys you would like to allow for them (Example: '=namespaces=[kubernetes.io/team,...],pods=[kubernetes.io/team],...)'. A single '*' can be provided per resource instead to allow any annotations, but that has severe performance implications (Example: '=pods=[*]').
5757
--metric-denylist string Comma-separated list of metrics not to be enabled. This list comprises of exact metric names and/or regex patterns. The allowlist and denylist are mutually exclusive.
5858
--metric-labels-allowlist string Comma-separated list of additional Kubernetes label keys that will be used in the resource' labels metric. By default the metric contains only name and namespace labels. To include additional labels provide a list of resource names in their plural form and Kubernetes label keys you would like to allow for them (Example: '=namespaces=[k8s-label-1,k8s-label-n,...],pods=[app],...)'. A single '*' can be provided per resource instead to allow any labels, but that has severe performance implications (Example: '=pods=[*]'). Additionally, an asterisk (*) can be provided as a key, which will resolve to all resources, i.e., assuming '--resources=deployments,pods', '=*=[*]' will resolve to '=deployments=[*],pods=[*]'.
59+
--metric-labels-append string Comma-separated list of additional Kubernetes label keys that will be added with their corresponding values to all metrics. By default the metric contains only name and namespace labels. Use of regex is supported (Example: '=regex=meta.example.com/(.*),product').
5960
--metric-opt-in-list string Comma-separated list of metrics which are opt-in and not enabled by default. This is in addition to the metric allow- and denylists
6061
--namespaces string Comma-separated list of namespaces to be enabled. Defaults to ""
6162
--namespaces-denylist string Comma-separated list of namespaces not to be enabled. If namespaces and namespaces-denylist are both set, only namespaces that are excluded in namespaces-denylist will be used.

internal/store/builder.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ type Builder struct {
8585
buildCustomResourceStoresFunc ksmtypes.BuildCustomResourceStoresFunc
8686
allowAnnotationsList map[string][]string
8787
allowLabelsList map[string][]string
88+
appendLabelsList string
8889
useAPIServerCache bool
8990
utilOptions *options.Options
9091
}
@@ -455,7 +456,8 @@ func (b *Builder) buildStorageClassStores() []cache.Store {
455456
}
456457

457458
func (b *Builder) buildPodStores() []cache.Store {
458-
return b.buildStoresFunc(podMetricFamilies(b.allowAnnotationsList["pods"], b.allowLabelsList["pods"]), &v1.Pod{}, createPodListWatch, b.useAPIServerCache)
459+
b.appendLabelsList = b.utilOptions.LabelsAppend
460+
return b.buildStoresFunc(podMetricFamilies(b.allowAnnotationsList["pods"], b.allowLabelsList["pods"], b.appendLabelsList), &v1.Pod{}, createPodListWatch, b.useAPIServerCache)
459461
}
460462

461463
func (b *Builder) buildCsrStores() []cache.Store {

0 commit comments

Comments
 (0)