grafana_datasource – Manage Grafana datasources
grafana_datasource – Manage Grafana datasources
New in version 2.5.
Synopsis
- Create/update/delete Grafana datasources via API.
Parameters
Parameter | Choices/Defaults | Comments |
---|---|---|
access - |
|
The access mode for this datasource. |
aws_access_key - added in 2.8 |
Default: "" |
AWS access key for CloudWatch datasource type when |
aws_assume_role_arn - added in 2.8 |
Default: "" |
AWS IAM role arn to assume for CloudWatch datasource type when |
aws_auth_type - added in 2.8 |
|
Type for AWS authentication for CloudWatch datasource type (authType of grafana api) |
aws_credentials_profile - added in 2.8 |
Default: "" |
Profile for AWS credentials for CloudWatch datasource type when |
aws_custom_metrics_namespaces - added in 2.8 |
Default: "" |
Namespaces of Custom Metrics for CloudWatch datasource type |
aws_default_region - added in 2.8 |
|
AWS default region for CloudWatch datasource type |
aws_secret_key - added in 2.8 |
Default: "" |
AWS secret key for CloudWatch datasource type when |
basic_auth_password - |
The datasource basic auth password, when | |
basic_auth_user - |
The datasource basic auth user. Setting this option with basic_auth_password will enable basic auth. | |
client_cert - added in 2.8 |
TLS certificate path used by ansible to query grafana api | |
client_key - added in 2.8 |
TLS private key path used by ansible to query grafana api | |
database - |
Name of the database for the datasource. This options is required when the | |
ds_type - / required |
|
The type of the datasource. |
es_version - |
|
Elasticsearch version (for Version 56 is for elasticsearch 5.6+ where tou can specify the |
grafana_api_key - |
The Grafana API key. If set, | |
grafana_url - / required |
The Grafana URL. | |
interval - |
|
For elasticsearch |
is_default boolean |
|
Make this datasource the default one. |
max_concurrent_shard_requests - |
Default: 256 |
Starting with elasticsearch 5.6, you can specify the max concurrent shard per requests. |
name - / required |
The name of the datasource. | |
org_id - |
Default: 1 |
Grafana Organisation ID in which the datasource should be created. Not used when |
password - |
The datasource password | |
sslmode - |
|
SSL mode for |
state - |
|
Status of the datasource |
time_field - |
Default: "timestamp" |
Name of the time field in elasticsearch ds. For example |
time_interval - |
Minimum group by interval for for example | |
tls_ca_cert - |
The TLS CA certificate for self signed certificates. Only used when | |
tls_client_cert - |
The client TLS certificate. If Starts with ----- BEGIN CERTIFICATE ----- | |
tls_client_key - |
The client TLS private key Starts with ----- BEGIN RSA PRIVATE KEY ----- | |
tls_skip_verify boolean added in 2.6 |
|
Skip the TLS datasource certificate verification. |
trends boolean added in 2.6 |
|
Use trends or not for zabbix datasource type |
tsdb_resolution - |
|
The opentsdb time resolution. |
tsdb_version - |
|
The opentsdb version. Use |
url - / required |
The URL of the datasource.
| |
url_password - added in 2.7 |
Default: "admin" |
The Grafana API password.
|
url_username - added in 2.7 |
Default: "admin" |
The Grafana API user.
|
use_proxy boolean added in 2.8 |
|
Boolean of whether or not to use proxy. |
user - |
The datasource login user for influxdb datasources. | |
validate_certs boolean |
|
Whether to validate the Grafana certificate. |
with_credentials boolean |
|
Whether credentials such as cookies or auth headers should be sent with cross-site requests. |
Examples
---
- name: Create elasticsearch datasource
grafana_datasource:
name: "datasource-elastic"
grafana_url: "https://grafana.company.com"
grafana_user: "admin"
grafana_password: "xxxxxx"
org_id: "1"
ds_type: "elasticsearch"
ds_url: "https://elastic.company.com:9200"
database: "[logstash_]YYYY.MM.DD"
basic_auth_user: "grafana"
basic_auth_password: "******"
time_field: "@timestamp"
time_interval: "1m"
interval: "Daily"
es_version: 56
max_concurrent_shard_requests: 42
tls_ca_cert: "/etc/ssl/certs/ca.pem"
- name: Create influxdb datasource
grafana_datasource:
name: "datasource-influxdb"
grafana_url: "https://grafana.company.com"
grafana_user: "admin"
grafana_password: "xxxxxx"
org_id: "1"
ds_type: "influxdb"
ds_url: "https://influx.company.com:8086"
database: "telegraf"
time_interval: ">10s"
tls_ca_cert: "/etc/ssl/certs/ca.pem"
- name: Create postgres datasource
grafana_datasource:
name: "datasource-postgres"
grafana_url: "https://grafana.company.com"
grafana_user: "admin"
grafana_password: "xxxxxx"
org_id: "1"
ds_type: "postgres"
ds_url: "postgres.company.com:5432"
database: "db"
user: "postgres"
password: "iampgroot"
sslmode: "verify-full"
- name: Create cloudwatch datasource
grafana_datasource:
name: "datasource-cloudwatch"
grafana_url: "https://grafana.company.com"
grafana_user: "admin"
grafana_password: "xxxxxx"
org_id: "1"
ds_type: "cloudwatch"
url: "http://monitoring.us-west-1.amazonaws.com"
aws_auth_type: "keys"
aws_default_region: "us-west-1"
aws_access_key: "speakFriendAndEnter"
aws_secret_key: "mel10n"
aws_custom_metrics_namespaces: "n1,n2"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
after dictionary |
changed |
datasource updated by module
Sample: {'access': 'proxy', 'basicAuth': False, 'database': 'test_*', 'id': 1035, 'isDefault': False, 'jsonData': {'esVersion': 5, 'timeField': '@timestamp', 'timeInterval': '10s'}, 'name': 'grafana_datasource_test', 'orgId': 1, 'type': 'elasticsearch', 'url': 'http://elastic.company.com:9200', 'user': , 'password': , 'withCredentials': False} |
before dictionary |
changed |
datasource returned by grafana api
Sample: {'access': 'proxy', 'basicAuth': False, 'database': 'test_*', 'id': 1035, 'isDefault': False, 'jsonData': {'esVersion': 5, 'timeField': '@timestamp', 'timeInterval': '1m'}, 'name': 'grafana_datasource_test', 'orgId': 1, 'type': 'elasticsearch', 'url': 'http://elastic.company.com:9200', 'user': , 'password': , 'withCredentials': False} |
id integer |
success |
Id of the datasource
Sample: 42 |
name string |
success |
name of the datasource created.
Sample: test-ds |
Status
- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]
Authors
- Thierry Sallé (@seuf)
- Martin Wang (@martinwangjian)
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.8/modules/grafana_datasource_module.html