Operations

grafanarmadillo.bulk

Perform bulk operations on Grafana.

BulkOperations defines the basic interface. It is meant to be parametrised in 2 phases: - information source: Subclasses of BulkOperations implement methods to get orgs and resources - actions: Subclasses of those classes implement the actions to take

For example:

BulkGrafanaOperation uses a Grafana instance as its source BulkExporter uses BulkGrafanaOperations to list all objects and write them to disk

class grafanarmadillo.bulk.BulkExporter(cfg: dict, root_directory: Path, templator: Templator)[source]

Export all resources from Grafana to files.

each_alert(path: Path, alert: AlertContent)[source]

Write each alert to files.

each_dashboard(path: Path, dashboard: DashboardContent)[source]

Write each dashboard to files.

class grafanarmadillo.bulk.BulkFileOperation(cfg: dict, root_directory: Path)[source]

Bulk operation which uses a filetree as its source.

all_orgs() Generator[Tuple[OrgMeta, GrafanaApi], None, None][source]

Iterate over all organisations in Grafana.

get_all_alerts(org: OrgMeta, gfn: GrafanaApi) Generator[Tuple[Path, AlertContent], None, None][source]

Get all alerts.

get_all_dashboards(org: OrgMeta, gfn: GrafanaApi) Generator[Tuple[Path, DashboardContent], None, None][source]

Get all dashboards.

class grafanarmadillo.bulk.BulkGrafanaOperation(cfg: dict)[source]

Bulk operations which uses a Grafana instance as its source.

all_orgs() Generator[Tuple[OrgMeta, GrafanaApi], None, None][source]

Iterate over all organisations in Grafana.

get_all_alerts(org: OrgMeta, gfn: GrafanaApi) Generator[Tuple[Path, AlertContent], None, None][source]

Get all alerts.

get_all_dashboards(org: OrgMeta, gfn: GrafanaApi) Generator[Tuple[Path, DashboardContent], None, None][source]

Get all dashboards.

class grafanarmadillo.bulk.BulkImporter(cfg: dict, root_directory: Path, templator: Templator)[source]

Import all resources from files into Grafana.

each_alert(path: Path, alert: AlertContent)[source]

Import each alert into Grafana.

each_dashboard(path: Path, dashboard: DashboardContent)[source]

Import each dashboard into Grafana.

class grafanarmadillo.bulk.BulkOperation(cfg: dict)[source]

Run bulk operations on Grafana.

abstract all_orgs() Generator[Tuple[OrgMeta, GrafanaApi], None, None][source]

Iterate over all organisations.

This method should be implemented for each source of information.

abstract each_alert(path: Path, alert: AlertContent)[source]

Act on each alert in Grafana.

This method should be implemented for each operation.

abstract each_dashboard(path: Path, dashboard: DashboardContent)[source]

Act on each dashboard in Grafana.

This method should be implemented for each operation.

abstract get_all_alerts(org: OrgMeta, gfn: GrafanaApi) Generator[Tuple[Path, AlertContent], None, None][source]

Iterate over all alerts.

This method should be implemented for each source of information.

abstract get_all_dashboards(org: OrgMeta, gfn: GrafanaApi) Generator[Tuple[Path, DashboardContent], None, None][source]

Iterate over all dashboards.

This method should be implemented for each source of information.

run()[source]

Run this bulk operation.

grafanarmadillo.bulk.get_all_orgs(gfn_multiorg) List[OrgMeta][source]

Get a list of all orgs.

grafanarmadillo.bulk.get_org(gfn_multiorg, org_name: str)[source]

Get an org by name, efficiently.

grafanarmadillo.migrate