diff --git a/.changelog/3383.txt b/.changelog/3383.txt index 48d17a6876..14dc27d0ff 100644 --- a/.changelog/3383.txt +++ b/.changelog/3383.txt @@ -1,8 +1,6 @@ ```release-note:feature -breaking-change: users who previously had agent `enable_debug` set in `global.server.extraConfig`, should remove the extraConfig entry to avoid configuration conflicts. -breaking-change: users who previously had agent `telemetry` stanza settings for `disable_hostname`, `enable_host_metrics`, `prefix_filter`, `dogstatsd_addr`, and/or `dogstatsd_tags`, should remove the extraConfig entry/entries to avoid configuration conflicts. helm: introduces `global.metrics.datadog` overrides to streamline consul-k8s datadog integration. -helm: introduces `global.metrics.enableConsulAgentDebug` to expose agent [`enable_debug`](https://developer.hashicorp.com/consul/docs/agent/config/config-files#enable_debug) configuration. +helm: introduces `server.enableAgentDebug` to expose agent [`enable_debug`](https://developer.hashicorp.com/consul/docs/agent/config/config-files#enable_debug) configuration. helm: introduces `global.metrics.disableAgentHostName` to expose agent [`telemetry.disable_hostname`](https://developer.hashicorp.com/consul/docs/agent/config/config-files#telemetry-disable_hostname) configuration. helm: introduces `global.metrics.enableHostMetrics` to expose agent [`telemetry.enable_host_metrics`](https://developer.hashicorp.com/consul/docs/agent/config/config-files#telemetry-enable_host_metrics) configuration. helm: introduces `global.metrics.prefixFilter` to expose agent [`telemetry.prefix_filter`](https://developer.hashicorp.com/consul/docs/agent/config/config-files#telemetry-prefix_filter) configuration. @@ -10,6 +8,6 @@ helm: introduces `global.metrics.datadog.dogstatsd.dogstatsdAddr` to expose agen helm: introduces `global.metrics.datadog.dogstatsd.dogstatsdTags` to expose agent [`telemetry.dogstatsd_tags`](https://developer.hashicorp.com/consul/docs/agent/config/config-files#telemetry-dogstatsd_tags) configuration. helm: introduces required `ad.datadoghq.com/` annotations and `tags.datadoghq.com/` labels for integration with [Datadog Autodiscovery](https://docs.datadoghq.com/integrations/consul/?tab=containerized) and [Datadog Unified Service Tagging](https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/?tab=kubernetes#serverless-environment) for Consul. helm: introduces automated unix domain socket hostPath mounting for containerized integration with datadog within consul-server statefulset. -helm: introduces `global.metrics.datadog.datadogOpenTelemetryCollector` override options to allow OTLP metrics forwarding to Datadog Agent. +helm: introduces `global.metrics.datadog.otlp` override options to allow OTLP metrics forwarding to Datadog Agent. control-plane: adds `server-acl-init` datadog agent token creation for datadog integration. ``` \ No newline at end of file diff --git a/charts/consul/templates/_helpers.tpl b/charts/consul/templates/_helpers.tpl index 69f22e2d3f..59a1705289 100644 --- a/charts/consul/templates/_helpers.tpl +++ b/charts/consul/templates/_helpers.tpl @@ -151,6 +151,48 @@ is passed to consul as a -config-file param on command line. [ -n "${HOSTNAME}" ] && sed -Ei "s|HOSTNAME|${HOSTNAME?}|g" /consul/extra-config/extra-from-values.json {{- end -}} +{{/* +Cleanup server.extraConfig entries to avoid conflicting entries: + - server.enableAgentDebug: + - `enable_debug` should not exist in extraConfig + - metrics.disableAgentHostName: + - if global.metrics.enabled and global.metrics.enableAgentMetrics are enabled, `disable_hostname` should not exist in extraConfig + - metrics.enableHostMetrics: + - if global.metrics.enabled and global.metrics.enableAgentMetrics are enabled, `enable_host_metrics` should not exist in extraConfig + - metrics.prefixFilter + - if global.metrics.enabled and global.metrics.enableAgentMetrics are enabled, `prefix_filter` should not exist in extraConfig + - metrics.datadog.enabled: + - if global.metrics.datadog.enabled and global.metrics.datadog.dogstatsd.enabled, `dogstatsd_tags` and `dogstatsd_addr` should not exist in extraConfig + +Usage: {{ template "consul.validateExtraConfig" . }} +*/}} +{{- define "consul.validateExtraConfig" -}} +{{- if (and .Values.global.metrics.enabled .Values.global.metrics.enableAgentMetrics) }} +{{- if (contains "enable_debug" .Values.server.extraConfig) }} +{{ fail "The 'enable_debug' key is present in extra-from-values.json. Use 'server.enableAgentDebug' to set this value." }} +{{- end }} +{{- if (contains "disable_hostname" .Values.server.extraConfig) }} +{{ fail "The 'disable_hostname' key is present in extra-from-values.json. Use 'global.metrics.disableAgentHostName' to set this value." }} +{{- end }} +{{- if (contains "enable_host_metrics" .Values.server.extraConfig) }} +{{ fail "The 'enable_host_metrics' key is present in extra-from-values.json. Use 'global.metrics.enableHostMetrics' to set this value." }} +{{- end }} +{{- if (contains "prefix_filter" .Values.server.extraConfig) }} +{{ fail "The 'prefix_filter' key is present in extra-from-values.json. Use 'global.metrics.prefix_filter' to set this value." }} +{{- end }} +{{- if (and .Values.global.metrics.datadog.dogstatsd.enabled) }} +{{- if (contains "dogstatsd_tags" .Values.server.extraConfig) }} +{{ fail "The 'dogstatsd_tags' key is present in extra-from-values.json. Use 'global.metrics.datadog.dogstatsd.dogstatsdTags' to set this value." }} +{{- end }} +{{- end }} +{{- if (and .Values.global.metrics.datadog.dogstatsd.enabled) }} +{{- if (contains "dogstatsd_addr" .Values.server.extraConfig) }} +{{ fail "The 'dogstatsd_addr' key is present in extra-from-values.json. Use 'global.metrics.datadog.dogstatsd.dogstatsd_addr' to set this value." }} +{{- end }} +{{- end }} +{{- end }} +{{- end -}} + {{/* Create chart name and version as used by the chart label. */}} @@ -589,8 +631,8 @@ Usage: {{ template "consul.validateDatadogConfiguration" . }} {{- if and .Values.global.metrics.datadog.enabled (or (not .Values.global.metrics.enableAgentMetrics) (not .Values.global.metrics.enabled) )}} {{fail "When enabling datadog metrics collection, the /v1/agent/metrics is required to be accessible, therefore global.metrics.enableAgentMetrics and global.metrics.enabled must be also be enabled."}} {{- end }} -{{- if and .Values.global.metrics.datadog.dogstatsd.enabled .Values.global.metrics.datadog.otlp.enabled }} -{{fail "You must have one of DogStatsD (global.metrics.datadog.dogstatsd.enabled) or OpenMetrics (global.metrics.datadog.otlp.enabled) enabled, not both as this is an unsupported configuration." }} +{{- if and .Values.global.metrics.datadog.dogstatsd.enabled .Values.global.metrics.datadog.openMetricsPrometheus.enabled }} +{{fail "You must have one of DogStatsD (global.metrics.datadog.dogstatsd.enabled) or OpenMetrics (global.metrics.datadog.openMetricsPrometheus.enabled) enabled, not both as this is an unsupported configuration." }} {{- end }} {{- if and .Values.global.metrics.datadog.otlp.enabled (not .Values.telemetryCollector.enabled) }} {{fail "Cannot enable Datadog OTLP metrics collection (global.metrics.datadog.otlp.enabled) without consul-telemetry-collector. Ensure Consul OTLP collection is enabled (telemetryCollector.enabled) and configured." }} diff --git a/charts/consul/templates/server-statefulset.yaml b/charts/consul/templates/server-statefulset.yaml index 024c3b5924..1a8bcb80e7 100644 --- a/charts/consul/templates/server-statefulset.yaml +++ b/charts/consul/templates/server-statefulset.yaml @@ -21,6 +21,7 @@ {{ template "consul.validateCloudSecretKeys" . }} {{ template "consul.validateMetricsConfig" . }} {{ template "consul.validateDatadogConfiguration" . }} +{{ template "consul.validateExtraConfig" . }} # StatefulSet to run the actual Consul server cluster. apiVersion: apps/v1 kind: StatefulSet @@ -143,7 +144,7 @@ spec: {{- if .Values.global.metrics.datadog.enabled }} "ad.datadoghq.com/tolerate-unready": "true" "ad.datadoghq.com/consul.logs": {{ .Values.global.metrics.datadog.dogstatsd.dogstatsdTags | squote }} - {{- if .Values.global.metrics.datadog.otlp.enabled }} + {{- if .Values.global.metrics.datadog.openMetricsPrometheus.enabled }} "ad.datadoghq.com/consul.checks": | { "openmetrics": { diff --git a/charts/consul/test/unit/server-config-configmap.bats b/charts/consul/test/unit/server-config-configmap.bats index 2729ed20d2..e796ed3d2b 100755 --- a/charts/consul/test/unit/server-config-configmap.bats +++ b/charts/consul/test/unit/server-config-configmap.bats @@ -1310,7 +1310,7 @@ load _helpers } #-------------------------------------------------------------------- -# Datadog Consul on Kubernetes Integration +# Datadog @test "server/ConfigMap: when global.metrics.datadog.enabled=true, sets default telemetry.dogstatsd_addr config" { cd `chart_dir` diff --git a/charts/consul/test/unit/server-statefulset.bats b/charts/consul/test/unit/server-statefulset.bats index ef95b850d0..f64f4c2705 100755 --- a/charts/consul/test/unit/server-statefulset.bats +++ b/charts/consul/test/unit/server-statefulset.bats @@ -899,7 +899,7 @@ load _helpers [ "${actual}" = "ENC[k8s_secret@default/default-datadog-agent-metrics-acl-token/token]" ] } -@test "server/StatefulSet: when global.metrics.datadog.otlp.enabled, applicable openmetrics annotation is set" { +@test "server/StatefulSet: when global.metrics.datadog.openMetricsPrometheus.enabled, applicable openmetrics annotation is set" { cd `chart_dir` local annotations=$(helm template \ -s templates/server-statefulset.yaml \ @@ -907,7 +907,7 @@ load _helpers --set 'telemetryCollector.enabled=true' \ --set 'global.metrics.enableAgentMetrics=true' \ --set 'global.metrics.datadog.enabled=true' \ - --set 'global.metrics.datadog.otlp.enabled=true' \ + --set 'global.metrics.datadog.openMetricsPrometheus.enabled=true' \ . | tee /dev/stderr | yq -r '.spec.template.metadata.annotations' | tee /dev/stderr) @@ -936,7 +936,7 @@ load _helpers } -@test "server/StatefulSet: when datadog.otlp.enabled, applicable openmetrics annotation is set with tls url" { +@test "server/StatefulSet: when datadog.openMetricsPrometheus.enabled, applicable openmetrics annotation is set with tls url" { cd `chart_dir` local annotations=$(helm template \ -s templates/server-statefulset.yaml \ @@ -945,7 +945,7 @@ load _helpers --set 'telemetryCollector.enabled=true' \ --set 'global.metrics.enableAgentMetrics=true' \ --set 'global.metrics.datadog.enabled=true' \ - --set 'global.metrics.datadog.otlp.enabled=true' \ + --set 'global.metrics.datadog.openMetricsPrometheus.enabled=true' \ . | tee /dev/stderr | yq -r '.spec.template.metadata.annotations' | tee /dev/stderr) @@ -985,7 +985,7 @@ load _helpers [ "${actual}" = ".*" ] } -@test "server/StatefulSet: when global.metrics.datadog.otlp.enabled, applicable openmetrics annotation is set with acls.manageSystemACLs enabled" { +@test "server/StatefulSet: when global.metrics.datadog.openMetricsPrometheus.enabled, applicable openmetrics annotation is set with acls.manageSystemACLs enabled" { cd `chart_dir` local annotations=$(helm template \ -s templates/server-statefulset.yaml \ @@ -994,7 +994,7 @@ load _helpers --set 'global.acls.manageSystemACLs=true' \ --set 'global.metrics.enableAgentMetrics=true' \ --set 'global.metrics.datadog.enabled=true' \ - --set 'global.metrics.datadog.otlp.enabled=true' \ + --set 'global.metrics.datadog.openMetricsPrometheus.enabled=true' \ . | tee /dev/stderr | yq -r '.spec.template.metadata.annotations' | tee /dev/stderr)