How do I get alerted for an exception in a custom plugin?
To get alerted for an exception in a custom plugin, include the attributes ['status'] = 0 and ['msg']=str(e) under Exception.
What do the attributes denote?
1. status: Denotes the availability of the monitor.
The value can either be:
- 1, which means the status is Up and metrics are collected successfully, or
- 0, indicating the status is Down and metrics cannot be collected due to a script error or failure to connect to the remote server or API.
2. msg: These are messages for the monitor when in Down status.
Both of the above are
reserved keys, and you can add the above attributes in the Exception section.
This would change the monitor status to Down if there is an error in the plugin, and ensure that the exception captured in the 'msg' keyword would be shown as the reason for the Down status.
except Exception as e:
data["status"]=0
data["msg"]=str(e)
catch
{
$Script:Status = 0
$Script:msg = $_.Exception.Message
}
Tip: Add this in your plugin scripts for faster troubleshooting.
Related Articles
FAQ on Custom Roles
What is the Created permission and what does it allow users to do? The Created permission is a specific type of access control that permits users to perform actions such as View, Write, or Delete solely on the modules, like dashboard, that they have ...
How to set thresholds and get alerted based on the number of DOWN locations?
By configuring the proper thresholds for your web application, you can decide when to get alerted for a DOWN monitor. Let's say you have a web application that you monitor from our three global locations and your downtime rule is set as three ...
Troubleshoot connection errors in the MySQL plugin
When configuring the MySQL plugin, you may encounter the following errors: Error : Connection Error - This error typically indicates that there is a problem establishing a connection to the database. Sometimes, this message is supplemented with an ...
What are Incident Parameters and Custom Parameters?
Incident and Custom parameters get passed along with the body of the URL during an HTTP request invocation. Incident Parameters Incident Parameters are predefined system parameters passed in the invoked URL's body. In the HTTP response, the Incident ...
Troubleshoot the "pymysql module not found" error when installing the MySQL plugin
If you're encountering the pymysql module not found error, it likely means that the pymysql Python library is not installed on the server. pymysql is a Python package that provides a way to interact with MySQL databases using Python code and is used ...