Skip to content

Commit

Permalink
update UDP dogstatsdPort behavior to exclude including a port value i…
Browse files Browse the repository at this point in the history
…f using a kube service address (as determined by user overrides)
  • Loading branch information
natemollica-nm committed Feb 9, 2024
1 parent d01568a commit 307991b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion charts/consul/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ Usage: {{ template "consul.dogstatsdAaddressInfo" . }}

{{- define "consul.dogstatsdAaddressInfo" -}}
{{- if (and .Values.global.metrics.datadog.enabled .Values.global.metrics.datadog.dogstatsd.enabled) }}
"dogstatsd_addr": "{{- if eq .Values.global.metrics.datadog.dogstatsd.socketTransportType "UDS" }}unix://{{ .Values.global.metrics.datadog.dogstatsd.dogstatsdAddr }}{{- else }}{{ .Values.global.metrics.datadog.dogstatsd.dogstatsdAddr | trimAll "\"" }}:{{ .Values.global.metrics.datadog.dogstatsd.dogstatsdPort | toString }}{{- end }}",{{- end }}
"dogstatsd_addr": "{{- if eq .Values.global.metrics.datadog.dogstatsd.socketTransportType "UDS" }}unix://{{ .Values.global.metrics.datadog.dogstatsd.dogstatsdAddr }}{{- else }}{{ .Values.global.metrics.datadog.dogstatsd.dogstatsdAddr | trimAll "\"" }}{{- if ne ( .Values.global.metrics.datadog.dogstatsd.dogstatsdPort | int ) 0 }}:{{ .Values.global.metrics.datadog.dogstatsd.dogstatsdPort | toString }}{{- end }}{{- end }}",{{- end }}
{{- end -}}

{{/*
Expand Down
6 changes: 3 additions & 3 deletions charts/consul/test/unit/server-config-configmap.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ load _helpers
[ "${actual}" = "unix:///var/run/datadog/dsd.socket" ]
}

@test "server/ConfigMap: when global.metrics.datadog.enabled=true, sets non-default namespace telemetry.dogstatsd_addr config" {
@test "server/ConfigMap: when global.metrics.datadog.enabled=true, sets non-default telemetry.dogstatsd_addr config" {
cd `chart_dir`
local actual=$(helm template \
-s templates/server-config-configmap.yaml \
Expand All @@ -1335,11 +1335,11 @@ load _helpers
--set 'global.metrics.datadog.enabled=true' \
--set 'global.metrics.datadog.dogstatsd.enabled=true' \
--set 'global.metrics.datadog.dogstatsd.socketTransportType="UDP"' \
--set 'global.metrics.datadog.dogstatsd.dogstatsdAddr="127.0.0.1"' \
--set 'global.metrics.datadog.dogstatsd.dogstatsdAddr="datadog-agent.default.svc.cluster.local"' \
. | tee /dev/stderr |
yq -r '.data["telemetry-config.json"]' | jq -r .telemetry.dogstatsd_addr | tee /dev/stderr)

[ "${actual}" = "127.0.0.1:8125" ]
[ "${actual}" = "datadog-agent.default.svc.cluster.local" ]
}

@test "server/ConfigMap: when global.metrics.datadog.enabled=true, sets non-default namespace telemetry.dogstatsd_addr with non-default port config" {
Expand Down
9 changes: 7 additions & 2 deletions charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,14 @@ global:
dogstatsdAddr: "/var/run/datadog/dsd.socket"
# Configures IP based dogstatsd designated port that will be appended to "UDP" based transport socket IP/Hostname URL.
#
# @default: 8125
# If using a kubernetes service based address (i.e., datadog.default.svc.cluster.local), set this to 0 to
# mitigate appending a port value to the dogstatsd address field. Resultant address would be "datadog.default.svc.cluster.local" with
# default port setting, while appending a non-zero port would result in "172.10.23.6:8125" with a dogstatsdAddr value
# of "172.10.23.6".
#
# @default: 0
# @type: integer
dogstatsdPort: 8125
dogstatsdPort: 0
# Configures datadog [autodiscovery](https://docs.datadoghq.com/containers/kubernetes/log/?tab=operator#autodiscovery)
# style [log integration](https://docs.datadoghq.com/integrations/consul/?tab=containerized#log-collection)
# configuration for Consul.
Expand Down

0 comments on commit 307991b

Please sign in to comment.