API Reference

class grafana_dashboards.grafana.Grafana(url, key=None)

Create object for grafana instance

Parameters:
  • url (str) – URL for Grafana server

  • key (str) – API token used for authenticate

class grafana_dashboards.grafana.datasource.Datasource(url, session)
create(name, data)

Create a new datasource

Parameters:
  • name (str) – URL friendly title of the datasource

  • data (dict) – Datasource model

Raises:

Exception – if datasource already exists

delete(datasource_id)

Delete a datasource

Parameters:

datasource_id (int) – Id number of datasource

Raises:

Exception – if datasource failed to delete

get(datasource_id)

Get a datasource

Parameters:

datasource_id (int) – Id number of datasource

Return type:

dict or None

get_all()

List all datasource

Return type:

dict

is_datasource(name)

Check if a datasource exists

Parameters:

name (str) – URL friendly title of the dashboard

Returns:

if datasource exists return id number.

Return type:

int

update(datasource_id, data)

Update an existing datasource

Parameters:
  • datasource_id (int) – URL friendly title of the dashboard

  • data (dict) – Datasource model

  • overwrite (bool) – Overwrite existing dashboard with newer version or with the same dashboard title

Raises:

Exception – if datasource already exists

class grafana_dashboards.grafana.dashboard.Dashboard(url, session)
create(name, data, overwrite=False, folder_id=0)

Create a new dashboard

Parameters:
  • name (str) – URL friendly title of the dashboard

  • data (dict) – Dashboard model

  • overwrite (bool) – Overwrite existing dashboard with newer version or with the same dashboard title

  • folder_id (int) – The id of the folder to save the dashboard in.

Raises:

Exception – if dashboard already exists

dashboard_uid(name)
delete(name)

Delete a dashboard

Parameters:

name (str) – URL friendly title of the dashboard

Raises:

Exception – if dashboard failed to delete

get(name)

Get a dashboard

Parameters:

name (str) – URL friendly title of the dashboard

Return type:

dict or None

is_dashboard(name)

Check if a dashboard exists

Parameters:

name (str) – URL friendly title of the dashboard

Returns:

True if dashboard exists

Return type:

bool