Skip to content

Commit 8969b97

Browse files
authored
Check for type=otlp before checking for protocol, which doesn't exist in other destination types (#1262)
Signed-off-by: Pete Wall <[email protected]>
1 parent 62951df commit 8969b97

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

charts/k8s-monitoring/templates/destinations/_destination_validations.tpl

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,26 @@
3636
{{- fail (join "\n" $msg) }}
3737
{{- end }}
3838

39-
{{/* Check if OTLP destination using Grafana Cloud OTLP gateway has protocol set */}}
40-
{{- if and (eq $destination.type "otlp") (ne $destination.protocol "http") (regexMatch "otlp-gateway-.+grafana\\.net" $destination.url) }}
41-
{{ fail (printf "\nDestination #%d (%s) is using Grafana Cloud OTLP gateway but has incorrect protocol '%s'. The gateway requires 'http'.\nPlease set:\ndestinations:\n - name: %s\n type: otlp\n url: %s\n protocol: http" $i $destination.name ($destination.protocol | default "grpc (default)") $destination.name $destination.url) }}
42-
{{- end }}
43-
44-
{{/* Check if OTLP destination using Grafana Cloud Tempo checks */}}
45-
{{- if and (eq $destination.type "otlp") (regexMatch "tempo-.+grafana\\.net" $destination.url) }}
46-
{{- if ne $destination.protocol "grpc" }}
47-
{{ fail (printf "\nDestination #%d (%s) is using Grafana Cloud Traces but has incorrect protocol '%s'. Grafana Cloud Traces requires 'grpc'.\nPlease set:\ndestinations:\n - name: %s\n type: otlp\n url: %s\n protocol: grpc" $i $destination.name ($destination.protocol | default "grpc (default)") $destination.name $destination.url) }}
48-
{{- end }}
49-
{{- if eq (dig "metrics" "enabled" true $destination) true }}
50-
{{ fail (printf "\nDestination #%d (%s) is using Grafana Cloud Traces but has metrics enabled. Tempo only supports traces.\nPlease set:\ndestinations:\n - name: %s\n type: otlp\n url: %s\n metrics:\n enabled: false" $i $destination.name $destination.name $destination.url) }}
39+
{{- if (eq $destination.type "otlp") }}
40+
{{/* Check if OTLP destination using Grafana Cloud OTLP gateway has protocol set */}}
41+
{{- if and (ne $destination.protocol "http") (regexMatch "otlp-gateway-.+grafana\\.net" $destination.url) }}
42+
{{ fail (printf "\nDestination #%d (%s) is using Grafana Cloud OTLP gateway but has incorrect protocol '%s'. The gateway requires 'http'.\nPlease set:\ndestinations:\n - name: %s\n type: otlp\n url: %s\n protocol: http" $i $destination.name ($destination.protocol | default "grpc (default)") $destination.name $destination.url) }}
5143
{{- end }}
52-
{{- if eq (dig "logs" "enabled" true $destination) true }}
53-
{{ fail (printf "\nDestination #%d (%s) is using Grafana Cloud Traces but has logs enabled. Tempo only supports traces.\nPlease set:\ndestinations:\n - name: %s\n type: otlp\n url: %s\n logs:\n enabled: false" $i $destination.name $destination.name $destination.url) }}
54-
{{- end }}
55-
{{- if eq (dig "traces" "enabled" true $destination) false }}
56-
{{ fail (printf "\nDestination #%d (%s) is using Grafana Cloud Traces but has traces disabled.\nPlease set:\ndestinations:\n - name: %s\n type: otlp\n url: %s\n traces:\n enabled: true" $i $destination.name $destination.name $destination.url) }}
44+
45+
{{/* Check if OTLP destination using Grafana Cloud Tempo checks */}}
46+
{{- if and (regexMatch "tempo-.+grafana\\.net" $destination.url) }}
47+
{{- if ne $destination.protocol "grpc" }}
48+
{{ fail (printf "\nDestination #%d (%s) is using Grafana Cloud Traces but has incorrect protocol '%s'. Grafana Cloud Traces requires 'grpc'.\nPlease set:\ndestinations:\n - name: %s\n type: otlp\n url: %s\n protocol: grpc" $i $destination.name ($destination.protocol | default "grpc (default)") $destination.name $destination.url) }}
49+
{{- end }}
50+
{{- if eq (dig "metrics" "enabled" true $destination) true }}
51+
{{ fail (printf "\nDestination #%d (%s) is using Grafana Cloud Traces but has metrics enabled. Tempo only supports traces.\nPlease set:\ndestinations:\n - name: %s\n type: otlp\n url: %s\n metrics:\n enabled: false" $i $destination.name $destination.name $destination.url) }}
52+
{{- end }}
53+
{{- if eq (dig "logs" "enabled" true $destination) true }}
54+
{{ fail (printf "\nDestination #%d (%s) is using Grafana Cloud Traces but has logs enabled. Tempo only supports traces.\nPlease set:\ndestinations:\n - name: %s\n type: otlp\n url: %s\n logs:\n enabled: false" $i $destination.name $destination.name $destination.url) }}
55+
{{- end }}
56+
{{- if eq (dig "traces" "enabled" true $destination) false }}
57+
{{ fail (printf "\nDestination #%d (%s) is using Grafana Cloud Traces but has traces disabled.\nPlease set:\ndestinations:\n - name: %s\n type: otlp\n url: %s\n traces:\n enabled: true" $i $destination.name $destination.name $destination.url) }}
58+
{{- end }}
5759
{{- end }}
5860
{{- end }}
5961

0 commit comments

Comments
 (0)