grafana4

Module for working with the Grafana v4 API

Added in version 2017.7.0.

depends:

requests

configuration:

This module requires a configuration profile to be configured in the minion config, minion pillar, or master config. The module will use the ‘grafana’ key by default, if defined.

For example:

grafana:
    grafana_url: http://grafana.localhost
    grafana_user: admin
    grafana_password: admin
    grafana_timeout: 3
saltext.grafana.modules.grafana4.__virtual__()[source]

Only load if requests is installed

saltext.grafana.modules.grafana4.get_users(profile='grafana')[source]

List all users.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.get_users
saltext.grafana.modules.grafana4.get_user(login, profile='grafana')[source]

Show a single user.

login

Login of the user.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.get_user <login>
saltext.grafana.modules.grafana4.get_user_data(userid, profile='grafana')[source]

Get user data.

userid

Id of the user.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.get_user_data <user_id>
saltext.grafana.modules.grafana4.create_user(profile='grafana', **kwargs)[source]

Create a new user.

login

Login of the new user.

password

Password of the new user.

email

Email of the new user.

name

Optional - Full name of the new user.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.create_user login=<login> password=<password> email=<email>
saltext.grafana.modules.grafana4.update_user(userid, profile='grafana', **kwargs)[source]

Update an existing user.

userid

Id of the user.

login

Optional - Login of the user.

email

Optional - Email of the user.

name

Optional - Full name of the user.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.update_user <user_id> login=<login> email=<email>
saltext.grafana.modules.grafana4.update_user_password(userid, profile='grafana', **kwargs)[source]

Update a user password.

userid

Id of the user.

password

New password of the user.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.update_user_password <user_id> password=<password>
saltext.grafana.modules.grafana4.update_user_permissions(userid, profile='grafana', **kwargs)[source]

Update a user password.

userid

Id of the user.

isGrafanaAdmin

Whether user is a Grafana admin.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.update_user_permissions <user_id> isGrafanaAdmin=<true|false>
saltext.grafana.modules.grafana4.delete_user(userid, profile='grafana')[source]

Delete a user.

userid

Id of the user.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.delete_user <user_id>
saltext.grafana.modules.grafana4.get_user_orgs(userid, profile='grafana')[source]

Get the list of organisations a user belong to.

userid

Id of the user.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.get_user_orgs <user_id>
saltext.grafana.modules.grafana4.delete_user_org(userid, orgid, profile='grafana')[source]

Remove a user from an organization.

userid

Id of the user.

orgid

Id of the organization.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.delete_user_org <user_id> <org_id>
saltext.grafana.modules.grafana4.get_orgs(profile='grafana')[source]

List all organizations.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.get_orgs
saltext.grafana.modules.grafana4.get_org(name, profile='grafana')[source]

Show a single organization.

name

Name of the organization.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.get_org <name>
saltext.grafana.modules.grafana4.switch_org(orgname, profile='grafana')[source]

Switch the current organization.

name

Name of the organization to switch to.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.switch_org <name>
saltext.grafana.modules.grafana4.get_org_users(orgname=None, profile='grafana')[source]

Get the list of users that belong to the organization.

orgname

Name of the organization.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.get_org_users <orgname>
saltext.grafana.modules.grafana4.create_org_user(orgname=None, profile='grafana', **kwargs)[source]

Add user to the organization.

loginOrEmail

Login or email of the user.

role
Role of the user for this organization. Should be one of:
  • Admin

  • Editor

  • Read Only Editor

  • Viewer

orgname

Name of the organization in which users are added.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.create_org_user <orgname> loginOrEmail=<loginOrEmail> role=<role>
saltext.grafana.modules.grafana4.update_org_user(userid, orgname=None, profile='grafana', **kwargs)[source]

Update user role in the organization.

userid

Id of the user.

loginOrEmail

Login or email of the user.

role
Role of the user for this organization. Should be one of:
  • Admin

  • Editor

  • Read Only Editor

  • Viewer

orgname

Name of the organization in which users are updated.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.update_org_user <user_id> <orgname> loginOrEmail=<loginOrEmail> role=<role>
saltext.grafana.modules.grafana4.delete_org_user(userid, orgname=None, profile='grafana')[source]

Remove user from the organization.

userid

Id of the user.

orgname

Name of the organization in which users are updated.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.delete_org_user <user_id> <orgname>
saltext.grafana.modules.grafana4.get_org_address(orgname=None, profile='grafana')[source]

Get the organization address.

orgname

Name of the organization in which users are updated.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.get_org_address <orgname>
saltext.grafana.modules.grafana4.update_org_address(orgname=None, profile='grafana', **kwargs)[source]

Update the organization address.

orgname

Name of the organization in which users are updated.

address1

Optional - address1 of the org.

address2

Optional - address2 of the org.

city

Optional - city of the org.

zip_code

Optional - zip_code of the org.

state

Optional - state of the org.

country

Optional - country of the org.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.update_org_address <orgname> country=<country>
saltext.grafana.modules.grafana4.get_org_prefs(orgname=None, profile='grafana')[source]

Get the organization preferences.

orgname

Name of the organization in which users are updated.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.get_org_prefs <orgname>
saltext.grafana.modules.grafana4.update_org_prefs(orgname=None, profile='grafana', **kwargs)[source]

Update the organization preferences.

orgname

Name of the organization in which users are updated.

theme

Selected theme for the org.

homeDashboardId

Home dashboard for the org.

timezone

Timezone for the org (one of: “browser”, “utc”, or “”).

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.update_org_prefs <orgname> theme=<theme> timezone=<timezone>
saltext.grafana.modules.grafana4.create_org(profile='grafana', **kwargs)[source]

Create a new organization.

name

Name of the organization.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.create_org <name>
saltext.grafana.modules.grafana4.update_org(orgid, profile='grafana', **kwargs)[source]

Update an existing organization.

orgid

Id of the organization.

name

New name of the organization.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.update_org <org_id> name=<name>
saltext.grafana.modules.grafana4.delete_org(orgid, profile='grafana')[source]

Delete an organization.

orgid

Id of the organization.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.delete_org <org_id>
saltext.grafana.modules.grafana4.get_datasources(orgname=None, profile='grafana')[source]

List all datasources in an organisation.

orgname

Name of the organization.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.get_datasources <orgname>
saltext.grafana.modules.grafana4.get_datasource(name, orgname=None, profile='grafana')[source]

Show a single datasource in an organisation.

name

Name of the datasource.

orgname

Name of the organization.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.get_datasource <name> <orgname>
saltext.grafana.modules.grafana4.create_datasource(orgname=None, profile='grafana', **kwargs)[source]

Create a new datasource in an organisation.

name

Name of the data source.

type

Type of the datasource (‘graphite’, ‘influxdb’ etc.).

access

Use proxy or direct.

url

The URL to the data source API.

user

Optional - user to authenticate with the data source.

password

Optional - password to authenticate with the data source.

database

Optional - database to use with the data source.

basicAuth

Optional - set to True to use HTTP basic auth to authenticate with the data source.

basicAuthUser

Optional - HTTP basic auth username.

basicAuthPassword

Optional - HTTP basic auth password.

jsonData

Optional - additional json data to post (eg. “timeInterval”).

isDefault

Optional - set data source as default.

withCredentials

Optional - Whether credentials such as cookies or auth headers should be sent with cross-site requests.

typeLogoUrl

Optional - Logo to use for this datasource.

orgname

Name of the organization in which the data source should be created.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.create_datasource
saltext.grafana.modules.grafana4.update_datasource(datasourceid, profile='grafana', **kwargs)[source]

Update a datasource.

datasourceid

Id of the datasource.

name

Name of the data source.

type

Type of the datasource (‘graphite’, ‘influxdb’ etc.).

access

Use proxy or direct.

url

The URL to the data source API.

user

Optional - user to authenticate with the data source.

password

Optional - password to authenticate with the data source.

database

Optional - database to use with the data source.

basicAuth

Optional - set to True to use HTTP basic auth to authenticate with the data source.

basicAuthUser

Optional - HTTP basic auth username.

basicAuthPassword

Optional - HTTP basic auth password.

jsonData

Optional - additional json data to post (eg. “timeInterval”).

isDefault

Optional - set data source as default.

withCredentials

Optional - Whether credentials such as cookies or auth headers should be sent with cross-site requests.

typeLogoUrl

Optional - Logo to use for this datasource.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.update_datasource <datasourceid>
saltext.grafana.modules.grafana4.delete_datasource(datasourceid, orgname=None, profile='grafana')[source]

Delete a datasource.

datasourceid

Id of the datasource.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.delete_datasource <datasource_id>
saltext.grafana.modules.grafana4.get_dashboard(slug, orgname=None, profile='grafana')[source]

Get a dashboard.

slug

Slug (name) of the dashboard.

orgname

Name of the organization.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.get_dashboard <slug>
saltext.grafana.modules.grafana4.delete_dashboard(slug, orgname=None, profile='grafana')[source]

Delete a dashboard.

slug

Slug (name) of the dashboard.

orgname

Name of the organization.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.delete_dashboard <slug>
saltext.grafana.modules.grafana4.create_update_dashboard(orgname=None, profile='grafana', **kwargs)[source]

Create or update a dashboard.

dashboard

A dict that defines the dashboard to create/update.

overwrite

Whether the dashboard should be overwritten if already existing.

orgname

Name of the organization.

profile

Configuration profile used to connect to the Grafana instance. Default is ‘grafana’.

CLI Example:

salt '*' grafana4.create_update_dashboard dashboard=<dashboard> overwrite=True orgname=<orgname>