I would like to start Java a java jar which has a REST API that collects metrics from the system on which Telegraf agent is running. Now, the issue is that if I start the jar using the EXEC input plugin, then according to telegraf.conf file, at a certain period of time the exec input plugin will want to collect data in some format ex JSON.
Could you please indicate how could I start the jar only one time before any input plugin will start collecting data?
@jackzampolin Thanks for your reply. I wanted to use the httpjson plugin but then I saw that this plugin will “flatten the JSON and finds all numeric values, treating them as floats”. I do have and String as values. So, I need to mention that we do have an input plugin that reads the data, which is in JSON format, from the REST API.
For the moment I created a bash script but it’s not what I am looking for as final solution. Maybe this will clear out what my intention is with starting a JAVA jar from Telegraf -> one time only. Please have a look at the following script.
# Call following funct whenever Ctrl-C is invoked
echo "Sending termination signal to JAVA PID $PID_JAVA"
kill -9 $PID_JAVA
echo "JAVA PID $PID_JAVA should be terminated now"
trap exit_signal SIGINT
nohup jre/bin/java -jar lib/jvmagent.jar &
./telegraf --config ../telegraf.conf
while true; do
So, I want to combine the Java Agent with Telegraf, by starting the jar with an exec function “somewhere”. Is this possible?
Once more thanks for coming back to this question. Best regards!
@jackzampolin Sad story here. I wish I could use systemd but sadly the operating system for the hosts I would like to deploy the Agent, is ancient and does not have systemd. Thanks for your suggestion, highly appreciate!