Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

Commit

Permalink
use lists instead of dicts for inputs & outputs in telegraf-s
Browse files Browse the repository at this point in the history
  • Loading branch information
amoskyler committed Aug 10, 2018
1 parent f4763f9 commit 80ced53
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 127 deletions.
2 changes: 1 addition & 1 deletion telegraf-s/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: telegraf-s
version: 1.7.2
version: 1.8.0
description: Telegraf is an agent written in Go for collecting, processing, aggregating, and writing metrics.
keywords:
- telegraf
Expand Down
15 changes: 15 additions & 0 deletions telegraf-s/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ Alternatively, a YAML file that specifies the values for the above parameters ca
$ helm install --name my-release -f values.yaml stable/telegraf
```

Outputs and inputs are configured as arrays of key/value dictionaries. Additional examples and defaults can be found in [values.yaml](values.yaml)
Example:
```
outputs:
- influxdb:
urls: []
# - "http://influxdb-influxdb.tick:8086"
database: "telegraf"
inputs:
- cpu:
percpu: false
totalcpu: true
- system:
```

> **Tip**: You can use the default [values.yaml](values.yaml)
## Telegraf Configuration
Expand Down
11 changes: 5 additions & 6 deletions telegraf-s/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ To open a shell session in the container running Telegraf run the following:

- kubectl exec -i -t --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "fullname" . }} -o jsonpath='{.items[0].metadata.name}') /bin/sh

To tail the logs for a Telegraf pod run the following:
To tail the logs for a Telegraf pod in the Daemonset run the following:

- kubectl logs -f --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "fullname" . }} -o jsonpath='{ .items[0].metadata.name }')
- kubectl logs -f --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "fullname" . }}-ds -o jsonpath='{ .items[0].metadata.name }')

{{- if empty .Values.config.outputs.influxdb.urls }}
{{- if eq .Values.service.type "LoadBalancer" }}

Need to set an InfluxDB url for either s daemonset to deploy this instance:

.Values.config.outputs.influxdb.urls
To watch for the LoadBalancer IP run the following

- kubectl get svc -w --namespace {{ .Release.Namespace }} -l app={{ template "fullname" . }}
{{- end }}
19 changes: 15 additions & 4 deletions telegraf-s/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this
{{- end -}}

{{- define "outputs" -}}
{{- range $outputIdx, $configObject := . -}}
{{- range $output, $config := . }}
[[outputs.{{ $output }}]]
{{- if $config }}
{{- $tp := typeOf $config -}}
{{- if eq $tp "map[string]interface {}" -}}
{{- range $key, $value := $config -}}
{{- $tp := typeOf $value }}
{{- if eq $tp "string"}}
Expand Down Expand Up @@ -83,13 +86,19 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}

{{- define "inputs" -}}
{{- range $input, $config := . -}}
{{- range $inputIdx, $configObject := . -}}
{{- range $input, $config := . -}}

[[inputs.{{- $input }}]]
{{- if $config -}}
{{- if $config -}}
{{- $tp := typeOf $config -}}
{{- if eq $tp "map[string]interface {}" -}}
{{- range $key, $value := $config -}}
{{- $tp := typeOf $value -}}
{{- if eq $tp "string" }}
Expand Down Expand Up @@ -158,7 +167,9 @@ We truncate at 24 chars because some Kubernetes name fields are limited to this
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{ end }}
{{- end }}
{{- end -}}
4 changes: 1 addition & 3 deletions telegraf-s/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{- if gt (len .Values.config.outputs.influxdb.urls) 0 }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -13,5 +12,4 @@ data:
{{ template "global_tags" .Values.config.global_tags }}
{{ template "agent" .Values.config.agent }}
{{ template "outputs" .Values.config.outputs }}
{{ template "inputs" .Values.config.inputs -}}
{{- end -}}
{{ template "inputs" .Values.config.inputs -}}
2 changes: 0 additions & 2 deletions telegraf-s/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{- if gt (len .Values.config.outputs.influxdb.urls) 0 }}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
Expand Down Expand Up @@ -37,4 +36,3 @@ spec:
- name: config
configMap:
name: {{ template "fullname" . }}
{{- end -}}
11 changes: 8 additions & 3 deletions telegraf-s/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
{{- if .Values.service.enabled -}}
{{- if .Values.service.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}
name: {{ template "fullname" . }}-s
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
spec:
type: {{ .Values.service.type }}
ports:
{{- range $key, $value := .Values.config.inputs }}
{{- range $objectKey, $objectValue := .Values.config.inputs }}
{{- range $key, $value := . -}}
{{- $tp := typeOf $value -}}
{{- if eq $key "http_listener" }}
- port: {{ trimPrefix ":" $value.service_address | int64 }}
targetPort: {{ trimPrefix ":" $value.service_address | int64 }}
Expand Down Expand Up @@ -36,7 +39,9 @@ spec:
targetPort: {{ trimPrefix ":" $value.service_address | int64 }}
name: "webhooks"
{{- end }}
{{- end -}}
{{- end }}
selector:
app: {{ template "fullname" . }}
app: {{ template "fullname" .}}-s
{{- end -}}
{{- end -}}
Loading

0 comments on commit 80ced53

Please sign in to comment.