what do I want to do?
I'm trying to deploy telegraf in my Kubernetes cluster so that I can use Telegraf's Prometheus input plugin to read the data (metrics) from a particular URL and write the metrics in a file using telegraf's output file plugin.
what did I do?
I used the telegraf helm chart to deploy telegraf on kubernetes. I changed the following config changes. The original telegraf yaml file:
config:
agent:
interval: "10s"
round_interval: true
metric_batch_size: 1000
metric_buffer_limit: 10000
collection_jitter: "0s"
flush_interval: "10s"
flush_jitter: "0s"
precision: ""
debug: false
quiet: false
logfile: ""
hostname: "$HOSTNAME"
omit_hostname: false
processors:
- enum:
mapping:
field: "status"
dest: "status_code"
value_mappings:
healthy: 1
problem: 2
critical: 3
outputs:
- influxdb:
urls:
- "http://influxdb.monitoring.svc:8086"
database: "telegraf"
inputs:
- statsd:
service_address: ":8125"
percentiles:
- 50
- 95
- 99
metric_separator: "_"
allowed_pending_messages: 10000
percentile_limit: 1000
The changes I made to it:
config:
outputs:
- file:
files:
- "stdout"
- "metrics.out"
data_format: influx
inputs:
- prometheus:
- urls:
url: "http://ipaddr:80/metrics"
And when I applied the helm chart along with the changes I got Error: Service "telegraf" is invalid: spec.ports: Required value and my deployment failed.
chandhana@Azure:~/clouddrive/PromExpose$ helm install telegraf influxdata/telegraf -f telegraf-values.yaml
Error: Service "telegraf" is invalid: spec.ports: Required value
Please do help me if I'm making any mistakes on the changed YAML configuration since I didn't find any resource for yaml format of telegraf's input and output plugin. Additional link for reference: telegraf .conf file
You forgot to enable metrics in values.yaml, its disabled by default. Correct part is
Change your
telegraf-values.yaml
toResult: