I’m trying postgres output plugin on telegraf 1.31.0.
Scenario: drop a PSQL table while telegraf is running
Expected behavior: telegraf should be able to recreate the table if it does not exists
Actual behavior: Telegraf throws error saying table does not exists hence dropping the metrics batch! (doesnt even buffer them)
This scenario was tried with table template as ‘create table if not exists’ and ‘create table’ both.
How do I make telegraf create the tables while it is already running and tables are dropped because of some unexpected cleanup.
You have not shared a config or full logs so I am not sure if you are concurrently or sequentially writing or the full scenario of what is going on.
However, if you are sequentially writing, the plugin looks through the metrics as they come in to ensure the necessary columns exist and if they do not exist then they are created. As a part of this, if the table does not exist then it is created.
@srebhan sure I’ll create a feature request for that. I would also like to ask what should one use if we want to execute a shell command on a specific condition. For example:
echo "Hello"
when metrics.fields[‘used’] > 100MBs.
I explored starlark functions like ctx.actions.run_shell but it didnt work for me. Could you please point me to some resource for this use case?
Thank you so much
@srebhan thank you, that looks like a very nice option. I tried it but I’m unable to pass the right command in the attribute. Suppose I simply want to pass the metrics into a shell script say: /usr/local/bin/hello.sh <metrics>