0

When my application is up, telegraf works fine and collects data related to jolokia since my application opens the port 11722 that telegraf uses to get the metrics. But then, when my application is down, telegraf starts to get errors since it can't connect to Jolokia. My telegraf version is 1.5.3 and this is a Production environment, so I don't have much flexibility to change the version. Is there a way to collect the jolokia metrics just when my application is up and running? I've tried to create a script to check if jolokia was running and use with a tag that then I could use with my agent, but this didn't work:

[[inputs.exec]]
  commands = ["sh /local/1/home/svcegctp/telegraf/inputs/scripts/check_jolokia.sh"]
  timeout = "1s"
  data_format = "influx"
  name_override = "jvm_status"
  [inputs.exec.tags]
    running = "true"
  (...)

[[inputs.jolokia2_agent]]

   # Add agents URLs to query
   urls = ["http://localhost:11722/jolokia"]

    
    [inputs.jolokia2_agent.tags]
       running = "true"

This is my script:

check_jolokia.sh

#!/bin/bash

if curl -s -u <username>:<password> http://localhost:11722/jolokia/version >/dev/null 2>&1; then
    echo "jvm_status running=true"
else
    echo "jvm_status running=false"
fi
Arthur Accioly
  • 801
  • 9
  • 26
  • 1
    What is the actual issue? Telegraf being outputting errors about unable to connect? To me that's not really an issue. Also, 1.5 is a very very old version. Current one is 1.25 and should be possible to update in-place. – Hipska Mar 09 '23 at 16:19

0 Answers0