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


Article Comments

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.


Jul, 2018 - Permalink

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


Jul, 2018 - Permalink

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


Jul, 2018 - Permalink

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


Jul, 2018 - Permalink

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


Jul, 2018 - Permalink

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.


Jul, 2018 - Permalink

Alrighty then :)


Kind regards,
Stephan Linke, Tech Support Team


Jul, 2018 - Permalink