Skip to content
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

[nr-k8s-otel-collector] Honor the LowDataMode toogle from the common-library #1472

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/nr-k8s-otel-collector/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.7.6
version: 0.7.7

dependencies:
- name: common-library
Expand Down
2 changes: 1 addition & 1 deletion charts/nr-k8s-otel-collector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ daemonset:
| kube-state-metrics.prometheusScrape | bool | `false` | Disable prometheus from auto-discovering KSM and potentially scraping duplicated data |
| labels | object | `{}` | Additional labels for chart objects |
| licenseKey | string | `""` | This set this license key to use. Can be configured also with `global.licenseKey` |
| lowDataMode | bool | `false` | Send only the [metrics required](https://github.com/newrelic/helm-charts/tree/master/charts/nr-k8s-otel-collector/docs/metrics-lowDataMode.md) to light up the NR kubernetes UI, this agent defaults to setting lowDataMode true, but if this setting is unset, lowDataMode will be set to false |
| lowDataMode | bool | `true` | Send only the [metrics required](https://github.com/newrelic/helm-charts/tree/master/charts/nr-k8s-otel-collector/docs/metrics-lowDataMode.md) to light up the NR kubernetes UI, this agent defaults to setting lowDataMode true, but if this setting is unset, lowDataMode will be set to false |
| nodeSelector | object | `{}` | Sets all pods' node selector. Can be configured also with `global.nodeSelector` |
| nrStaging | bool | `false` | Send the metrics to the staging backend. Requires a valid staging license key. Can be configured also with `global.nrStaging` |
| podLabels | object | `{}` | Additional labels for chart pods |
Expand Down
27 changes: 27 additions & 0 deletions charts/nr-k8s-otel-collector/templates/_low_data_mode.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- /*
This helper detect if the user set a value for the LowDataMode toggle and use it or defaults to `true`.
*/ -}}
{{- define "nrKubernetesOtel.lowDataMode" -}}
{{- $userSetAValue := false -}}
{{- $lowDataMode := "" -}}

{{- $global := index .Values "global" | default dict -}}
{{- if get $global "lowDataMode" | kindIs "bool" -}}
{{- $userSetAValue = true -}}
{{- $lowDataMode = $global.lowDataMode -}}
{{- end -}}

{{- if (get .Values "lowDataMode" | kindIs "bool") -}}
{{- $userSetAValue = true -}}
{{- $lowDataMode = .Values.lowDataMode -}}
{{- end -}}

{{- if $userSetAValue -}}
{{- if $lowDataMode -}}
{{- $lowDataMode -}}
{{- end -}}
{{- else -}}
{{- /* This is the default we need for this chart */ -}}
true
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ data:
- prometheus
{{- end }}
processors:
{{- if include "newrelic.common.lowDataMode" . }}
{{- if include "nrKubernetesOtel.lowDataMode" . }}
- metricstransform/ldm
- metricstransform/kubeletstats
- metricstransform/cadvisor
Expand All @@ -597,7 +597,7 @@ data:
- resourcedetection/env
- resourcedetection/cloudproviders
- resource
{{- if include "newrelic.common.lowDataMode" . }}
{{- if include "nrKubernetesOtel.lowDataMode" . }}
- transform/low_data_mode_inator
- resource/low_data_mode_inator
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ data:
- filter/exclude_zero_value_kube_persistentvolumeclaim_status_phase
- filter/exclude_zero_value_kube_pod_status_phase
- filter/exclude_zero_value_kube_pod_container_status
{{- if include "newrelic.common.lowDataMode" . }}
{{- if include "nrKubernetesOtel.lowDataMode" . }}
- metricstransform/ldm
- metricstransform/k8s_cluster_info_ldm
- metricstransform/ksm
Expand All @@ -557,7 +557,7 @@ data:
- prometheus
processors:
- metricstransform/k8s_cluster_info
{{- if include "newrelic.common.lowDataMode" . }}
{{- if include "nrKubernetesOtel.lowDataMode" . }}
- metricstransform/ldm
- metricstransform/k8s_cluster_info_ldm
- metricstransform/apiserver
Expand Down
87 changes: 87 additions & 0 deletions charts/nr-k8s-otel-collector/tests/lowdatamode_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
suite: lowdatamode
templates:
- templates/deployment-configmap.yaml
- templates/daemonset-configmap.yaml
release:
name: my-release
namespace: my-namespace
tests:
- it: lowDataMode is set by default
set:
cluster: test
global:
lowDataMode: ~
lowDataMode: ~
asserts:
- matchRegex:
path: data["deployment-config.yaml"]
pattern: " +- filter/exclude_metrics_low_data_mode"
template: templates/deployment-configmap.yaml
- matchRegex:
path: data["daemonset-config.yaml"]
pattern: " +- filter/exclude_metrics_low_data_mode"
template: templates/daemonset-configmap.yaml

- it: lowDataMode set to true at global level is honored
set:
cluster: test
global:
lowDataMode: true
lowDataMode: ~
asserts:
- matchRegex:
path: data["deployment-config.yaml"]
pattern: " +- filter/exclude_metrics_low_data_mode"
template: templates/deployment-configmap.yaml
- matchRegex:
path: data["daemonset-config.yaml"]
pattern: " +- filter/exclude_metrics_low_data_mode"
template: templates/daemonset-configmap.yaml

- it: lowDataMode set to false at global level is honored
set:
cluster: test
global:
lowDataMode: false
lowDataMode: ~
asserts:
- notMatchRegex:
path: data["deployment-config.yaml"]
pattern: " +- filter/exclude_metrics_low_data_mode"
template: templates/deployment-configmap.yaml
- notMatchRegex:
path: data["daemonset-config.yaml"]
pattern: " +- filter/exclude_metrics_low_data_mode"
template: templates/daemonset-configmap.yaml

- it: lowDataMode set to true at local level is honored
set:
cluster: test
global:
lowDataMode: false
lowDataMode: true
asserts:
- matchRegex:
path: data["deployment-config.yaml"]
pattern: " +- filter/exclude_metrics_low_data_mode"
template: templates/deployment-configmap.yaml
- matchRegex:
path: data["daemonset-config.yaml"]
pattern: " +- filter/exclude_metrics_low_data_mode"
template: templates/daemonset-configmap.yaml

- it: lowDataMode set to false at local level is honored
set:
cluster: test
global:
lowDataMode: true
lowDataMode: false
asserts:
- notMatchRegex:
path: data["deployment-config.yaml"]
pattern: " +- filter/exclude_metrics_low_data_mode"
template: templates/deployment-configmap.yaml
- notMatchRegex:
path: data["daemonset-config.yaml"]
pattern: " +- filter/exclude_metrics_low_data_mode"
template: templates/daemonset-configmap.yaml
4 changes: 2 additions & 2 deletions charts/nr-k8s-otel-collector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,5 @@ receivers:
enabled: true

# -- (bool) Send only the [metrics required](https://github.com/newrelic/helm-charts/tree/master/charts/nr-k8s-otel-collector/docs/metrics-lowDataMode.md) to light up the NR kubernetes UI, this agent defaults to setting lowDataMode true, but if this setting is unset, lowDataMode will be set to false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this change, wouldn't lowDataMode be true if unset? If so, we should update this wording.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kang-makes Bumping this :) Thanks!

# @default -- `false`
lowDataMode: true
# @default -- `true`
lowDataMode:
Loading