New in version 2.5.
Parameter |
Choices/Defaults |
Comments |
---|---|---|
access
|
|
Access mode for this datasource
|
basic_auth_password
|
|
Datasource basic auth password, when basic auth is true
|
basic_auth_user
|
|
Datasource basic auth user.
Setting this option with basic_auth_password will enable basic auth.
|
database
|
|
Name of the database for the datasource.
This options is required when the ds_type is influxdb, elasticsearch (index name), mysql or postgres
|
ds_type
required |
|
Type of the datasource
|
es_version
|
|
Elasticsearch version (for ds_type = elasticsearch only)
Version 56 is for elasticsearch 5.6+ where tou can specify the max_concurrent_shard_requests option.
|
grafana_api_key
|
|
Grafana API key
If set, grafana_user and grafana_password will be ignored
|
grafana_password
|
Default:
admin
|
Grafana API password
|
grafana_url
required |
|
Grafana url
|
grafana_user
|
Default:
admin
|
Grafana API user
|
interval
|
|
for elasticsearch ds_type, this is the index pattern used.
|
is_default
|
Default:
no
|
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 |
|
Name of the datasource
|
org_id
|
Default:
yes
|
Grafana Organisation ID in which the datasource should be created
Not used when grafana_api_key is set, because the grafana_api_key only belong to one organisation.
|
password
|
|
Datasource password
|
sslmode
|
|
SSL mode for postgres datasoure type.
|
state
|
|
Status of the datasource
|
time_field
|
Default:
timestamp
|
Name of the time field in elasticsearch ds
For example
@timestamp |
time_interval
|
|
Minimum group by interval for influxdb or elasticsearch datasources
for example '>10s'
|
tls_ca_cert
|
|
tls ca certificate for self signed certificates.
only used when tls_client_cert and tls_client_key are set
|
tls_client_cert
|
|
client tls certificate.
If tls_client_cert and tls_client_key are set, this will enable tls auth.
begins with ----- BEGIN CERTIFICATE -----
|
tls_client_key
|
|
client tls private key
befins with ----- BEGIN RSA PRIVATE KEY -----
|
tsdb_resolution
|
yes
|
opentsdb time resolution
|
tsdb_version
|
yes
|
opentsdb version (1 for <= 2.1, 2 for ==2.2, 3 for ==2.3)
|
url
required |
|
Url of the datasource
|
user
|
|
Datasource login user for influxdb datasources
|
validate_certs
|
Default:
yes
|
Validate or not grafana certificate
|
with_credentials
|
Default:
no
|
Whether credentials such as cookies or auth headers should be sent with cross-site requests.
|
---
- name: create elasticsearch datasource
grafana_datasource:
name: my_elastic
grafana_url: http://grafana.company.com
type: elasticsearch
url: https://elasticsearch.company.com:9200
database: my-index_*
basic_auth: true
basic_auth_user: grafana
basic_auth_password: xxxxxxxx
json_data: '{"esVersion":5, "timeField": "@timestamp"}'
state: present
Common return values are documented here, the following are the fields unique to this module:
Key |
Returned |
Description |
---|---|---|
after
dict
|
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
dict
|
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
int
|
success |
Id of the datasource
Sample:
42
|
name
string
|
success |
name of the datasource created.
Sample:
test-ds
|
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
Hint
If you notice any issues in this documentation you can edit this document to improve it.