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

Create dynamic channel with rest custom sensor and json

Votes:

0

Hi, I´m trying to monitor the HTTP Status Codes from my traefik load balancer with the REST Custom Sensor.

This is the json i get from traefiks api ->

{
  "pid": 32510,
  "uptime": "3h48m4.565825751s",
  "uptime_sec": 13684.565825751,
  "time": "2018-07-04 14:37:31.941361889 +0200 CEST m=+13684.830775391",
  "unixtime": 1530707851,
  "status_code_count": {
    "200": 37,
    "301": 2,
    "404": 1
  },
  "total_status_code_count": {
    "200": 190914,
    "206": 106,
    "301": 40928,
    "302": 61348,
    "304": 2381,
    "307": 4,
    "400": 38,
    "401": 3,
    "403": 4,
    "404": 24526,
    "406": 284,
    "410": 1175,
    "500": 3630
  },
  "count": 40,
  "total_count": 325341,
  "total_response_time": "7h56m26.869387871s",
  "total_response_time_sec": 28586.869387871,
  "average_response_time": "87.867404ms",
  "average_response_time_sec": 0.087867404
}

I have already created a Rest configuration and i can get the values into prtg. But there is one big problem. If i restart traefik, the status codes are reset and won´t appear again in the json until a client triggers it again. Therefor the sensor gets down with reason "could not resolve channel HTTP 404: path does not exist 'total_status_code_count.404' "

{
  "pid": 1243,
  "uptime": "4.159367305s",
  "uptime_sec": 4.159367305,
  "time": "2018-07-04 16:39:09.434314257 +0200 CEST m=+10.209230759",
  "unixtime": 1530715149,
  "status_code_count": {
    
  },
  "total_status_code_count": {
    
  },
  "count": 0,
  "total_count": 0,
  "total_response_time": "0s",
  "total_response_time_sec": 0,
  "average_response_time": "0s",
  "average_response_time_sec": 0,
  "recent_errors": [
    
  ]
}

So I have tried to create an generic channel, but i don´t understand the example/syntax which is listed in the manual. Maybe you can help me.

Thanks in advance. Regards, Stefan

generic-channel json prtg rest-custom

Created on Jul 4, 2018 2:53:31 PM

Last change on Jul 4, 2018 6:33:56 PM by  Dariusz Gorka [Paessler Support]



Best Answer

Accepted Answer

Votes:

0

This one should do the trick:

{
    "prtg": {
      "result": [
        {
          "channel": "HTTP ",
          "mode": "Difference",
          "value": {
             "200": 0,
             "302": 0,
             "404": 0,
            
             #0 : $.total_status_code_count["200", "302", "404"],
          },
          "CustomUnit": "Status Code(s)"
        },
        {
          "channel": "Average Repsonse Time" ,
          "value": $.average_response_time_sec * 1000,
          "CustomUnit": "ms",
          "float": 1
        }
      ]
    }
  }

Works for me at least :D


Kind regards,
Stephan Linke, Tech Support Team

Created on Jul 9, 2018 11:57:56 AM by  Stephan Linke [Paessler Support]



7 Replies

Votes:

0

Hello,

thank you for the KB Post. Can you share the Rest-Configuration as well as a screenshot showing the sensor's settings & overview tab? That should help to debug the issue.

best regards.

Created on Jul 5, 2018 12:28:19 PM by  Torsten Lindner [Paessler Support]



Votes:

0

Hi Torsten,

this is my Rest-Configuration

{ "prtg": { "result": [ { "channel": "HTTP 404", "mode": "Difference", "value": "total_status_code_count.404", "CustomUnit": "Status Code(s)" }, { "channel": "HTTP 302", "mode": "Difference", "value": "total_status_code_count.302", "CustomUnit": "Status Code(s)" }, { "channel": "HTTP 200", "mode": "Difference", "value": "total_status_code_count.200", "CustomUnit": "Status Code(s)" }, { "channel": "Average Repsonse Time" , "value": "average_response_time_sec *1000", "CustomUnit": "ms", "float": 1 } ] } }

Sensor Settings Sensor Overview

Best Regards Stefan

Created on Jul 5, 2018 12:52:00 PM



Accepted Answer

Votes:

0

This one should do the trick:

{
    "prtg": {
      "result": [
        {
          "channel": "HTTP ",
          "mode": "Difference",
          "value": {
             "200": 0,
             "302": 0,
             "404": 0,
            
             #0 : $.total_status_code_count["200", "302", "404"],
          },
          "CustomUnit": "Status Code(s)"
        },
        {
          "channel": "Average Repsonse Time" ,
          "value": $.average_response_time_sec * 1000,
          "CustomUnit": "ms",
          "float": 1
        }
      ]
    }
  }

Works for me at least :D


Kind regards,
Stephan Linke, Tech Support Team

Created on Jul 9, 2018 11:57:56 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi Stephan,

thanks for your answer. Unfortunately it´s not working for me.

could not load config: invalid character '#' looking for beginning of object key string

I understand that the placeholder #0 is not valid JSON and a extension of the official JSONPATH. Do I have to enable something on my PRTG Installation to make this extension available?

Regards Stefan

Created on Jul 9, 2018 12:18:56 PM



Votes:

0

It works for me 1:1 with the latest PRTG version. Which one are you running?

Created on Jul 9, 2018 12:26:34 PM by  Stephan Linke [Paessler Support]



Votes:

0

Already found out that we are running an old 17.3 version where this is not available. Have to check if and when we are upgrading to the new 18 version.

Created on Jul 9, 2018 12:33:09 PM



Votes:

0

Alrighty then :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Jul 9, 2018 2:04:37 PM 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.