Skip to content

Table of Contents

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 value
  • Exception - 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 objects
  • recipient any - Specify the recipient datasource id of the alerts (default grafana)

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - 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 value
  • Exception - 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 alerts
  • recipient any - Specify the recipient datasource id of the alerts (default grafana)

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - 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 alerts
  • recipient any - Specify the recipient datasource id of the alerts (default grafana)

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - 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 value
  • Exception - 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 value
  • Exception - 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 value
  • Exception - 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 value
  • Exception - 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 value
  • Exception - 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 object
  • recipient 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 value
  • Exception - 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 dict
  • receivers list - Specify the list of AlertmanagerReceivers objects
  • recipient any - Specify the recipient datasource id of the alerts (default grafana)

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - 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 value
  • Exception - 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 value
  • Exception - 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 value
  • Exception - 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 name
  • recipient any - Specify the recipient datasource id of the alerts (default grafana)

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - 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 name
  • recipient any - Specify the recipient datasource id of the alerts (default grafana)

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - 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 name
  • group_name str - Specify the ruler group name
  • rules list - Specify the ruler rule object list
  • recipient 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 value
  • Exception - 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 name
  • group_name str - Specify the ruler group name
  • recipient any - Specify the recipient datasource id of the alerts (default grafana)

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - 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 name
  • group_name str - Specify the ruler group name
  • recipient any - Specify the recipient datasource id of the alerts (default grafana)

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - 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 value
  • Exception - 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 objects
  • condition str - Specify the condition
  • data_query list - Specify a list of datasource rule query objects
  • recipient any - Specify the recipient datasource id of the alerts (default grafana)

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - 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 names
  • alertmanagers_choice str - Specify the Alertmanagers choice (default all)

Raises:

  • ValueError - Missed specifying a necessary value
  • Exception - 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