Skip to content

Commit

Permalink
dogstatsd and otlp mutually exclusive verification checks
Browse files Browse the repository at this point in the history
  • Loading branch information
natemollica-nm committed Feb 9, 2024
1 parent f66f0f3 commit 2dc237b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions charts/consul/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,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.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." }}
{{- 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." }}
{{- 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." }}
Expand Down
21 changes: 21 additions & 0 deletions charts/consul/test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,27 @@ load _helpers

}

@test "server/StatefulSet: consul metrics exclusion annotation when using metrics.datadog.dogstatsd.enabled=true" {
cd `chart_dir`
local annotations=$(helm template \
-s templates/server-statefulset.yaml \
--set 'global.image=hashicorp/consul-enterprise:1.17.0-ent' \
--set 'global.metrics.enabled=true' \
--set 'global.metrics.enableAgentMetrics=true' \
--set 'global.metrics.datadog.enabled=true' \
--set 'global.metrics.datadog.dogstatsd.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations' | tee /dev/stderr)

local actual=$( echo "$annotations" | \
yq -r '."ad.datadoghq.com/consul.checks"' | tee /dev/stderr )
[ -n "${actual}" ]

local actual=$( echo "$annotations" | \
yq -r '."ad.datadoghq.com/consul.metrics_exclude"' | tee /dev/stderr )
[ "${actual}" = "true" ]
}


@test "server/StatefulSet: datadog unified tagging labels get added when global.metrics.datadog.enabled=true" {
cd `chart_dir`
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ global:
# - `/v1/coordinate/datacenters`
# - `/v1/coordinate/nodes`
#
# Setting either `global.metrics.datadogIntegration.openMetricsPrometheus.enabled=true` or `global.metrics.datadogIntegration.dogstatsd.enabled=true` disables the above checks
# Setting either `global.metrics.datadog.otlp.enabled=true` or `global.metrics.datadog.dogstatsd.enabled=true` disables the above checks
# in lieu of metrics data collection via DogStatsD or by a customer OpenMetrics (Prometheus) collection endpoint.
#
# ~> **Note:** If you have a [dogstatsd_mapper_profile](https://docs.datadoghq.com/integrations/consul/?tab=host#dogstatsd) configured for Consul
Expand Down

0 comments on commit 2dc237b

Please sign in to comment.