This article applies as of PRTG 22

I use some of the web server (HTTP) sensors of PRTG. I am not sure if I have to configure the sensors to show a certain sensor status when receiving a certain HTTP status code. Is there a rule for that?



How an HTTP sensor reacts to HTTP status codes

HTTP sensors show their status depending on the HTTP status codes that they receive.

By default, the sensor states are the following:

HTTP status codeHTTP sensor status
2xx SuccessUp (green)

Note: Except for status code 200, the REST Custom sensor defines all other 2xx states as the Down status.
3xx RedirectionWarning (yellow); Down (red) for too many redirects
4xx Client ErrorDown (red)
5xx Server ErrorDown (red)

You need to manually configure your HTTP sensors only if you want to change these default reactions. In this case, you can change the sensor status based on limits and/or keyword checks.

If you are looking for an alternative where you can adjust the behavior to "accept" a specific HTTP code (for example, green sensor on HTTP 403), you will need to use a custom sensor.


Managing sensor-state/status-code relationships, such as preventing 3xx redirects from triggering warnings or downtimes, is not currently possible in PRTG. However, utilizing this script to extend PRTG's capabilities and customize sensor behavior offers a potential solution.


If you're encountering HTTP 403 errors while using PRTG to monitor a web service. The web service responds with a 403 status code to PRTG requests due to insufficient data in the requests, and modifying this behavior is complex. Using the "HTTP Advanced" sensor with the "Don't alarm if text exists in reply" option still triggers alerts because of the 403 status. This is because a HTTP error will also always show an alert within PRTG. This is how the sensor is designed and intended for. To confirm that a service is responding at "http://IP:port/" without unnecessary alarms, use a "Port Sensor." Configure the Port Sensor to monitor port 443 (or the appropriate port for your service) and activate the "Use Transport-Level Security (default)" option. This setup allows you to verify the service's responsiveness without triggering alerts for the 403 status code.

To monitor specific HTTP status codes in PRTG and ensure that responses like 401 do not trigger errors, you can use a custom script. Follow these steps: 

1. Save the following script as "response_code.ps1" on the PRTG core server or remote probe under the directory: `C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXE\`.  http://pastebin.com/X7VM23aH

2. In PRTG, navigate to the device where you want to add the sensor. 

3. Click Add Sensor.

4. Search for and select EXE/Script

5. Choose response_code.ps1 as the script. 

6. Use the following parameters, adjusting them accordingly: ```text -url "your-domain.com" -ResponseCode "401" -protocol "https" ``` 


This setup will allow PRTG to monitor the specified URL and only show an error if the response code is not what you are looking for. For example, it will show "OK" if a 401 status is returned, and an error for other codes like 5XX or if no response is received. For detailed information on using EXE/Script sensors, visit the PRTG Manual .



More


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.