Invalid JSON due to non-escaped strings

Hello all,

I’ve encountered an issue stemming from how Icinga handles the strings in the JSON object it outputs. Namely, since Icinga doesn’t do any escaping of the content of the JSON strings, a check(whether it is the check’s plugin output, the check’s name, the command information from the check, etc.) can create a situation where the JSON object becomes invalid due to non-escaped special characters and/or control characters in the string.

An example is the following Event Stream response for a State Change of a check using the Invoke-IcingaCheckICMP Powershell plugin:

         "Use-Icinga; exit Invoke-IcingaCheckICMP",
      "output":"[CRITICAL] Check package ICMP Check for ##HOSTNAME## - [CRITICAL] ICMP request to ##IP ADDRESS## with 64 bytes
\_ [CRITICAL] ICMP request to ##IP ADDRESS## with 64 bytes: Value 206ms is greater than threshold 200ms
   "service":"Powershell Connection to",

If you place the above JSON into a formatter/validator such as the one at, it will flag:

  • The backslashes in the Command
  • The control characters(carriage return and line feed) and the backslash in the Output

Now, the above output is slightly modified from the standard output that would come from the Icinga Powershell Framework as Check package ICMP Check for ##HOSTNAME## would usually look like Check package "ICMP Check for ##HOSTNAME##"(thus inserting non-escaped double quotes in the output), but I placed modified New-IcingaCheck.psm1 and New-IcingaCheckPackage.psm1 files in the custom directory for the framework that removed the double quotes from the output.

What I am wondering is:

  1. Has anyone else encountered this issue and if so, how have you worked around it?
  2. Does this seem like a good feature request to have Icinga escape special and control characters in its JSON string output?

Your function call would be interesting to recreate this


I actually encountered this while trying to setup the Icinga2 pack on Stackstorm. I had created when I had initially discovered the issue. An exception would come up whenever the pack would pass off the JSON from Icinga to Python’s json.loads function.

Ok I understand. I don’t know stackstorm and I don’t know the python script of the pack. To recreate this situation, you have to create the same api request manulaly as the script is doing. After you could parse the json with other programs like jq or the website you wrote. … just an idea