From 1fb8149f7e25cbc40f3dea428ec1c59526423e3d Mon Sep 17 00:00:00 2001 From: hoangphuocbk Date: Wed, 5 Jul 2023 23:08:40 +0700 Subject: [PATCH 1/3] add Quickwit datasource --- plugins/modules/grafana_datasource.py | 2 + .../grafana_datasource/tasks/quickwit.yml | 138 ++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 tests/integration/targets/grafana_datasource/tasks/quickwit.yml diff --git a/plugins/modules/grafana_datasource.py b/plugins/modules/grafana_datasource.py index 1c0253b9..b33acc7e 100644 --- a/plugins/modules/grafana_datasource.py +++ b/plugins/modules/grafana_datasource.py @@ -48,6 +48,7 @@ - loki - redis-datasource - tempo + - quickwit-quickwit-datasource type: str ds_url: description: @@ -790,6 +791,7 @@ def setup_module_object(): "redis-datasource", "loki", "tempo", + "quickwit-quickwit-datasource", ] ), ds_url=dict(type="str"), diff --git a/tests/integration/targets/grafana_datasource/tasks/quickwit.yml b/tests/integration/targets/grafana_datasource/tasks/quickwit.yml new file mode 100644 index 00000000..4cff7906 --- /dev/null +++ b/tests/integration/targets/grafana_datasource/tasks/quickwit.yml @@ -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 From fa4f21a73fa271234d8b6e24afdc5c12fd56c92d Mon Sep 17 00:00:00 2001 From: hoangphuocbk Date: Wed, 25 Oct 2023 20:09:52 +0700 Subject: [PATCH 2/3] add Quickwit change log --- changelogs/fragments/308_datasource_quickwit.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/308_datasource_quickwit.yml diff --git a/changelogs/fragments/308_datasource_quickwit.yml b/changelogs/fragments/308_datasource_quickwit.yml new file mode 100644 index 00000000..d91a1308 --- /dev/null +++ b/changelogs/fragments/308_datasource_quickwit.yml @@ -0,0 +1,2 @@ +minor_changes: + - Add Quickwit search engine datasource (https://quickwit.io). From 360a22c29d2246a5ef39af3b04a0eb4b2d851949 Mon Sep 17 00:00:00 2001 From: Nemental <15136847+Nemental@users.noreply.github.com> Date: Thu, 4 Jan 2024 14:18:55 +0100 Subject: [PATCH 3/3] style: ansible lint tests --- .../grafana_datasource/tasks/quickwit.yml | 137 +++++++++--------- 1 file changed, 68 insertions(+), 69 deletions(-) diff --git a/tests/integration/targets/grafana_datasource/tasks/quickwit.yml b/tests/integration/targets/grafana_datasource/tasks/quickwit.yml index 4cff7906..8221dcb4 100644 --- a/tests/integration/targets/grafana_datasource/tasks/quickwit.yml +++ b/tests/integration/targets/grafana_datasource/tasks/quickwit.yml @@ -1,138 +1,137 @@ --- - - name: Create Quickwit datasource register: result - grafana_datasource: - name: "Quickwit" + community.grafana.grafana_datasource: + name: Quickwit grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: quickwit-quickwit-datasource ds_url: http://localhost:7280/api/v1 additional_json_data: - index: 'hdfs-logs' + index: hdfs-logs timeField: timestamp timeOutputFormat: unix_timestamp_secs logMessageField: body logLevelField: severity_text -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.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' + - 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" + community.grafana.grafana_datasource: + name: Quickwit grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: quickwit-quickwit-datasource ds_url: http://localhost:7280/api/v1 additional_json_data: - index: 'hdfs-logs' + index: hdfs-logs timeField: timestamp timeOutputFormat: unix_timestamp_secs logMessageField: body logLevelField: severity_text -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.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' + - 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" + community.grafana.grafana_datasource: + name: Quickwit grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" - org_id: '1' + org_id: "1" ds_type: quickwit-quickwit-datasource ds_url: http://quickwit-url:7280/api/v1 additional_json_data: - index: 'hdfs-logs' + index: hdfs-logs timeField: timestamp timeOutputFormat: unix_timestamp_millis logMessageField: body logLevelField: severity_text -- debug: +- ansible.builtin.debug: var: result -- assert: +- ansible.builtin.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' + - 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" + community.grafana.grafana_datasource: + name: Quickwit grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- assert: +- ansible.builtin.assert: that: - - result.changed + - result.changed - name: Delete Quickwit datasource (idempotency) register: result - grafana_datasource: - name: "Quickwit" + community.grafana.grafana_datasource: + name: Quickwit grafana_url: "{{ grafana_url }}" grafana_user: "{{ grafana_username }}" grafana_password: "{{ grafana_password }}" state: absent -- assert: +- ansible.builtin.assert: that: - - not result.changed + - not result.changed