From 333f997ace72fb8f3b15cfa6fe0aa0eee7a5f0fd Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Thu, 31 Aug 2023 00:21:35 +0200 Subject: [PATCH] Support multiple sample events --- spec/input/spec.yml | 2 +- spec/integration/data_stream/spec.yml | 2 +- .../good_input/sample_event_other.json | 63 +++++++++++++++++++ .../_dev/test/system/test-default-config.yml | 11 +++- .../data_stream/foo/sample_event_one.json | 63 +++++++++++++++++++ .../data_stream/foo/sample_event_two.json | 63 +++++++++++++++++++ 6 files changed, 201 insertions(+), 3 deletions(-) create mode 100644 test/packages/good_input/sample_event_other.json create mode 100644 test/packages/good_v2/data_stream/foo/sample_event_one.json create mode 100644 test/packages/good_v2/data_stream/foo/sample_event_two.json diff --git a/spec/input/spec.yml b/spec/input/spec.yml index 11aad9616..59c5e9c37 100644 --- a/spec/input/spec.yml +++ b/spec/input/spec.yml @@ -48,7 +48,7 @@ spec: $ref: "../integration/data_stream/fields/spec.yml" - description: Sample event file type: file - name: "sample_event.json" + pattern: "^sample_event(_[a-z0-9]+)?.json$" contentMediaType: "application/json" required: false - description: Folder containing development resources diff --git a/spec/integration/data_stream/spec.yml b/spec/integration/data_stream/spec.yml index c1ea4a9b4..6e1101415 100644 --- a/spec/integration/data_stream/spec.yml +++ b/spec/integration/data_stream/spec.yml @@ -65,7 +65,7 @@ spec: required: false - description: Sample event file type: file - name: "sample_event.json" + pattern: "^sample_event(_[a-z0-9]+)?.json$" contentMediaType: "application/json" required: false - description: Folder containing testing related files and sub-folders diff --git a/test/packages/good_input/sample_event_other.json b/test/packages/good_input/sample_event_other.json new file mode 100644 index 000000000..617212c23 --- /dev/null +++ b/test/packages/good_input/sample_event_other.json @@ -0,0 +1,63 @@ +{ + "@timestamp": "2022-11-16T19:00:58.919Z", + "agent": { + "ephemeral_id": "1f2789fe-4041-4b4d-aac2-076a34c5d24f", + "id": "47bdbac3-731d-4b11-9af6-06fba253dba8", + "name": "docker-fleet-agent", + "type": "metricbeat", + "version": "8.5.0" + }, + "data_stream": { + "dataset": "good_input.sql_query", + "namespace": "ep", + "type": "metrics" + }, + "ecs": { + "version": "8.0.0" + }, + "elastic_agent": { + "id": "47bdbac3-731d-4b11-9af6-06fba253dba8", + "snapshot": true, + "version": "8.5.0" + }, + "event": { + "dataset": "good_input.sql_query", + "duration": 1326395, + "module": "sql" + }, + "host": { + "architecture": "x86_64", + "containerized": false, + "hostname": "docker-fleet-agent", + "id": "0addaca3101a43f4a52be882837fb33d", + "ip": [ + "192.168.192.7" + ], + "mac": [ + "02-42-C0-A8-C0-07" + ], + "name": "docker-fleet-agent", + "os": { + "codename": "focal", + "family": "debian", + "kernel": "5.15.0-50-generic", + "name": "Ubuntu", + "platform": "ubuntu", + "type": "linux", + "version": "20.04.5 LTS (Focal Fossa)" + } + }, + "metricset": { + "name": "query", + "period": 10000 + }, + "service": { + "address": "elastic-package-service-good_input-1:3306", + "type": "sql" + }, + "sql": { + "driver": "mysql", + "metrics": {}, + "query": "SHOW GLOBAL STATUS LIKE 'Innodb_system%'" + } +} \ No newline at end of file diff --git a/test/packages/good_v2/data_stream/foo/_dev/test/system/test-default-config.yml b/test/packages/good_v2/data_stream/foo/_dev/test/system/test-default-config.yml index 798baeeab..607ddd930 100644 --- a/test/packages/good_v2/data_stream/foo/_dev/test/system/test-default-config.yml +++ b/test/packages/good_v2/data_stream/foo/_dev/test/system/test-default-config.yml @@ -1,2 +1,11 @@ wait_for_data_timeout: 10m -vars: ~ \ No newline at end of file +vars: ~ + +samples: + - name: "one" + condition: + key: "sql.driver" + value: "mysql" + - name: "two" + condition: + key: "sql.driver" diff --git a/test/packages/good_v2/data_stream/foo/sample_event_one.json b/test/packages/good_v2/data_stream/foo/sample_event_one.json new file mode 100644 index 000000000..58c47a657 --- /dev/null +++ b/test/packages/good_v2/data_stream/foo/sample_event_one.json @@ -0,0 +1,63 @@ +{ + "@timestamp": "2022-11-16T19:00:58.919Z", + "agent": { + "ephemeral_id": "1f2789fe-4041-4b4d-aac2-076a34c5d24f", + "id": "47bdbac3-731d-4b11-9af6-06fba253dba8", + "name": "docker-fleet-agent", + "type": "metricbeat", + "version": "8.5.0" + }, + "data_stream": { + "dataset": "sql_input.sql_query", + "namespace": "ep", + "type": "metrics" + }, + "ecs": { + "version": "8.0.0" + }, + "elastic_agent": { + "id": "47bdbac3-731d-4b11-9af6-06fba253dba8", + "snapshot": true, + "version": "8.5.0" + }, + "event": { + "dataset": "sql_input.sql_query", + "duration": 1326395, + "module": "sql" + }, + "host": { + "architecture": "x86_64", + "containerized": false, + "hostname": "docker-fleet-agent", + "id": "0addaca3101a43f4a52be882837fb33d", + "ip": [ + "192.168.192.7" + ], + "mac": [ + "02-42-C0-A8-C0-07" + ], + "name": "docker-fleet-agent", + "os": { + "codename": "focal", + "family": "debian", + "kernel": "5.15.0-50-generic", + "name": "Ubuntu", + "platform": "ubuntu", + "type": "linux", + "version": "20.04.5 LTS (Focal Fossa)" + } + }, + "metricset": { + "name": "query", + "period": 10000 + }, + "service": { + "address": "elastic-package-service-sql_input-1:3306", + "type": "sql" + }, + "sql": { + "driver": "mysql", + "metrics": {}, + "query": "SHOW GLOBAL STATUS LIKE 'Innodb_system%'" + } +} \ No newline at end of file diff --git a/test/packages/good_v2/data_stream/foo/sample_event_two.json b/test/packages/good_v2/data_stream/foo/sample_event_two.json new file mode 100644 index 000000000..58c47a657 --- /dev/null +++ b/test/packages/good_v2/data_stream/foo/sample_event_two.json @@ -0,0 +1,63 @@ +{ + "@timestamp": "2022-11-16T19:00:58.919Z", + "agent": { + "ephemeral_id": "1f2789fe-4041-4b4d-aac2-076a34c5d24f", + "id": "47bdbac3-731d-4b11-9af6-06fba253dba8", + "name": "docker-fleet-agent", + "type": "metricbeat", + "version": "8.5.0" + }, + "data_stream": { + "dataset": "sql_input.sql_query", + "namespace": "ep", + "type": "metrics" + }, + "ecs": { + "version": "8.0.0" + }, + "elastic_agent": { + "id": "47bdbac3-731d-4b11-9af6-06fba253dba8", + "snapshot": true, + "version": "8.5.0" + }, + "event": { + "dataset": "sql_input.sql_query", + "duration": 1326395, + "module": "sql" + }, + "host": { + "architecture": "x86_64", + "containerized": false, + "hostname": "docker-fleet-agent", + "id": "0addaca3101a43f4a52be882837fb33d", + "ip": [ + "192.168.192.7" + ], + "mac": [ + "02-42-C0-A8-C0-07" + ], + "name": "docker-fleet-agent", + "os": { + "codename": "focal", + "family": "debian", + "kernel": "5.15.0-50-generic", + "name": "Ubuntu", + "platform": "ubuntu", + "type": "linux", + "version": "20.04.5 LTS (Focal Fossa)" + } + }, + "metricset": { + "name": "query", + "period": 10000 + }, + "service": { + "address": "elastic-package-service-sql_input-1:3306", + "type": "sql" + }, + "sql": { + "driver": "mysql", + "metrics": {}, + "query": "SHOW GLOBAL STATUS LIKE 'Innodb_system%'" + } +} \ No newline at end of file