Skip to content

Commit

Permalink
feat(vector): Add help output for configurations with datadog_agent s…
Browse files Browse the repository at this point in the history
…ource (#178)

* feat(vector): Add help output for configurations with datadog_agent source, set quiet to suppress

Signed-off-by: Spencer Gilbert <[email protected]>

* cleanup help output based on quickstart work

Signed-off-by: Spencer Gilbert <[email protected]>

* draft colorizing output for easier reading

Signed-off-by: Spencer Gilbert <[email protected]>

* 0.8.0 isn't a pre-release

Signed-off-by: Spencer Gilbert <[email protected]>

* support variable tls, and don't print config helper if .Values.quiet=true

Signed-off-by: Spencer Gilbert <[email protected]>
  • Loading branch information
spencergilbert authored Apr 5, 2022
1 parent ce17ab6 commit 13aadfb
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/vector/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ annotations:
artifacthub.io/links: |
- name: Chart Source
url: https://github.com/vectordotdev/helm-charts
artifacthub.io/prerelease: "true"
artifacthub.io/prerelease: "false"
3 changes: 3 additions & 0 deletions charts/vector/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
{{ template "_divider" }}

{{ include "_vector.top" . }}

{{ if not .Values.quiet }}{{ include "_configure.datadog" . }}{{ end }}

88 changes: 87 additions & 1 deletion charts/vector/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,95 @@ Print the `url` option for the Vector command.
{{- if $.Values.customConfig -}}
{{- if $.Values.customConfig.api -}}
{{- if $.Values.customConfig.api.address -}}
--url {{ printf "http://%s/graphql" $.Values.customConfig.api.address }}
{{ print "\\" }}
--url {{ printf "http://%s/graphql" $.Values.customConfig.api.address }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Configuring Datadog Agents to forward to Vector.
This is really alpha level, and should be refactored
to be more generally usable for other components.
*/}}
{{- define "_configure.datadog" -}}
{{- $hasSourceDatadogAgent := false }}
{{- $sourceDatadogAgentPort := "" }}
{{- $hasTls := "" }}
{{- $protocol := "http" }}
{{- range $componentKind, $configs := .Values.customConfig }}
{{- if eq $componentKind "sources" }}
{{- range $componentId, $componentConfig := $configs }}
{{- if eq (get $componentConfig "type") "datadog_agent" }}
{{- $hasSourceDatadogAgent = true }}
{{- $sourceDatadogAgentPort = mustRegexFind "[0-9]+$" (get $componentConfig "address") }}
{{- if (hasKey $componentConfig "tls") }}
{{- $tlsOpts := get $componentConfig "tls" }}
{{- $hasTls = get $tlsOpts "enabled" }}
{{- if $hasTls }}{{ $protocol = "https" }}{{ end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if or (not .Values.customConfig) (and .Values.customConfig $hasSourceDatadogAgent) }}
{{- template "_divider" }}
{{ print "\033[36;1mdatadog_agent:\033[0m" }}
To forward logs from Datadog Agents deployed with the {{ include "_fmt.yellow" "datadog" }} Helm chart,
include the following in the {{ include "_fmt.yellow" "values.yaml" }} for your {{ include "_fmt.yellow" "datadog" }} chart:
For Datadog Agents version {{ include "_fmt.yellow" "7.34" }}/{{ include "_fmt.yellow" "6.34" }} or lower:
{{ include "_fmt.blue" "datadog:" }}
{{ include "_fmt.blue" "containerExclude:" }} "name:vector"
{{ include "_fmt.blue" "logs:" }}
{{ include "_fmt.blue" "enabled:" }} {{ include "_fmt.yellow" "true" }}
{{ include "_fmt.blue" "containerCollectAll:" }} {{ include "_fmt.yellow" "true" }}
{{ include "_fmt.blue" "agents:" }}
{{ include "_fmt.blue" "useConfigMap:" }} {{ include "_fmt.yellow" "true" }}
{{ include "_fmt.blue" "customAgentConfig:" }}
{{ include "_fmt.blue" "kubelet_tls_verify:" }} {{ include "_fmt.yellow" "false" }}
{{ include "_fmt.blue" "logs_config:" }}
{{- if .Values.haproxy.enabled }}
{{ include "_fmt.blue" "logs_dd_url:" }} "{{ include "haproxy.fullname" $ }}.{{ $.Release.Namespace }}:{{ $sourceDatadogAgentPort | default "8282" }}"
{{- else }}
{{ include "_fmt.blue" "logs_dd_url:" }} "{{ include "vector.fullname" $ }}.{{ $.Release.Namespace }}:{{ $sourceDatadogAgentPort | default "8282" }}"
{{- end }}
{{- if $hasTls }}
{{ include "_fmt.blue" "logs_no_ssl:" }} {{ include "_fmt.yellow" "false" }}
{{- else }}
{{ include "_fmt.blue" "logs_no_ssl:" }} {{ include "_fmt.yellow" "true" }}
{{- end }}
{{ include "_fmt.blue" "use_http:" }} {{ include "_fmt.yellow" "true" }}
{{- end }}
For Datadog Agents version {{ include "_fmt.yellow" "7.35" }}/{{ include "_fmt.yellow" "6.35" }} or greater:
{{ include "_fmt.blue" "datadog:" }}
{{ include "_fmt.blue" "containerExclude:" }} "name:vector"
{{ include "_fmt.blue" "logs:" }}
{{ include "_fmt.blue" "enabled:" }} {{ include "_fmt.yellow" "true" }}
{{ include "_fmt.blue" "containerCollectAll:" }} {{ include "_fmt.yellow" "true" }}
{{ include "_fmt.blue" "agents:" }}
{{ include "_fmt.blue" "useConfigMap:" }} {{ include "_fmt.yellow" "true" }}
{{ include "_fmt.blue" "customAgentConfig:" }}
{{ include "_fmt.blue" "kubelet_tls_verify:" }} {{ include "_fmt.yellow" "false" }}
{{ include "_fmt.blue" "vector:" }}
{{ include "_fmt.blue" "logs:" }}
{{ include "_fmt.blue" "enabled:" }} {{ include "_fmt.yellow" "true" }}
{{- if .Values.haproxy.enabled }}
{{ include "_fmt.blue" "url:" }} "{{ $protocol }}://{{ include "haproxy.fullname" $ }}.{{ $.Release.Namespace }}:{{ $sourceDatadogAgentPort | default "8282" }}"
{{- else }}
{{ include "_fmt.blue" "url:" }} "{{ $protocol }}://{{ include "vector.fullname" $ }}.{{ $.Release.Namespace }}:{{ $sourceDatadogAgentPort | default "8282" }}"
{{- end }}
{{ include "_fmt.blue" "metrics:" }}
{{ include "_fmt.blue" "enabled:" }} {{ include "_fmt.yellow" "true" }}
{{- if .Values.haproxy.enabled }}
{{ include "_fmt.blue" "url:" }} "{{ $protocol }}://{{ include "haproxy.fullname" $ }}.{{ $.Release.Namespace }}:{{ $sourceDatadogAgentPort | default "8282" }}"
{{- else }}
{{ include "_fmt.blue" "url:" }} "{{ $protocol }}://{{ include "vector.fullname" $ }}.{{ $.Release.Namespace }}:{{ $sourceDatadogAgentPort | default "8282" }}"
{{- end }}
{{- end }}

0 comments on commit 13aadfb

Please sign in to comment.