alertmanager package¶
Submodules¶
alertmanager.alertmanager module¶
-
class
alertmanager.alertmanager.
AlertManager
(host, port=9093, req_obj=None)[source]¶ Bases:
object
Implements and interface to the Alert Manager API.
Alert Manager comes packaged with Prometheus and is used for alert management. This class aims to create an interface that simplifies interactions with the Alert Manager API. It also provides a simple means of introducing alerts into Alert Manager that do not originate from Prometheus.
-
ERROR_STATUSES
= ['error']¶
-
SUCCESS_STATUSES
= ['success']¶
-
delete_silence
(silence_id)[source]¶ Delete a silence.
This method allows us to specify a silence_id and delete it from Alert Manager.
- silence_id : str
- This is the ID of the silence returned by Alert Manager.
- Alert
- Return the response from Alert Manager as an Alert object.
-
get_alert_groups
()[source]¶ Return alerts grouped by label keys.
Another method to return our alerts.
- Alert
- Return the response from Alert Manager as an Alert object.
-
get_alerts
(**kwargs)[source]¶ Get a list of all alerts currently in Alert Manager.
This method returns a list of all firing alerts from our Alert Manager instance.
- **kwargs : dict
- Arbitrary keyword arguments. These kwargs can be used to specify filters to limit the return of our list of alerts to alerts that match our filter.
- list
- Return a list of Alert objects from our Alert Manager instance.
-
get_receivers
()[source]¶ Return a list of available receivers from our Alert Manager instance.
Receivers from an alert manager perspective are notification integrations. Notifications can be sent from Alert Manager to any of The listed receivers. Per Alert Manager documentation, no new receivers are going to be added, so further integrations should be managed via the webhook receiver: https://prometheus.io/docs/alerting/configuration/
- Alert
- Return the response from Alert Manager as an Alert object.
-
get_silence
(id=None)[source]¶ Return a list of alert silences.
Alert Manager allows alerts to be silenced. This call will return a list of all silences that have been created on our Alert Manager instance.
- id : str
- (Default value = None) This is the ID of the silence we want returned.
- Alert
- Return the response from Alert Manager as an Alert object. In this case a list of silences.
-
get_silences
(**kwargs)[source]¶ Get a list of all silences currently in Alert Manager.
This method returns a list of all silences from our Alert Manager instance.
- **kwargs : dict
- Arbitrary keyword arguments. These kwargs can be used to specify filters to limit the return of our list of alerts to silences that match our filter.
- list
- Return a list of Silence objects from our Alert Manager instance.
-
get_status
()[source]¶ Return the status of our Alert Manager instance.
This method returns a great deal of valuable information about our Alert Manager’s current configuration.
- Alert
- Return the response from Alert Manager as an Alert object.
-
post_alerts
(*alert)[source]¶ Post alerts to Alert Manager.
This method is straightforward and it’s name describes what it does. We use this method to post alerts to Alert Manager.
- *alert : list of alerts or single alert
- This is either a list of Alert objects, dictionaries or a single Alert object or dictionary to be posted as an alert to Alert Manager.
- Alert
- Return the response from Alert Manager as an Alert object.
-
post_silence
(silence)[source]¶ Create a silence.
This method can be utilized to silence alerts based on a matches found by alert manager specified in the matchers parameter. Minimum structure for a matcher is as follows: {‘matchers’:
- [
- {
- ‘name’: ‘label’, ‘value’: ‘label_value’
}
], ‘endsAt’: ‘silence end_time’
}
- matcher : dict
- Our matcher is a dict containing keys/values to match an alert.
- Alert
- Return the response from Alert Manager as an Alert object.
-
request_session
¶ Return a requests object used to affect HTTP requests.
This property is intended to be called by the _make_request method so we are always working with request.Sessions, allowing good customization for end users
- _req_obj : requests.Session()
- This is our default requests.Session() object. Can be overridden during instantiation by specifying the req_obj parameter.
-