telegraf
telegraf copied to clipboard
Tail input silently ignores files in unreadable directories
Relevant telegraf.conf
[global_tags]
[agent]
interval = "5s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
flush_interval = "1s"
precision = "1ms"
[[inputs.tail]]
files = [ "/home/myuser/root_only/myfile" ]
data_format = "influx"
Logs from Telegraf
$ telegraf --config telegraf-basic.conf --debug --test
2024-11-13T11:36:48Z I! Loading config: telegraf-basic.conf
2024-11-13T11:36:48Z I! Starting Telegraf 1.32.2 brought to you by InfluxData the makers of InfluxDB
2024-11-13T11:36:48Z I! Available plugins: 235 inputs, 9 aggregators, 32 processors, 26 parsers, 62 outputs, 6 secret-stores
2024-11-13T11:36:48Z I! Loaded inputs: tail
2024-11-13T11:36:48Z I! Loaded aggregators:
2024-11-13T11:36:48Z I! Loaded processors:
2024-11-13T11:36:48Z I! Loaded secretstores:
2024-11-13T11:36:48Z W! Outputs are not used in testing mode!
2024-11-13T11:36:48Z I! Tags enabled: host=thinkpad
2024-11-13T11:36:48Z D! [agent] Initializing plugins
2024-11-13T11:36:48Z D! [agent] Starting service inputs
2024-11-13T11:36:48Z D! [agent] Stopping service inputs
2024-11-13T11:36:48Z D! [agent] Input channel closed
2024-11-13T11:36:48Z D! [agent] Stopped Successfully
System info
Fedora 44, Telegraf 1.32.2
Docker
No response
Steps to reproduce
- Run telegraf with a tail input that references a file in a directory to which there are no access permissions for the executing user
Expected behavior
If a file can not be reached because of directory permissions then an error should be reported.
Actual behavior
No error is reported, telegraf ignores the input
Additional info
I couldn't work out in the code at what point the path access is evaluated, it seems to be quite early on as when the code is adding the tail, there are unaviodable error messages there that would be printed had it failed inside the Tail module.
This works fine for actual file permissions, but not for directories.