Skip to content

Commit

Permalink
add Quickwit datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangphuocbk committed Jul 5, 2023
1 parent 2202c99 commit 4e3f64a
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/modules/grafana_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
- camptocamp-prometheus-alertmanager-datasource
- loki
- redis-datasource
- quickwit-quickwit-datasource
type: str
ds_url:
description:
Expand Down Expand Up @@ -738,7 +739,8 @@ def setup_module_object():
'camptocamp-prometheus-alertmanager-datasource',
'sni-thruk-datasource',
'redis-datasource',
'loki']),
'loki',
'quickwit-quickwit-datasource']),
ds_url=dict(type='str'),
access=dict(default='proxy', choices=['proxy', 'direct']),
database=dict(type='str', default=""),
Expand Down
138 changes: 138 additions & 0 deletions tests/integration/targets/grafana_datasource/tasks/quickwit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---

- name: Create Quickwit datasource
register: result
grafana_datasource:
name: "Quickwit"
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
org_id: '1'
ds_type: quickwit-quickwit-datasource
ds_url: http://localhost:7280/api/v1
additional_json_data:
index: 'hdfs-logs'
timeField: timestamp
timeOutputFormat: unix_timestamp_secs
logMessageField: body
logLevelField: severity_text

- debug:
var: result

- assert:
that:
- result.changed
- result.datasource.access == 'proxy'
- not result.datasource.isDefault
- result.datasource.database == ''
- result.datasource.name == 'Quickwit'
- result.datasource.orgId == 1
- result.datasource.type == 'quickwit-quickwit-datasource'
- result.datasource.url == 'http://localhost:7280/api/v1'
- "result.msg == 'Datasource Quickwit created'"
- result.datasource.jsonData.index == 'hdfs-logs'
- result.datasource.jsonData.timeField == 'timestamp'
- result.datasource.jsonData.timeOutputFormat == 'unix_timestamp_secs'
- result.datasource.jsonData.logMessageField == 'body'
- result.datasource.jsonData.logLevelField == 'severity_text'

- name: Check Quickwit datasource creation (idempotency)
register: result
grafana_datasource:
name: "Quickwit"
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
org_id: '1'
ds_type: quickwit-quickwit-datasource
ds_url: http://localhost:7280/api/v1
additional_json_data:
index: 'hdfs-logs'
timeField: timestamp
timeOutputFormat: unix_timestamp_secs
logMessageField: body
logLevelField: severity_text

- debug:
var: result

- assert:
that:
- not result.changed
- result.datasource.access == 'proxy'
- not result.datasource.isDefault
- result.datasource.database == ''
- result.datasource.name == 'Quickwit'
- result.datasource.orgId == 1
- result.datasource.type == 'quickwit-quickwit-datasource'
- result.datasource.url == 'http://localhost:7280/api/v1'
- "result.msg == 'Datasource Quickwit created'"
- result.datasource.jsonData.index == 'hdfs-logs'
- result.datasource.jsonData.timeField == 'timestamp'
- result.datasource.jsonData.timeOutputFormat == 'unix_timestamp_secs'
- result.datasource.jsonData.logMessageField == 'body'
- result.datasource.jsonData.logLevelField == 'severity_text'

- name: Update Quickwit datasource
register: result
grafana_datasource:
name: "Quickwit"
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
org_id: '1'
ds_type: quickwit-quickwit-datasource
ds_url: http://quickwit-url:7280/api/v1
additional_json_data:
index: 'hdfs-logs'
timeField: timestamp
timeOutputFormat: unix_timestamp_millis
logMessageField: body
logLevelField: severity_text

- debug:
var: result

- assert:
that:
- result.changed
- result.datasource.access == 'proxy'
- not result.datasource.isDefault
- result.datasource.database == ''
- result.datasource.name == 'Quickwit'
- result.datasource.orgId == 1
- result.datasource.type == 'quickwit-quickwit-datasource'
- result.datasource.url == 'http://quickwit-url:7280/api/v1'
- "result.msg == 'Datasource Quickwit created'"
- result.datasource.jsonData.index == 'hdfs-logs'
- result.datasource.jsonData.timeField == 'timestamp'
- result.datasource.jsonData.timeOutputFormat == 'unix_timestamp_millis'
- result.datasource.jsonData.logMessageField == 'body'
- result.datasource.jsonData.logLevelField == 'severity_text'

- name: Delete Quickwit datasource
register: result
grafana_datasource:
name: "Quickwit"
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent

- assert:
that:
- result.changed

- name: Delete Quickwit datasource (idempotency)
register: result
grafana_datasource:
name: "Quickwit"
grafana_url: "{{ grafana_url }}"
grafana_user: "{{ grafana_username }}"
grafana_password: "{{ grafana_password }}"
state: absent

- assert:
that:
- not result.changed

0 comments on commit 4e3f64a

Please sign in to comment.