Hello…
I am trying to pass the data from input to a custom script as an argument in “outputs.execd” in telegraf.
Can someone help me figure this out, as I have not found any documentations of its possibility within telegraf.
The execd argument is basically the inputs that are coming in.
The Execd processor plugin runs an external program as a separate process, pipes metrics into the process’s STDIN, and reads processed metrics from its STDOUT. The programs must accept influx line protocol on standard in (STDIN) and output metrics in InfluxDB line protocol to standard output (STDOUT). You can use the Telegraf Execd Go Shim to build and contribute your own external input, processor, and output plugin. Take a look at the external Telegraf plugins for a list of the external plugins that are already available to you.
Program output on standard error is mirrored to the telegraf log.
The example.py script in the repo is a simple example of using the Execd processor plugin to read STDIN and print the metrics to STDOUT with Python.
It looks like this:
# A simple processor. It reads stdin and writes it to stdout.
import sys
def main():
for line in sys.stdin:
print(line.rstrip())
sys.stdout.flush()
if __name__ == '__main__':
main()
The telegraf configuration for the Execd Processor Plugin that executes the simple example.py script looks like this: