I verified both my original log file entry and grok filter via the heroku grokdebug and it parsed correctly. So then I tried using an example from https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html:
I have GROK filter as %{IP:client} %{WORD:method} %{URIPATHPARAM:request} %{NUMBER:bytes} %{NUMBER:duration}
When I start the service via systemctl stop/start telegraf, I see nothing to stdout nor the output file I specified. I’ve enabled debug logging in [agent] section, and I don’t see that log file generated either. I vierifed telegraf service is running via ps | ax.
Then I tried manually running service via “telegraf -config /etc/telegraf/telegraf.conf”.
This time I see a metrics.out file, but it’s empty. I also see the telegraf.log file generated, but all It spits out every 10 seconds is: 2017-10-06T06:14:00Z D! Output [file] buffer fullness: 0 / 10000 metrics.
Here is my test.log file:
root@hpe-host-ubuntu16-02 [~]# cat test.log
55.3.244.1 GET /index.html 15824 0.043
55.3.244.2 GET /index.html 15824 0.043
55.3.244.1 PUT /index.html 15824 0.043
55.3.244.1 GET /index.html 15824 0.043
55.3.244.2 GET /index.html 15824 0.043
55.3.244.1 PUT /index.html 15824 0.043
55.3.244.1 GET /index.html 15824 0.043
55.3.244.2 GET /index.html 15824 0.043
55.3.244.1 PUT /index.html 15824 0.043
This is what my inputs and outputs section in /etc/telegraf/telegraf.conf looks like:
Configuration for telegraf agent
[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 = true
quiet = false
logfile = “/root/telegraf.log”
hostname = “”
omit_hostname = false
[[inputs.logparser]]
files = [“/root/test.log”]
from_beginning = false
[inputs.logparser.grok]
patterns = [“%{IP:client} %{WORD:method} %{URIPATHPARAM:request} %{NUMBER:bytes} %{NUMBER:duration}”]
measurement = “test_log”
# Send telegraf metrics to file(s)
[[outputs.file]]
## Files to write to, “stdout” is a specially handled file.
files = [“stdout”, “/root/metrics.out”]
data_format = “influx”
Am I missing any configuration? Is my grok pattern incorrect for telegraf? (it does say, “The Telegraf grok parser uses a slightly modified version of logstash “grok” patterns”)