Hi @Michal_Pristas,
Thanks for the update.
Sorry I made a mistake in my initial question.
Actually my config is working, but the problem is that it only works for the first time which I believe is due to filebeat remembering file and line info.
As a workaround I am copying the file with different filename each time.
Here is my config file:
filebeat.inputs:
- type: log
paths:
- test2.log
json.keys_under_root: true
json.add_error_key: true
json.message_key: method
output:
console:
pretty: true
What I am trying to do here is testing my config file and see if it works as expected.
To be more specific, I am trying to run filebeat as cmd line with --once
.
However I have encountered the following issues:
- Filebeat not looking for specified config file, instead it always looks for the default location.
filebeat -c ./filebeat.yml -e --once
2019-07-17T10:06:01.059+0900 INFO instance/beat.go:606 Home path: [/usr/local/Cellar/filebeat-oss/7.2.0/libexec] Config path: [/usr/local/etc/filebeat] Data path: [/usr/local/var/lib/filebeat] Logs path: [/usr/local/var/log/filebeat]
-
--once
not stopping filebeat after all log lines has been processed in test.log
.
2019-07-17T10:06:01.090+0900 INFO beater/filebeat.go:376 All data collection completed. Shutting down.
2019-07-17T10:06:01.090+0900 INFO log/harvester.go:253 Harvester started for file: /xxxx/test2.log
2019-07-17T10:06:01.090+0900 INFO crawler/crawler.go:139 Stopping Crawler
2019-07-17T10:06:01.090+0900 INFO crawler/crawler.go:149 Stopping 1 inputs
<some json output>
2019-07-17T10:06:31.090+0900 INFO [monitoring] log/log.go:145 Non-zero metrics in the last 30s {"monitoring": {"metrics": {"beat":{"cpu":{"system":{"ticks":26,"time":{"ms":26}},"total":{"ticks":61,"time":{"ms":61},"value":61},"user":{"ticks":35,"time":{"ms":35}}},"info":{"ephemeral_id":"159f09a7-6541-470f-8cc6-f9b219ae31e8","uptime":{"ms":30048}},"memstats":{"gc_next":4194304,"memory_alloc":1976464,"memory_total":5629792,"rss":20844544},"runtime":{"goroutines":23}},"filebeat":{"events":{"added":3,"done":3},"harvester":{"open_files":1,"running":1,"started":1}},"libbeat":{"config":{"module":{"running":0}},"output":{"events":{"acked":2,"batches":1,"total":2},"type":"console","write":{"bytes":2200}},"pipeline":{"clients":1,"events":{"active":0,"filtered":1,"published":2,"total":3},"queue":{"acked":2}}},"registrar":{"states":{"current":3,"update":3},"writes":{"success":2,"total":2}},"system":{"cpu":{"cores":8},"load":{"1":1.6206,"15":1.9434,"5":1.7983,"norm":{"1":0.2026,"15":0.2429,"5":0.2248}}}}}}
Since I am just testing filebeat and configs, I wish to make it look for config file that I specified and not remember the filename/content, also ideally it would end once all contents of log file has been processed.
Is it possible to achieve the the above?