Commit fc730cf0 authored by David McKay's avatar David McKay Committed by David McKay

feat(telegraf-ds): opinionated telegraf-ds deamonset

This chart does not allow tweaking the input configuration. It is for node and Kubernetes monitoring. Use the `telegraf` chart if you need to configure the inputs
parent 4c83301d
...@@ -160,11 +160,11 @@ Create chart name and version as used by the chart label. ...@@ -160,11 +160,11 @@ Create chart name and version as used by the chart label.
{{- end }} {{- end }}
{{- end -}} {{- end -}}
{{- define "inputs" -}} {{- define "processors" -}}
{{- range $inputIdx, $configObject := . -}} {{- range $processorIdx, $configObject := . -}}
{{- range $input, $config := . -}} {{- range $processor, $config := . -}}
[[inputs.{{- $input }}]] [[processors.{{- $processor }}]]
{{- if $config -}} {{- if $config -}}
{{- $tp := typeOf $config -}} {{- $tp := typeOf $config -}}
{{- if eq $tp "map[string]interface {}" -}} {{- if eq $tp "map[string]interface {}" -}}
...@@ -208,11 +208,11 @@ Create chart name and version as used by the chart label. ...@@ -208,11 +208,11 @@ Create chart name and version as used by the chart label.
] ]
{{- end }} {{- end }}
{{- if eq $tp "map[string]interface {}" }} {{- if eq $tp "map[string]interface {}" }}
[[inputs.{{ $input }}.{{ $key }}]] [[processors.{{ $processor }}.{{ $key }}]]
{{- range $k, $v := $value }} {{- range $k, $v := $value }}
{{- $tps := typeOf $v }} {{- $tps := typeOf $v }}
{{- if eq $tps "string" }} {{- if eq $tps "string" }}
{{ $k }} = {{ $v }} {{ $k }} = {{ $v | quote }}
{{- end }} {{- end }}
{{- if eq $tps "[]interface {}"}} {{- if eq $tps "[]interface {}"}}
{{ $k }} = [ {{ $k }} = [
...@@ -229,10 +229,19 @@ Create chart name and version as used by the chart label. ...@@ -229,10 +229,19 @@ Create chart name and version as used by the chart label.
] ]
{{- end }} {{- end }}
{{- if eq $tps "map[string]interface {}"}} {{- if eq $tps "map[string]interface {}"}}
[[inputs.{{ $input }}.{{ $key }}.{{ $k }}]] [processors.{{ $processor }}.{{ $key }}.{{ $k }}]
{{- range $foo, $bar := $v }} {{- range $foo, $bar := $v }}
{{- $tp := typeOf $bar -}}
{{- if eq $tp "string" }}
{{ $foo }} = {{ $bar | quote }} {{ $foo }} = {{ $bar | quote }}
{{- end }} {{- end }}
{{- if eq $tp "int" }}
{{ $foo }} = {{ $bar }}
{{- end }}
{{- if eq $tp "float64" }}
{{ $foo }} = {{ int64 $bar }}
{{- end }}
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
...@@ -243,11 +252,11 @@ Create chart name and version as used by the chart label. ...@@ -243,11 +252,11 @@ Create chart name and version as used by the chart label.
{{- end }} {{- end }}
{{- end -}} {{- end -}}
{{- define "processors" -}} {{- define "aggregators" -}}
{{- range $processorIdx, $configObject := . -}} {{- range $aggregatorIdx, $configObject := . -}}
{{- range $processor, $config := . -}} {{- range $aggregator, $config := . -}}
[[processors.{{- $processor }}]] [[aggregators.{{- $aggregator }}]]
{{- if $config -}} {{- if $config -}}
{{- $tp := typeOf $config -}} {{- $tp := typeOf $config -}}
{{- if eq $tp "map[string]interface {}" -}} {{- if eq $tp "map[string]interface {}" -}}
...@@ -290,8 +299,11 @@ Create chart name and version as used by the chart label. ...@@ -290,8 +299,11 @@ Create chart name and version as used by the chart label.
{{- end }} {{- end }}
] ]
{{- end }} {{- end }}
{{- end }}
{{- range $key, $value := $config -}}
{{- $tp := typeOf $value -}}
{{- if eq $tp "map[string]interface {}" }} {{- if eq $tp "map[string]interface {}" }}
[[processors.{{ $processor }}.{{ $key }}]] [[aggregators.{{ $aggregator }}.{{ $key }}]]
{{- range $k, $v := $value }} {{- range $k, $v := $value }}
{{- $tps := typeOf $v }} {{- $tps := typeOf $v }}
{{- if eq $tps "string" }} {{- if eq $tps "string" }}
...@@ -299,20 +311,50 @@ Create chart name and version as used by the chart label. ...@@ -299,20 +311,50 @@ Create chart name and version as used by the chart label.
{{- end }} {{- end }}
{{- if eq $tps "[]interface {}"}} {{- if eq $tps "[]interface {}"}}
{{ $k }} = [ {{ $k }} = [
{{- $numOut := len $value }} {{- $numOut := len $v }}
{{- $numOut := sub $numOut 1 }} {{- $numOut := sub $numOut 1 }}
{{- range $b, $val := $v }} {{- range $b, $val := $v }}
{{- $i := int64 $b }} {{- $i := int64 $b }}
{{- $tv := typeOf $val -}}
{{- if eq $i $numOut }} {{- if eq $i $numOut }}
{{- if eq $tv "string" }}
{{ $val | quote }} {{ $val | quote }}
{{- end }}
{{- if eq $tv "float64" }}
{{- $xval := float64 (int64 $val) -}}
{{- if eq $val $xval -}}
{{ $val | float64 }}.0
{{- else -}}
{{ $val | float64 }}
{{- end -}}
{{- end }}
{{- if eq $tv "int64" }}
{{ $val | int64 }}
{{- end }}
{{- else }} {{- else }}
{{- if eq $tv "string" }}
{{ $val | quote }}, {{ $val | quote }},
{{- end }} {{- end }}
{{- if eq $tv "float64" }}
{{- $xval := float64 (int64 $val) -}}
{{- if eq $val $xval -}}
{{ $val | float64 }}.0,
{{- else -}}
{{ $val | float64 }},
{{- end -}}
{{- end }}
{{- if eq $tv "int64" }}
{{ $val | int64 }},
{{- end }}
{{- end }}
{{- end }} {{- end }}
] ]
{{- end }} {{- end }}
{{- end }}
{{- range $k, $v := $value }}
{{- $tps := typeOf $v }}
{{- if eq $tps "map[string]interface {}"}} {{- if eq $tps "map[string]interface {}"}}
[processors.{{ $processor }}.{{ $key }}.{{ $k }}] [aggregators.{{ $aggregator }}.{{ $key }}.{{ $k }}]
{{- range $foo, $bar := $v }} {{- range $foo, $bar := $v }}
{{- $tp := typeOf $bar -}} {{- $tp := typeOf $bar -}}
{{- if eq $tp "string" }} {{- if eq $tp "string" }}
......
...@@ -12,5 +12,29 @@ data: ...@@ -12,5 +12,29 @@ data:
{{ template "global_tags" .Values.config.global_tags }} {{ template "global_tags" .Values.config.global_tags }}
{{ template "agent" .Values.config.agent }} {{ template "agent" .Values.config.agent }}
{{ template "processors" .Values.config.processors }} {{ template "processors" .Values.config.processors }}
{{ template "aggregators" .Values.config.aggregators }}
{{ template "outputs" .Values.config.outputs }} {{ template "outputs" .Values.config.outputs }}
{{ template "inputs" .Values.config.inputs -}}
\ No newline at end of file [[inputs.diskio]]
[[inputs.kernel]]
[[inputs.mem]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
[[inputs.cpu]]
percpu = true
totalcpu = true
collect_cpu_time = false
report_active = false
[[inputs.disk]]
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.docker]]
endpoint = "unix:///var/run/docker.sock"
[[inputs.kubernetes]]
url = "https://$HOSTIP:10250"
bearer_token = "/run/secrets/kubernetes.io/serviceaccount/token"
insecure_skip_verify = true
...@@ -29,6 +29,10 @@ spec: ...@@ -29,6 +29,10 @@ spec:
resources: resources:
{{ toYaml .Values.resources | indent 10 }} {{ toYaml .Values.resources | indent 10 }}
env: env:
- name: HOSTIP
valueFrom:
fieldRef:
fieldPath: status.hostIP
{{ toYaml .Values.env | indent 8 }} {{ toYaml .Values.env | indent 8 }}
volumeMounts: volumeMounts:
- name: varrunutmpro - name: varrunutmpro
......
{{- if .Values.rbac.create }} {{- if .Values.rbac.create }}
# Allow to define extra custom rules
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: influx:telegraf:custom
labels:
rbac.authorization.k8s.io/aggregate-view-telegraf-custom: "true"
rules:
{{ toYaml .Values.rbac.rules | indent 2 }}
---
# kubernetes_plugin: Give access to stats endpoints # kubernetes_plugin: Give access to stats endpoints
kind: ClusterRole kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
...@@ -17,8 +7,11 @@ metadata: ...@@ -17,8 +7,11 @@ metadata:
labels: labels:
rbac.authorization.k8s.io/aggregate-view-telegraf-stats: "true" rbac.authorization.k8s.io/aggregate-view-telegraf-stats: "true"
rules: rules:
- apiGroups: ["metrics.k8s.io"]
resources: ["pods"]
verbs: ["get", "list", "watch"]
- apiGroups: [""] - apiGroups: [""]
resources: ["nodes/proxy"] resources: ["nodes/stats"]
verbs: ["get", "watch", "list"] verbs: ["get", "watch", "list"]
--- ---
# Define global role with the default system:aggregate-to-view cluster role and the two rules we just created # Define global role with the default system:aggregate-to-view cluster role and the two rules we just created
...@@ -29,8 +22,6 @@ metadata: ...@@ -29,8 +22,6 @@ metadata:
aggregationRule: aggregationRule:
clusterRoleSelectors: clusterRoleSelectors:
- matchLabels: - matchLabels:
rbac.authorization.k8s.io/aggregate-view-telegraf-custom: "true"
- matchLabels:
rbac.authorization.k8s.io/aggregate-view-telegraf-stats: "true" rbac.authorization.k8s.io/aggregate-view-telegraf-stats: "true"
- matchLabels: - matchLabels:
rbac.authorization.k8s.io/aggregate-to-view: "true" rbac.authorization.k8s.io/aggregate-to-view: "true"
......
...@@ -30,10 +30,6 @@ env: ...@@ -30,10 +30,6 @@ env:
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: status.hostIP fieldPath: status.hostIP
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: "HOST_PROC" - name: "HOST_PROC"
value: "/rootfs/proc" value: "/rootfs/proc"
- name: "HOST_SYS" - name: "HOST_SYS"
...@@ -47,46 +43,13 @@ tolerations: [] ...@@ -47,46 +43,13 @@ tolerations: []
rbac: rbac:
# Specifies whether RBAC resources should be created # Specifies whether RBAC resources should be created
create: true create: true
# Rules for the created rule
rules: []
# When using the prometheus input to scrape all pods you need extra rules set to the ClusterRole to be
# able to scan the pods for scraping labels. The following rules have been taken from:
# https://github.com/helm/charts/blob/master/stable/prometheus/templates/server-clusterrole.yaml#L8-L46
# - apiGroups:
# - ""
# resources:
# - nodes
# - nodes/proxy
# - nodes/metrics
# - services
# - endpoints
# - pods
# - ingresses
# - configmaps
# verbs:
# - get
# - list
# - watch
# - apiGroups:
# - "extensions"
# resources:
# - ingresses/status
# - ingresses
# verbs:
# - get
# - list
# - watch
# - nonResourceURLs:
# - "/metrics"
# verbs:
# - get
serviceAccount: serviceAccount:
# Specifies whether a ServiceAccount should be created # Specifies whether a ServiceAccount should be created
create: true create: true
# The name of the ServiceAccount to use. # The name of the ServiceAccount to use.
# If not set and create is true, a name is generated using the fullname template # If not set and create is true, a name is generated using the fullname template
name: #name:
## Exposed telegraf configuration ## Exposed telegraf configuration
## ref: https://docs.influxdata.com/telegraf/v1.13/administration/configuration/ ## ref: https://docs.influxdata.com/telegraf/v1.13/administration/configuration/
...@@ -102,7 +65,7 @@ config: ...@@ -102,7 +65,7 @@ config:
flush_interval: "10s" flush_interval: "10s"
flush_jitter: "0s" flush_jitter: "0s"
precision: "" precision: ""
debug: false debug: true
quiet: false quiet: false
logfile: "" logfile: ""
hostname: "$HOSTNAME" hostname: "$HOSTNAME"
...@@ -110,7 +73,7 @@ config: ...@@ -110,7 +73,7 @@ config:
outputs: outputs:
- influxdb: - influxdb:
urls: urls:
- "http://influxdb.monitoring:8086" - "http://influxdb:8086"
database: "telegraf" database: "telegraf"
retention_policy: "" retention_policy: ""
timeout: "5s" timeout: "5s"
...@@ -118,28 +81,6 @@ config: ...@@ -118,28 +81,6 @@ config:
password: "" password: ""
user_agent: "telegraf" user_agent: "telegraf"
insecure_skip_verify: false insecure_skip_verify: false
inputs: - file:
- cpu: files:
percpu: true - stdout
totalcpu: true
collect_cpu_time: false
report_active: false
- disk:
ignore_fs: ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
- diskio:
- docker:
endpoint: "unix:///var/run/docker.sock"
timeout: "5s"
perdevice: true
total: false
docker_label_exclude:
- "annotation.kubernetes.io/*"
- kernel:
- kubernetes:
url: "https://kubernetes.default.svc.cluster.local/api/v1/nodes/$NODE_NAME/proxy"
bearer_token: "/run/secrets/kubernetes.io/serviceaccount/token"
insecure_skip_verify: true
- mem:
- processes:
- swap:
- system:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment