Alerts API
This article provides sample API calls used for obtaining and creating Alerts.
PREREQUISITES:
- Set up API access
- Verify that you have API access OR get token call via curl since all API calls require a token
Get all Alerts for a specific Metric
You can fetch the list of all alerts for a specific Metric. NOTE: You might get empty result.
- Item: metric_alert
- Method: GET
- element: Specify the element ID in this field. Element ID can be determined in the web browser URL of its editor. For example:
https://demo.metricinsights.com/chart/index/index/element/284
4. Run Request
Get only recent Alerts (or Alerts for a specific time period)
or qualify each metric by time range
- Item: alert_rule
- Method: POST
- element: Specify the element ID in this field. Element ID can be determined in the web browser URL of its editor. For example:
https://demo.metricinsights.com/chart/index/index/element/284
- start_time/end_time: Define a date range for which the alerts should be shown.
- Run Request
Create an Alert Rule (multiple types)
Target Alert Rule Type
- Item: alert_rule
- Method: POST
- ID: Find an existing Alert of the Target type that you wish to use as a foundation for new Alert; open its Editor and find its ID in the web browser URL. For example:
https://demo.metricinsights.com/editor/kpialertrule/edit/id/1442
- Modify any parameters of this request according to your requirements
- Run Request
Fixed Value Rule Type
- Item: alert_rule
- Method: POST
- ID: Find an existing Alert of a Fixed Value type that you wish to use as a foundation for new Alert; open its Editor and find its ID in the web browser URL. For example:
https://demo.metricinsights.com/editor/kpialertrule/edit/id/1444
- Modify any parameters of this request according to your requirements
- Run Request
Prior Value Rule Type
- Item: alert_rule
- Method: POST
- ID: Find an existing Alert with a Prior Value type that you wish to use as a foundation for new Alert; open its Editor and find its ID in the web browser URL. For example:
https://demo.metricinsights.com/editor/kpialertrule/edit/id/1449
- Modify any parameters of this request according to your requirements
- Run Request
Recent Volatility Rule Type
- Item: alert_rule
- Method: POST
- ID: Find an existing Alert with a Volatility Levels type that you wish to use as a foundation for new Alert; open its Editor and find its ID in the web browser URL. For example:
https://demo.metricinsights.com/editor/kpialertrule/edit/id/2891
- Modify any parameters of this request according to your requirements
- Run Request
Combination of Multiple Alerts Rule Types
- Item: alert_rule
- Method: POST
- ID: Find an existing Alert with a Compound type that you wish to use as a foundation for the new Alert; open its Editor and find its ID in the web browser URL. For example:
https://demo.metricinsights.com/editor/kpialertrule/edit/id/2891
- Modify any parameters of this request according to your requirements
- Run Request
Global Alert Rule Type
- Item: alert_rule
- Method: POST
- ID: Find an existing Global Alert Rule that you wish to use as a foundation for the new Alert; open its Editor and find its ID in the web browser URL. For example:
https://demo.metricinsights.com/editor/alertrule/edit/id/1456
- Modify any parameters of this request according to your requirements
- Run Request
User Alert Subscriptions
You can use API toolkit to easily manage users' Alert subscriptions.
View all User Subscriptions to Alerts
You can review all the Alerts certain user is subscribed to.
- Item: alert_user_share
- Method: GET
- User: Specify user ID. To determine the ID of a specific user, open the User Editor and find ID in the web browser URL. For example:
https://demo.metricinsights.com/admin/user/edit/id/1
4. Request URL (generated automatically):
https://demo.metricinsights.com/api/alert_rule_user_share?user=1
5. Run Request
NOTE:
Dimension value "-1" stands for all dimension values.
Create User Subscription to an Alert Rule
You can subscribe users to specific Alert Rules (one user to one Alert rule at a time).
- Item: alert_rule_user_share
- Method: POST
- ID: Enter the ID of previously created "alert_rule+user" combination. To see the list of all such pairs, choose GET method, leave ID, alert_rule and user fields empty and Run Request. All "alert_rule+user" combinations are going to be displayed in the Raw response field. Choose the one that is supposed to serve as a foundation for the new combination.
- alert_rule: Specify the alert rule ID. To determine the ID of a specific Alert, open the Alert Editor and find ID in the web browser URL. For example:
https://demo.metricinsights.com/editor/kpialertrule/edit/id/9
5. User: Specify user ID. To determine the ID of a specific user, open the User Editor and find ID in the web browser URL. For example:
https://demo.metricinsights.com/admin/user/edit/id/1
6. Run Request
Unsubscribe a User from the Alert Rule
This procedure allows deleting certain alert rule subscriptions.
- Item: alert_rule_user_share
- Method: DELETE
- ID: Enter the ID of the "alert_rule+user" combination to be deleted. To see the list of all such pairs, choose GET method, leave ID, alert_rule and user fields empty and Run Request. All "alert_rule+user" combinations are going to be displayed in the Raw response field. Choose the one which is supposed to be deleted.
- Run Request
NOTE: If the "alert_rule+user" combination is successfully deleted, the Raw response field is going to be empty.