What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How would you use placeholder syntax in a REST template.

Votes:

0

Hi,

I'm trying to create a dynamic REST template for monitoring aspects of PowerDNS recursor. One of the metrics counts how long each thread has spent on queries - as threads are dynamic and vary depending on the machine I thought I'd try to build a placeholder but I think either the format of the PowerDNS API is foiling me or PRTG.

These are the entries I'm trying to monitor with the template:

[
  {
    "name": "cpu-msec-thread-0",
    "type": "StatisticItem",
    "value": "88195007"
  },
  {
    "name": "cpu-msec-thread-1",
    "type": "StatisticItem",
    "value": "23439221"
  },
  {
    "name": "cpu-msec-thread-10",
    "type": "StatisticItem",
    "value": "26430890"
  },
  {
    "name": "cpu-msec-thread-11",
    "type": "StatisticItem",
    "value": "24616980"
  },
  {
    "name": "cpu-msec-thread-12",
    "type": "StatisticItem",
    "value": "25795722"
  },
  {
    "name": "cpu-msec-thread-2",
    "type": "StatisticItem",
    "value": "25027948"
  },
  {
    "name": "cpu-msec-thread-3",
    "type": "StatisticItem",
    "value": "25910209"
  },
  {
    "name": "cpu-msec-thread-4",
    "type": "StatisticItem",
    "value": "25116874"
  },
  {
    "name": "cpu-msec-thread-5",
    "type": "StatisticItem",
    "value": "24945352"
  },
  {
    "name": "cpu-msec-thread-6",
    "type": "StatisticItem",
    "value": "25538823"
  },
  {
    "name": "cpu-msec-thread-7",
    "type": "StatisticItem",
    "value": "25172107"
  },
  {
    "name": "cpu-msec-thread-8",
    "type": "StatisticItem",
    "value": "25194866"
  },
  {
    "name": "cpu-msec-thread-9",
    "type": "StatisticItem",
    "value": "23597720"
  },
  {
    "name": "fd-usage",
    "type": "StatisticItem",
    "value": "114"
  },
  {
    "name": "malloc-bytes",
    "type": "StatisticItem",
    "value": "0"
  },
  {
    "name": "real-memory-usage",
    "type": "StatisticItem",
    "value": "1257447424"
  },
  {
    "name": "security-status",
    "type": "StatisticItem",
    "value": "1"
  },
  {
    "name": "sys-msec",
    "type": "StatisticItem",
    "value": "193078605"
  },
  {
    "name": "uptime",
    "type": "StatisticItem",
    "value": "2455604"
  },
  {
    "name": "user-msec",
    "type": "StatisticItem",
    "value": "196111840"
  }
]

I'm trying to get PRTG to work out how many "cpu-msec-thread-n" gauges to create.

The current version of the template looks like this:

{
  "prtg": {
    "description" : {
      "device": "PowerDNS Recursor (System)",
      "query": ":8082/api/v1/servers/localhost/statistics",
      "comment": "PowerDNS Recursor system stats"
    },
    "result": [
      {
        "channel": "Recursor CPU thread Time",
        "Unit": "Custom",
        "CustomUnit": "ms",
        "Mode": "Difference",
        "value": {$["cpu-msec-thread-"][#0]}
      },
      {
        "channel": "Recursor CPU system Time",
        "Unit": "Custom",
        "CustomUnit": "ms",
        "Mode": "Difference",
        "value": $["sys-msec"]
      },
      {
        "channel": "Recursor CPU user Time",
        "Unit": "Custom",
        "CustomUnit": "ms",
        "Mode": "Difference",
        "value": $["user-msec"]
      },
      {
        "channel": "Recursor Memory Usage",
        "VolumeSize": "KiloByte",
        "value": $["real-memory-usage"]
      },
      {
        "channel": "Recursor File Descriptors",
        "Unit": "Count",
        "value": $["fd-usage"]
      },
      {
        "channel": "Recursor Software Update Status",
        "ValueLookup": "cleminan.pccw.powerdns.security.status",
        "ShowChart": "0",
        "ShowTable": "1",
        "value": $["security-status"]
      },
      {
        "channel": "Recursor Process Uptime",
        "Unit": "TimeSeconds",
        "value": $.uptime
      }
    ]
  }
}

I've had a play around with the format of the query string both:

"value": {$["cpu-msec-thread-"][#0]}

and

"value": {$["cpu-msec-thread-"[#0]]}

But with PRTG's handling of hyphens requiring a combination of punctuation it muddies the examples given.

https://www.paessler.com/manuals/prtg/rest_custom_sensor#jsonpath_expressions

Any help would be gratefully received.

Many thanks a.

placeholder prtg rest template

Created on Jan 2, 2020 3:39:43 PM



3 Replies

Votes:

0

Unfortunately, - (dashes) within the selector will always cause the Sensor to think it's a mathematic equation, rather than a selector. Could you try $.*["cpu-msec-thread"][*][0] ? Not sure if that'll work though. Rule of thumb is to put the selector containing the dashes into [" and "].

Created on Jan 3, 2020 8:20:14 AM by  Stephan Linke [Paessler Support]



Votes:

0

Thanks for the response, however I think I may have larger problems.

I suspect PRTG is expecting:

"label": "value"

But PowerDNS recursor stats are all in the form:

{ "name": "cpu-msec-thread-0", "type": "StatisticItem", "value": "88195007" },

The dnsdist load balancer has a JSON API for stats in the former format, but neither the PowerDNS Recursor or Authoritative servers utilise it.

Created on Jan 3, 2020 10:20:57 AM



Votes:

0

The format is perfectly fine from what I can tell, but the name is somewhat difficult to get correctly. Did you have any success with the string I provided?

Created on Jan 7, 2020 8:39:02 AM by  Stephan Linke [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.