Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mssql datasource #307

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/304-mssql_datasource.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- added mssql to datasource module
24 changes: 21 additions & 3 deletions plugins/modules/grafana_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- sni-thruk-datasource
- camptocamp-prometheus-alertmanager-datasource
- loki
- mssql
- redis-datasource
type: str
ds_url:
Expand Down Expand Up @@ -169,7 +170,7 @@
default: '@timestamp'
time_interval:
description:
- Minimum group by interval for C(influxdb), C(elasticsearch) or C(prometheus) datasources.
- Minimum group by interval for C(influxdb), C(elasticsearch), C(prometheus), or C(mssql) datasources.
- for example C(>10s).
type: str
interval:
Expand Down Expand Up @@ -463,6 +464,22 @@
additional_secure_json_data:
httpHeaderValue1: "Bearer ihavenogroot"
enforce_secure_data: true

- name: Create Grafana data source
community.grafana.grafana_datasource:
name: "datasource-mssql"
grafana_url: "https://grafana.company.com"
grafana_user: "admin"
grafana_password: "xxxxxx"
org_id: "1"
ds_type: "mssql"
ds_url: "mssql.company.com"
time_interval: 5s
database: "SQLWATCH"
user: sqlwatch
additional_secure_json_data:
password: "xxxxxx"
delegate_to: localhost
'''

RETURN = '''
Expand Down Expand Up @@ -619,7 +636,7 @@ def get_datasource_payload(data):
es_version = ES_VERSION_MAPPING.get(data['es_version'])
json_data['esVersion'] = es_version

if data['ds_type'] in ['elasticsearch', 'influxdb', 'prometheus']:
if data['ds_type'] in ['elasticsearch', 'influxdb', 'prometheus', 'mssql']:
if data.get('time_interval'):
json_data['timeInterval'] = data['time_interval']

Expand Down Expand Up @@ -742,7 +759,8 @@ def setup_module_object():
'camptocamp-prometheus-alertmanager-datasource',
'sni-thruk-datasource',
'redis-datasource',
'loki']),
'loki',
'mssql']),
ds_url=dict(type='str'),
access=dict(default='proxy', choices=['proxy', 'direct']),
database=dict(type='str', default=""),
Expand Down
Loading