I'm using an HTTP Data Advanced sensor to monitor some JSON, containing several channels. In theory, this JSON should be overwritten every 5 minutes with new, so the sensor runs every 5 minutes too. However, in reality the JSON is not always overwritten.

In order to know when the results in PRTG are from, I'd like to add a channel to the JSON names something like "Query Time (UTC)". How can I successfully add this channel?

Attempt 1 - just throw the date in

However, doing this without any additional parameters in the JSON causes the sensor to fail (not unexpectedly) -

The returned JSON does not match the expected structure ('2018-08-01T10:49:26.0Z' is not a valid integer value). (code: PE231)

{
    "prtg": {
        "result": [
            {
                "channel": "Query Time (UTC)",
                "value": "2018-08-01T10:49:26.0Z"
            },
            {...},
            {...},
            {...}
        ]
    }
}

Attempt 2 - use the 'Custom' unit type

I've also tried to include the "unit" and customUnit parameters, but that leads to another error -

The returned JSON does not match the expected structure ('1 Aug 2018). (code: PE231)

{
    "prtg": {
        "result": [
            {
                "channel": "Query Time (UTC)",
                "value": "1 Aug 2018, 10:49 AM",
                "unit": "Custom",
                "CustomUnit": "UTC"
            },
            {...},
            {...},
            {...}
        ]
    }
}

Attempt 3 - use the 'duration' function

After some research, I came across the 'duration' function. It's not clear from the documentation exactly where it can be used, so I thought I'd give it a go, but that failed too -

The returned JSON does not match the expected structure ('duration(2018-08-01T10:49:26.0000000Z). (code: PE231)

{
    "prtg": {
        "result": [
            {
                "channel": "Query Time (UTC)",
                "value": "duration(2018-08-01T10:49:26.0000000Z, now())"
            },
            {...},
            {...},
            {...}
        ]
    }
}

Article Comments

"value": duration(2018-08-01T10:49:26.0000000Z, now()) ...should work. If not, please provide your entire configuration file. Add !nopublish to the beginning of your post to avoid having it published.


Kind regards,
Stephan Linke, Tech Support Team


Aug, 2018 - Permalink

Ah, sorry - please encapsulate the time string: '2018-08-01T10:49:26.0000000Z'.

Additionally, please make sure to use the latest PRTG version to have all features of the REST sensor available :)


Kind regards,
Stephan Linke, Tech Support Team


Aug, 2018 - Permalink

I've now encapsulated the time string but I'm still getting the same error.

The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231)

{
    "prtg": {
        "result": [
            {
                "channel": "Query Age",
                "value": duration('2018-08-01T10:49:26.0000000Z', now())
            },
            {...},
            {...},
            {...}
        ]
    }
}

I'm not sure what the latest version is, but we're running 18.3.42.1748+.


Aug, 2018 - Permalink

Ha, keep your eyes peeled. The issue is not the actual date, but another value in the JSON:

"channel": "Incoming Messages",
"value": "102

The 102 is missing the " at the end. That should be the reason why it's not working.


Kind regards,
Stephan Linke, Tech Support Team


Aug, 2018 - Permalink