Table of Contents
- alerting
- Alerting
- get_alertmanager_alerts
- create_or_update_alertmanager_alerts
- get_alertmanager_group_alerts
- delete_alertmanager_silence_by_id
- get_alertmanager_silence_by_id
- get_alertmanager_silences
- create_or_update_alertmanager_silence
- get_alertmanager_status
- delete_alertmanager_config
- get_alertmanager_config
- create_or_update_alertmanager_config
- test_alertmanager_receivers
- get_prometheus_alerts
- get_prometheus_rules
- get_ruler_rules
- delete_ruler_namespace
- get_ruler_groups_by_namespace
- create_or_update_ruler_group_by_namespace
- delete_ruler_group
- get_ruler_group
- test_rule
- test_recipient_rule
- delete_ngalert_organization_configuration
- get_ngalert_organization_configuration
- create_or_update_ngalert_organization_configuration
- get_ngalert_alertmanagers_by_organization
alerting
Alerting Objects
class Alerting()
The class includes all necessary methods to access the Grafana alerting API endpoints
Arguments:
grafana_api_model
APIModel - Inject a Grafana API model object that includes all necessary values and information
Attributes:
grafana_api_model
APIModel - This is where we store the grafana_api_model
get_alertmanager_alerts
def get_alertmanager_alerts(recipient: any = "grafana") -> list
The method includes a functionality to get the Alertmanager alerts specified by the recipient
Arguments:
recipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
list - Returns the list of Alertmanager alerts
create_or_update_alertmanager_alerts
def create_or_update_alertmanager_alerts(alerts: list,
recipient: any = "grafana")
The method includes a functionality to create or update the Alertmanager alerts specified by the recipient and the alerts list
Arguments:
alerts
list - Specify a list of the alert objectsrecipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
get_alertmanager_group_alerts
def get_alertmanager_group_alerts(recipient: any = "grafana") -> list
The method includes a functionality to get the Alertmanager group alerts specified by the recipient
Arguments:
recipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
list - Returns the list of Alertmanager group alerts
delete_alertmanager_silence_by_id
def delete_alertmanager_silence_by_id(silence_id: str,
recipient: any = "grafana")
The method includes a functionality to delete the Alertmanager silence specified by the silence id and the recipient
Arguments:
silence_id
str - Specify the silence id of the alertsrecipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
get_alertmanager_silence_by_id
def get_alertmanager_silence_by_id(silence_id: str,
recipient: any = "grafana") -> dict
The method includes a functionality to get the Alertmanager silence specified by the silence id and the recipient
Arguments:
silence_id
str - Specify the silence id of the alertsrecipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the dict of Alertmanager silence alert
get_alertmanager_silences
def get_alertmanager_silences(recipient: any = "grafana") -> list
The method includes a functionality to get all Alertmanager silences specified by the recipient
Arguments:
recipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
list - Returns the list of Alertmanager silence alerts
create_or_update_alertmanager_silence
def create_or_update_alertmanager_silence(silence: Silence,
recipient: any = "grafana") -> dict
The method includes a functionality to create or update the Alertmanager silence specified by the silence object and the recipient
Arguments:
silence -> Specify the silence object
- recipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the dict of newly created silence alert
get_alertmanager_status
def get_alertmanager_status(recipient: str = "grafana") -> dict
The method includes a functionality to get the Alertmanager status specified by the recipient
Arguments:
recipient
str - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the dict of the Alertmanager status
delete_alertmanager_config
def delete_alertmanager_config(recipient: any = "grafana")
The method includes a functionality to delete the Alertmanager config specified by the recipient
Arguments:
recipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
get_alertmanager_config
def get_alertmanager_config(recipient: any = "grafana") -> dict
The method includes a functionality to get the Alertmanager config specified by the recipient
Arguments:
recipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the dict of the Alertmanager config
create_or_update_alertmanager_config
def create_or_update_alertmanager_config(
alertmanager_config: AlertmanagerConfig,
recipient: any = "grafana",
template_files: dict = None)
The method includes a functionality to create or update the Alertmanager config specified by the Alertmanager config object, recipient and template_files
Arguments:
alertmanager_config
AlertmanagerConfig - Specify the Alertmanager config objectrecipient
any - Specify the recipient datasource id of the alerts (default grafana)template_files(dict)
- Specify the optional template files (default None)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
test_alertmanager_receivers
def test_alertmanager_receivers(alert: dict,
receivers: list,
recipient: any = "grafana")
The method includes a functionality to test the Alertmanager receivers specified by the alert dict, receivers object and the recipient
Arguments:
alert
dict - Specify the alert dictreceivers
list - Specify the list of AlertmanagerReceivers objectsrecipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
get_prometheus_alerts
def get_prometheus_alerts(recipient: any = "grafana") -> dict
The method includes a functionality to get all prometheus alerts specified by the recipient
Arguments:
recipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the dict of the prometheus alerts
get_prometheus_rules
def get_prometheus_rules(recipient: any = "grafana") -> dict
The method includes a functionality to get all prometheus rules specified by the recipient
Arguments:
recipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the dict of the prometheus rules
get_ruler_rules
def get_ruler_rules(recipient: str = "grafana") -> dict
The method includes a functionality to get all ruler rules specified by the recipient
Arguments:
recipient
str - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the dict of the ruler rules
delete_ruler_namespace
def delete_ruler_namespace(namespace: str, recipient: any = "grafana")
The method includes a functionality to delete a ruler namespace specified by the namespace name and the recipient
Arguments:
namespace
str - Specify the namespace namerecipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
get_ruler_groups_by_namespace
def get_ruler_groups_by_namespace(namespace: str,
recipient: any = "grafana") -> dict
The method includes a functionality to get all ruler groups specified by the namespace name and the recipient
Arguments:
namespace
str - Specify the namespace namerecipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the dict of the ruler groups
create_or_update_ruler_group_by_namespace
def create_or_update_ruler_group_by_namespace(namespace: str,
group_name: str,
rules: list,
recipient: any = "grafana",
interval: int = 0)
The method includes a functionality to create or update a ruler group specified by the namespace name, a ruler group name, a ruler rule object list, the recipient and an interval
Arguments:
namespace
str - Specify the namespace namegroup_name
str - Specify the ruler group namerules
list - Specify the ruler rule object listrecipient
any - Specify the recipient datasource id of the alerts (default grafana)interval
int - Specify the interval of the ruler (default 0)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
delete_ruler_group
def delete_ruler_group(namespace: str,
group_name: str,
recipient: any = "grafana")
The method includes a functionality to delete a ruler group specified by the namespace name, a ruler group name and the recipient
Arguments:
namespace
str - Specify the namespace namegroup_name
str - Specify the ruler group namerecipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
get_ruler_group
def get_ruler_group(namespace: str,
group_name: str,
recipient: any = "grafana") -> dict
The method includes a functionality to get a ruler group specified by the namespace name, a ruler group name and the recipient
Arguments:
namespace
str - Specify the namespace namegroup_name
str - Specify the ruler group namerecipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the dict of all ruler groups
test_rule
def test_rule(data_query: list) -> dict
The method includes a functionality to test a rule specified by a list of datasource rule query objects
Arguments:
data_query
list - Specify a list of datasource rule query objects
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
str - Returns the result of the specified query
test_recipient_rule
def test_recipient_rule(expr: str,
condition: str,
data_query: list,
recipient: any = "grafana") -> dict
The method includes a functionality to test a recipient role specified by the expr, the condition, a list of data queries and the recipient
Arguments:
expr
str - Specify a list of datasource rule query objectscondition
str - Specify the conditiondata_query
list - Specify a list of datasource rule query objectsrecipient
any - Specify the recipient datasource id of the alerts (default grafana)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the result of the specified recipient rule
delete_ngalert_organization_configuration
def delete_ngalert_organization_configuration()
The method includes a functionality to delete the NGAlert organization admin configuration
Raises:
Exception
- Unspecified error by executing the API call
Returns:
None
get_ngalert_organization_configuration
def get_ngalert_organization_configuration() -> dict
The method includes a functionality to get the NGAlert organization admin configuration
Raises:
Exception
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the NGAlert organization configuration
create_or_update_ngalert_organization_configuration
def create_or_update_ngalert_organization_configuration(
alert_managers: list, alertmanagers_choice: str = "all")
The method includes a functionality to create or update the NGAlert organization admin configuration
Arguments:
alert_managers
list - Specify the list of alert manager namesalertmanagers_choice
str - Specify the Alertmanagers choice (default all)
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
get_ngalert_alertmanagers_by_organization
def get_ngalert_alertmanagers_by_organization() -> dict
The method includes a functionality to get the discovered and dropped Alertmanagers of the user's organization and based on the specified configuration
Raises:
Exception
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the NGAlert Alertmanagers