From 074a4414107ea999da69f8b8ea28fa76258ff1d7 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 21 Mar 2019 00:21:13 +0200 Subject: [PATCH] Add testdata for stats metricset of coredns Signed-off-by: Chris Signed-off-by: Chris Mark --- .../docs/modules/coredns/stats.asciidoc | 6 + .../module/coredns/stats/_meta/data.json | 74 ++++++ .../coredns/stats/_meta/data_panic_event.json | 28 -- .../stats/_meta/data_request_count_event.json | 34 --- .../_meta/data_request_duration_ns_event.json | 54 ---- .../stats/_meta/data_request_type_event.json | 35 --- .../_meta/data_response_rcode_event.json | 35 --- .../stats/_meta/data_size_bytes_event.json | 78 ------ .../coredns/stats/_meta/test/metrics.expected | 217 ---------------- .../coredns/stats/_meta/testdata/config.yml | 3 + .../stats/_meta/testdata/do_count_total.plain | 3 + .../do_count_total.plain-expected.json | 31 +++ .../coredns/stats/_meta/testdata/docs.plain | 38 +++ .../_meta/testdata/docs.plain-expected.json | 75 ++++++ .../_meta/testdata/panic_count_total.plain | 3 + .../panic_count_total.plain-expected.json | 25 ++ .../prometheus_full_output.plain} | 0 ...prometheus_full_output.plain-expected.json | 241 ++++++++++++++++++ .../_meta/testdata/rcode_count_total.plain | 3 + .../rcode_count_total.plain-expected.json | 32 +++ .../_meta/testdata/request_count_total.plain | 3 + .../request_count_total.plain-expected.json | 31 +++ .../_meta/testdata/request_duration.plain | 21 ++ .../request_duration.plain-expected.json | 51 ++++ .../stats/_meta/testdata/request_size.plain | 19 ++ .../testdata/request_size.plain-expected.json | 50 ++++ .../testdata/request_type_count_total.plain | 3 + ...quest_type_count_total.plain-expected.json | 32 +++ .../stats/_meta/testdata/response_size.plain | 19 ++ .../response_size.plain-expected.json | 50 ++++ .../coredns/stats/stats_integration_test.go | 89 ------- metricbeat/module/coredns/stats/stats_test.go | 37 --- 32 files changed, 813 insertions(+), 607 deletions(-) create mode 100644 metricbeat/module/coredns/stats/_meta/data.json delete mode 100644 metricbeat/module/coredns/stats/_meta/data_panic_event.json delete mode 100644 metricbeat/module/coredns/stats/_meta/data_request_count_event.json delete mode 100644 metricbeat/module/coredns/stats/_meta/data_request_duration_ns_event.json delete mode 100644 metricbeat/module/coredns/stats/_meta/data_request_type_event.json delete mode 100644 metricbeat/module/coredns/stats/_meta/data_response_rcode_event.json delete mode 100644 metricbeat/module/coredns/stats/_meta/data_size_bytes_event.json delete mode 100644 metricbeat/module/coredns/stats/_meta/test/metrics.expected create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/config.yml create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/do_count_total.plain create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/do_count_total.plain-expected.json create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/docs.plain create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/docs.plain-expected.json create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/panic_count_total.plain create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/panic_count_total.plain-expected.json rename metricbeat/module/coredns/stats/_meta/{test/metrics => testdata/prometheus_full_output.plain} (100%) create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/prometheus_full_output.plain-expected.json create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/rcode_count_total.plain create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/rcode_count_total.plain-expected.json create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/request_count_total.plain create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/request_count_total.plain-expected.json create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/request_duration.plain create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/request_duration.plain-expected.json create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/request_size.plain create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/request_size.plain-expected.json create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/request_type_count_total.plain create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/request_type_count_total.plain-expected.json create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/response_size.plain create mode 100644 metricbeat/module/coredns/stats/_meta/testdata/response_size.plain-expected.json delete mode 100644 metricbeat/module/coredns/stats/stats_integration_test.go delete mode 100644 metricbeat/module/coredns/stats/stats_test.go diff --git a/metricbeat/docs/modules/coredns/stats.asciidoc b/metricbeat/docs/modules/coredns/stats.asciidoc index 780b80f7ec77..95ec886d6d75 100644 --- a/metricbeat/docs/modules/coredns/stats.asciidoc +++ b/metricbeat/docs/modules/coredns/stats.asciidoc @@ -15,3 +15,9 @@ include::../../../module/coredns/stats/_meta/docs.asciidoc[] For a description of each field in the metricset, see the <> section. +Here is an example document generated by this metricset: + +[source,json] +---- +include::../../../module/coredns/stats/_meta/data.json[] +---- diff --git a/metricbeat/module/coredns/stats/_meta/data.json b/metricbeat/module/coredns/stats/_meta/data.json new file mode 100644 index 000000000000..f7181c2915e6 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/data.json @@ -0,0 +1,74 @@ +{ + "@timestamp": "2019-03-01T08:05:34.853Z", + "coredns": { + "stats": { + "dns": { + "request": { + "size": { + "bytes": { + "bucket": { + "+Inf": 440, + "0": 0, + "100": 440, + "1023": 440, + "16000": 440, + "200": 440, + "2047": 440, + "300": 440, + "32000": 440, + "400": 440, + "4095": 440, + "48000": 440, + "511": 440, + "64000": 440, + "8291": 440 + }, + "count": 440, + "sum": 22880 + } + } + }, + "response": { + "size": { + "bytes": { + "bucket": { + "+Inf": 440, + "0": 0, + "100": 440, + "1023": 440, + "16000": 440, + "200": 440, + "2047": 440, + "300": 440, + "32000": 440, + "400": 440, + "4095": 440, + "48000": 440, + "511": 440, + "64000": 440, + "8291": 440 + }, + "count": 440, + "sum": 29480 + } + } + } + }, + "proto": "udp", + "server": "dns://:53", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } +} \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/data_panic_event.json b/metricbeat/module/coredns/stats/_meta/data_panic_event.json deleted file mode 100644 index 742b910c93ac..000000000000 --- a/metricbeat/module/coredns/stats/_meta/data_panic_event.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "@timestamp": "2017-10-12T08:05:34.853Z", - "agent": { - "hostname": "host.example.com", - "name": "host.example.com" - }, - "coredns": { - "stats": { - "panic": { - "count": { - "total": 0 - } - } - } - }, - "event": { - "dataset": "coredns.stats", - "duration": 115000, - "module": "coredns" - }, - "metricset": { - "name": "stats" - }, - "service": { - "address": "127.0.0.1:9153", - "type": "coredns" - } -} \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/data_request_count_event.json b/metricbeat/module/coredns/stats/_meta/data_request_count_event.json deleted file mode 100644 index 278abf6cd492..000000000000 --- a/metricbeat/module/coredns/stats/_meta/data_request_count_event.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "@timestamp": "2017-10-12T08:05:34.853Z", - "agent": { - "hostname": "host.example.com", - "name": "host.example.com" - }, - "coredns": { - "stats": { - "dns": { - "request": { - "count": { - "total": 430 - } - } - }, - "family": "1", - "proto": "udp", - "server": "dns://:53", - "zone": "dropped" - } - }, - "event": { - "dataset": "coredns.stats", - "duration": 115000, - "module": "coredns" - }, - "metricset": { - "name": "stats" - }, - "service": { - "address": "127.0.0.1:9153", - "type": "coredns" - } -} \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/data_request_duration_ns_event.json b/metricbeat/module/coredns/stats/_meta/data_request_duration_ns_event.json deleted file mode 100644 index 32708e27cfb4..000000000000 --- a/metricbeat/module/coredns/stats/_meta/data_request_duration_ns_event.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "@timestamp": "2017-10-12T08:05:34.853Z", - "agent": { - "hostname": "host.example.com", - "name": "host.example.com" - }, - "coredns": { - "stats": { - "dns": { - "request": { - "duration": { - "ns": { - "bucket": { - "+Inf": 430, - "1000000": 0, - "1024000000": 0, - "128000000": 0, - "16000000": 0, - "2000000": 0, - "2048000000": 427, - "250000": 0, - "256000000": 0, - "32000000": 0, - "4000000": 0, - "4096000000": 428, - "500000": 0, - "512000000": 0, - "64000000": 0, - "8000000": 0, - "8192000000": 430 - }, - "count": 430, - "sum": 870306874252 - } - } - } - }, - "server": "dns://:53", - "zone": "." - } - }, - "event": { - "dataset": "coredns.stats", - "duration": 115000, - "module": "coredns" - }, - "metricset": { - "name": "stats" - }, - "service": { - "address": "127.0.0.1:9153", - "type": "coredns" - } -} diff --git a/metricbeat/module/coredns/stats/_meta/data_request_type_event.json b/metricbeat/module/coredns/stats/_meta/data_request_type_event.json deleted file mode 100644 index 154d614c14af..000000000000 --- a/metricbeat/module/coredns/stats/_meta/data_request_type_event.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "@timestamp": "2017-10-12T08:05:34.853Z", - "agent": { - "hostname": "host.example.com", - "name": "host.example.com" - }, - "coredns": { - "stats": { - "dns": { - "request": { - "type": { - "count": { - "total": 430 - } - } - } - }, - "server": "dns://:53", - "type": "A", - "zone": "." - } - }, - "event": { - "dataset": "coredns.stats", - "duration": 115000, - "module": "coredns" - }, - "metricset": { - "name": "stats" - }, - "service": { - "address": "127.0.0.1:9153", - "type": "coredns" - } -} \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/data_response_rcode_event.json b/metricbeat/module/coredns/stats/_meta/data_response_rcode_event.json deleted file mode 100644 index 0aa1da95db41..000000000000 --- a/metricbeat/module/coredns/stats/_meta/data_response_rcode_event.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "@timestamp": "2017-10-12T08:05:34.853Z", - "agent": { - "hostname": "host.example.com", - "name": "host.example.com" - }, - "coredns": { - "stats": { - "dns": { - "response": { - "rcode": { - "count": { - "total": 430 - } - } - } - }, - "rcode": "SERVFAIL", - "server": "dns://:53", - "zone": "." - } - }, - "event": { - "dataset": "coredns.stats", - "duration": 115000, - "module": "coredns" - }, - "metricset": { - "name": "stats" - }, - "service": { - "address": "127.0.0.1:9153", - "type": "coredns" - } -} \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/data_size_bytes_event.json b/metricbeat/module/coredns/stats/_meta/data_size_bytes_event.json deleted file mode 100644 index ecced482d6c7..000000000000 --- a/metricbeat/module/coredns/stats/_meta/data_size_bytes_event.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "@timestamp": "2017-10-12T08:05:34.853Z", - "agent": { - "hostname": "host.example.com", - "name": "host.example.com" - }, - "coredns": { - "stats": { - "dns": { - "request": { - "size": { - "bytes": { - "bucket": { - "+Inf": 430, - "0": 0, - "100": 430, - "1023": 430, - "16000": 430, - "200": 430, - "2047": 430, - "300": 430, - "32000": 430, - "400": 430, - "4095": 430, - "48000": 430, - "511": 430, - "64000": 430, - "8291": 430 - }, - "count": 430, - "sum": 24080 - } - } - }, - "response": { - "size": { - "bytes": { - "bucket": { - "+Inf": 430, - "0": 0, - "100": 430, - "1023": 430, - "16000": 430, - "200": 430, - "2047": 430, - "300": 430, - "32000": 430, - "400": 430, - "4095": 430, - "48000": 430, - "511": 430, - "64000": 430, - "8291": 430 - }, - "count": 430, - "sum": 24080 - } - } - } - }, - "proto": "udp", - "server": "dns://:53", - "zone": "." - } - }, - "event": { - "dataset": "coredns.stats", - "duration": 115000, - "module": "coredns" - }, - "metricset": { - "name": "stats" - }, - "service": { - "address": "127.0.0.1:9153", - "type": "coredns" - } -} \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/test/metrics.expected b/metricbeat/module/coredns/stats/_meta/test/metrics.expected deleted file mode 100644 index ef2093b64107..000000000000 --- a/metricbeat/module/coredns/stats/_meta/test/metrics.expected +++ /dev/null @@ -1,217 +0,0 @@ -[ - { - "RootFields": null, - "ModuleFields": null, - "MetricSetFields": { - "dns": { - "response": { - "rcode": { - "count": { - "total": 440 - } - } - } - }, - "rcode": "NOERROR", - "server": "dns://:53", - "zone": "." - }, - "Index": "", - "ID": "", - "Namespace": "", - "Timestamp": "0001-01-01T00:00:00Z", - "Error": null, - "Host": "", - "Service": "", - "Took": 0 - }, - { - "RootFields": null, - "ModuleFields": null, - "MetricSetFields": { - "panic": { - "count": { - "total": 0 - } - } - }, - "Index": "", - "ID": "", - "Namespace": "", - "Timestamp": "0001-01-01T00:00:00Z", - "Error": null, - "Host": "", - "Service": "", - "Took": 0 - }, - { - "RootFields": null, - "ModuleFields": null, - "MetricSetFields": { - "dns": { - "request": { - "do": { - "count": { - "total": 113 - } - }, - "duration": { - "ns": { - "bucket": { - "+Inf": 440, - "1000000": 0, - "1024000000": 440, - "128000000": 437, - "16000000": 0, - "2000000": 0, - "2048000000": 440, - "250000": 0, - "256000000": 438, - "32000000": 0, - "4000000": 0, - "4096000000": 440, - "500000": 0, - "512000000": 440, - "64000000": 424, - "8000000": 0, - "8192000000": 440 - }, - "count": 440, - "sum": 21712619368 - } - } - } - }, - "server": "dns://:53", - "zone": "." - }, - "Index": "", - "ID": "", - "Namespace": "", - "Timestamp": "0001-01-01T00:00:00Z", - "Error": null, - "Host": "", - "Service": "", - "Took": 0 - }, - { - "RootFields": null, - "ModuleFields": null, - "MetricSetFields": { - "dns": { - "request": { - "size": { - "bytes": { - "bucket": { - "+Inf": 440, - "0": 0, - "100": 440, - "1023": 440, - "16000": 440, - "200": 440, - "2047": 440, - "300": 440, - "32000": 440, - "400": 440, - "4095": 440, - "48000": 440, - "511": 440, - "64000": 440, - "8291": 440 - }, - "count": 440, - "sum": 22880 - } - } - }, - "response": { - "size": { - "bytes": { - "bucket": { - "+Inf": 440, - "0": 0, - "100": 440, - "1023": 440, - "16000": 440, - "200": 440, - "2047": 440, - "300": 440, - "32000": 440, - "400": 440, - "4095": 440, - "48000": 440, - "511": 440, - "64000": 440, - "8291": 440 - }, - "count": 440, - "sum": 29480 - } - } - } - }, - "proto": "udp", - "server": "dns://:53", - "zone": "." - }, - "Index": "", - "ID": "", - "Namespace": "", - "Timestamp": "0001-01-01T00:00:00Z", - "Error": null, - "Host": "", - "Service": "", - "Took": 0 - }, - { - "RootFields": null, - "ModuleFields": null, - "MetricSetFields": { - "dns": { - "request": { - "count": { - "total": 440 - } - } - }, - "family": "1", - "proto": "udp", - "server": "dns://:53", - "zone": "." - }, - "Index": "", - "ID": "", - "Namespace": "", - "Timestamp": "0001-01-01T00:00:00Z", - "Error": null, - "Host": "", - "Service": "", - "Took": 0 - }, - { - "RootFields": null, - "ModuleFields": null, - "MetricSetFields": { - "dns": { - "request": { - "type": { - "count": { - "total": 440 - } - } - } - }, - "server": "dns://:53", - "type": "A", - "zone": "." - }, - "Index": "", - "ID": "", - "Namespace": "", - "Timestamp": "0001-01-01T00:00:00Z", - "Error": null, - "Host": "", - "Service": "", - "Took": 0 - } -] diff --git a/metricbeat/module/coredns/stats/_meta/testdata/config.yml b/metricbeat/module/coredns/stats/_meta/testdata/config.yml new file mode 100644 index 000000000000..ab6bf2416543 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/config.yml @@ -0,0 +1,3 @@ +type: http +url: "/metrics" +suffix: plain diff --git a/metricbeat/module/coredns/stats/_meta/testdata/do_count_total.plain b/metricbeat/module/coredns/stats/_meta/testdata/do_count_total.plain new file mode 100644 index 000000000000..b4cc3c1f1eb6 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/do_count_total.plain @@ -0,0 +1,3 @@ +# HELP coredns_dns_request_do_count_total Counter of DNS requests with DO bit set per zone. +# TYPE coredns_dns_request_do_count_total counter +coredns_dns_request_do_count_total{server="dns://:53",zone="."} 113.0 diff --git a/metricbeat/module/coredns/stats/_meta/testdata/do_count_total.plain-expected.json b/metricbeat/module/coredns/stats/_meta/testdata/do_count_total.plain-expected.json new file mode 100644 index 000000000000..4f854e03be44 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/do_count_total.plain-expected.json @@ -0,0 +1,31 @@ +[ + { + "coredns": { + "stats": { + "dns": { + "request": { + "do": { + "count": { + "total": 113 + } + } + } + }, + "server": "dns://:53", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + } +] \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/testdata/docs.plain b/metricbeat/module/coredns/stats/_meta/testdata/docs.plain new file mode 100644 index 000000000000..1efc76bc8b02 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/docs.plain @@ -0,0 +1,38 @@ +# HELP coredns_dns_response_size_bytes Size of the returned response in bytes. +# TYPE coredns_dns_response_size_bytes histogram +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="0.0"} 0.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="100.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="200.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="300.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="400.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="511.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="1023.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="2047.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="4095.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="8291.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="16000.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="32000.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="48000.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="64000.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="+Inf"} 440.0 +coredns_dns_response_size_bytes_sum{proto="udp",server="dns://:53",zone="."} 29480.0 +coredns_dns_response_size_bytes_count{proto="udp",server="dns://:53",zone="."} 440.0 +# HELP coredns_dns_request_size_bytes Size of the EDNS0 UDP buffer in bytes (64K for TCP). +# TYPE coredns_dns_request_size_bytes histogram +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="0.0"} 0.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="100.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="200.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="300.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="400.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="511.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="1023.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="2047.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="4095.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="8291.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="16000.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="32000.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="48000.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="64000.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="+Inf"} 440.0 +coredns_dns_request_size_bytes_sum{proto="udp",server="dns://:53",zone="."} 22880.0 +coredns_dns_request_size_bytes_count{proto="udp",server="dns://:53",zone="."} 440.0 diff --git a/metricbeat/module/coredns/stats/_meta/testdata/docs.plain-expected.json b/metricbeat/module/coredns/stats/_meta/testdata/docs.plain-expected.json new file mode 100644 index 000000000000..38f2248d7d66 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/docs.plain-expected.json @@ -0,0 +1,75 @@ +[ + { + "coredns": { + "stats": { + "dns": { + "request": { + "size": { + "bytes": { + "bucket": { + "+Inf": 440, + "0": 0, + "100": 440, + "1023": 440, + "16000": 440, + "200": 440, + "2047": 440, + "300": 440, + "32000": 440, + "400": 440, + "4095": 440, + "48000": 440, + "511": 440, + "64000": 440, + "8291": 440 + }, + "count": 440, + "sum": 22880 + } + } + }, + "response": { + "size": { + "bytes": { + "bucket": { + "+Inf": 440, + "0": 0, + "100": 440, + "1023": 440, + "16000": 440, + "200": 440, + "2047": 440, + "300": 440, + "32000": 440, + "400": 440, + "4095": 440, + "48000": 440, + "511": 440, + "64000": 440, + "8291": 440 + }, + "count": 440, + "sum": 29480 + } + } + } + }, + "proto": "udp", + "server": "dns://:53", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + } +] \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/testdata/panic_count_total.plain b/metricbeat/module/coredns/stats/_meta/testdata/panic_count_total.plain new file mode 100644 index 000000000000..97e4299051dd --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/panic_count_total.plain @@ -0,0 +1,3 @@ +# HELP coredns_panic_count_total A metrics that counts the number of panics. +# TYPE coredns_panic_count_total counter +coredns_panic_count_total 42.0 diff --git a/metricbeat/module/coredns/stats/_meta/testdata/panic_count_total.plain-expected.json b/metricbeat/module/coredns/stats/_meta/testdata/panic_count_total.plain-expected.json new file mode 100644 index 000000000000..c13297036e0d --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/panic_count_total.plain-expected.json @@ -0,0 +1,25 @@ +[ + { + "coredns": { + "stats": { + "panic": { + "count": { + "total": 42 + } + } + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + } +] \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/test/metrics b/metricbeat/module/coredns/stats/_meta/testdata/prometheus_full_output.plain similarity index 100% rename from metricbeat/module/coredns/stats/_meta/test/metrics rename to metricbeat/module/coredns/stats/_meta/testdata/prometheus_full_output.plain diff --git a/metricbeat/module/coredns/stats/_meta/testdata/prometheus_full_output.plain-expected.json b/metricbeat/module/coredns/stats/_meta/testdata/prometheus_full_output.plain-expected.json new file mode 100644 index 000000000000..8865794ce317 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/prometheus_full_output.plain-expected.json @@ -0,0 +1,241 @@ +[ + { + "coredns": { + "stats": { + "panic": { + "count": { + "total": 0 + } + } + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + }, + { + "coredns": { + "stats": { + "dns": { + "request": { + "size": { + "bytes": { + "bucket": { + "+Inf": 440, + "0": 0, + "100": 440, + "1023": 440, + "16000": 440, + "200": 440, + "2047": 440, + "300": 440, + "32000": 440, + "400": 440, + "4095": 440, + "48000": 440, + "511": 440, + "64000": 440, + "8291": 440 + }, + "count": 440, + "sum": 22880 + } + } + }, + "response": { + "size": { + "bytes": { + "bucket": { + "+Inf": 440, + "0": 0, + "100": 440, + "1023": 440, + "16000": 440, + "200": 440, + "2047": 440, + "300": 440, + "32000": 440, + "400": 440, + "4095": 440, + "48000": 440, + "511": 440, + "64000": 440, + "8291": 440 + }, + "count": 440, + "sum": 29480 + } + } + } + }, + "proto": "udp", + "server": "dns://:53", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + }, + { + "coredns": { + "stats": { + "dns": { + "request": { + "count": { + "total": 440 + } + } + }, + "family": "1", + "proto": "udp", + "server": "dns://:53", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + }, + { + "coredns": { + "stats": { + "dns": { + "response": { + "rcode": { + "count": { + "total": 440 + } + } + } + }, + "rcode": "NOERROR", + "server": "dns://:53", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + }, + { + "coredns": { + "stats": { + "dns": { + "request": { + "type": { + "count": { + "total": 440 + } + } + } + }, + "server": "dns://:53", + "type": "A", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + }, + { + "coredns": { + "stats": { + "dns": { + "request": { + "do": { + "count": { + "total": 113 + } + }, + "duration": { + "ns": { + "bucket": { + "+Inf": 440, + "1000000": 0, + "1024000000": 440, + "128000000": 437, + "16000000": 0, + "2000000": 0, + "2048000000": 440, + "250000": 0, + "256000000": 438, + "32000000": 0, + "4000000": 0, + "4096000000": 440, + "500000": 0, + "512000000": 440, + "64000000": 424, + "8000000": 0, + "8192000000": 440 + }, + "count": 440, + "sum": 21712619368 + } + } + } + }, + "server": "dns://:53", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + } +] \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/testdata/rcode_count_total.plain b/metricbeat/module/coredns/stats/_meta/testdata/rcode_count_total.plain new file mode 100644 index 000000000000..4b38b0619816 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/rcode_count_total.plain @@ -0,0 +1,3 @@ +# HELP coredns_dns_response_rcode_count_total Counter of response status codes. +# TYPE coredns_dns_response_rcode_count_total counter +coredns_dns_response_rcode_count_total{rcode="NOERROR",server="dns://:53",zone="."} 440.0 diff --git a/metricbeat/module/coredns/stats/_meta/testdata/rcode_count_total.plain-expected.json b/metricbeat/module/coredns/stats/_meta/testdata/rcode_count_total.plain-expected.json new file mode 100644 index 000000000000..05c945bc0bf8 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/rcode_count_total.plain-expected.json @@ -0,0 +1,32 @@ +[ + { + "coredns": { + "stats": { + "dns": { + "response": { + "rcode": { + "count": { + "total": 440 + } + } + } + }, + "rcode": "NOERROR", + "server": "dns://:53", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + } +] \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/testdata/request_count_total.plain b/metricbeat/module/coredns/stats/_meta/testdata/request_count_total.plain new file mode 100644 index 000000000000..9a7e0e905e09 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/request_count_total.plain @@ -0,0 +1,3 @@ +# HELP coredns_dns_request_count_total Counter of DNS requests made per zone, protocol and family. +# TYPE coredns_dns_request_count_total counter +coredns_dns_request_count_total{family="1",proto="udp",server="dns://:53",zone="."} 440.0 diff --git a/metricbeat/module/coredns/stats/_meta/testdata/request_count_total.plain-expected.json b/metricbeat/module/coredns/stats/_meta/testdata/request_count_total.plain-expected.json new file mode 100644 index 000000000000..f8107cdf7901 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/request_count_total.plain-expected.json @@ -0,0 +1,31 @@ +[ + { + "coredns": { + "stats": { + "dns": { + "request": { + "count": { + "total": 440 + } + } + }, + "family": "1", + "proto": "udp", + "server": "dns://:53", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + } +] \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/testdata/request_duration.plain b/metricbeat/module/coredns/stats/_meta/testdata/request_duration.plain new file mode 100644 index 000000000000..717f371d331d --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/request_duration.plain @@ -0,0 +1,21 @@ +# HELP coredns_dns_request_duration_seconds Histogram of the time (in seconds) each request took. +# TYPE coredns_dns_request_duration_seconds histogram +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="0.00025"} 0.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="0.0005"} 0.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="0.001"} 0.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="0.002"} 0.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="0.004"} 0.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="0.008"} 0.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="0.016"} 0.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="0.032"} 0.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="0.064"} 424.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="0.128"} 437.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="0.256"} 438.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="0.512"} 440.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="1.024"} 440.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="2.048"} 440.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="4.096"} 440.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="8.192"} 440.0 +coredns_dns_request_duration_seconds_bucket{server="dns://:53",zone=".",le="+Inf"} 440.0 +coredns_dns_request_duration_seconds_sum{server="dns://:53",zone="."} 21.712619368 +coredns_dns_request_duration_seconds_count{server="dns://:53",zone="."} 440.0 diff --git a/metricbeat/module/coredns/stats/_meta/testdata/request_duration.plain-expected.json b/metricbeat/module/coredns/stats/_meta/testdata/request_duration.plain-expected.json new file mode 100644 index 000000000000..051528b9e7ef --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/request_duration.plain-expected.json @@ -0,0 +1,51 @@ +[ + { + "coredns": { + "stats": { + "dns": { + "request": { + "duration": { + "ns": { + "bucket": { + "+Inf": 440, + "1000000": 0, + "1024000000": 440, + "128000000": 437, + "16000000": 0, + "2000000": 0, + "2048000000": 440, + "250000": 0, + "256000000": 438, + "32000000": 0, + "4000000": 0, + "4096000000": 440, + "500000": 0, + "512000000": 440, + "64000000": 424, + "8000000": 0, + "8192000000": 440 + }, + "count": 440, + "sum": 21712619368 + } + } + } + }, + "server": "dns://:53", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + } +] \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/testdata/request_size.plain b/metricbeat/module/coredns/stats/_meta/testdata/request_size.plain new file mode 100644 index 000000000000..4048c7190dcc --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/request_size.plain @@ -0,0 +1,19 @@ +# HELP coredns_dns_request_size_bytes Size of the EDNS0 UDP buffer in bytes (64K for TCP). +# TYPE coredns_dns_request_size_bytes histogram +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="0.0"} 0.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="100.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="200.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="300.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="400.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="511.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="1023.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="2047.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="4095.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="8291.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="16000.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="32000.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="48000.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="64000.0"} 440.0 +coredns_dns_request_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="+Inf"} 440.0 +coredns_dns_request_size_bytes_sum{proto="udp",server="dns://:53",zone="."} 22880.0 +coredns_dns_request_size_bytes_count{proto="udp",server="dns://:53",zone="."} 440.0 diff --git a/metricbeat/module/coredns/stats/_meta/testdata/request_size.plain-expected.json b/metricbeat/module/coredns/stats/_meta/testdata/request_size.plain-expected.json new file mode 100644 index 000000000000..8acbd403326f --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/request_size.plain-expected.json @@ -0,0 +1,50 @@ +[ + { + "coredns": { + "stats": { + "dns": { + "request": { + "size": { + "bytes": { + "bucket": { + "+Inf": 440, + "0": 0, + "100": 440, + "1023": 440, + "16000": 440, + "200": 440, + "2047": 440, + "300": 440, + "32000": 440, + "400": 440, + "4095": 440, + "48000": 440, + "511": 440, + "64000": 440, + "8291": 440 + }, + "count": 440, + "sum": 22880 + } + } + } + }, + "proto": "udp", + "server": "dns://:53", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + } +] \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/testdata/request_type_count_total.plain b/metricbeat/module/coredns/stats/_meta/testdata/request_type_count_total.plain new file mode 100644 index 000000000000..8bab97974963 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/request_type_count_total.plain @@ -0,0 +1,3 @@ +# HELP coredns_dns_request_type_count_total Counter of DNS requests per type, per zone. +# TYPE coredns_dns_request_type_count_total counter +coredns_dns_request_type_count_total{server="dns://:53",type="A",zone="."} 440.0 diff --git a/metricbeat/module/coredns/stats/_meta/testdata/request_type_count_total.plain-expected.json b/metricbeat/module/coredns/stats/_meta/testdata/request_type_count_total.plain-expected.json new file mode 100644 index 000000000000..975b31d8421b --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/request_type_count_total.plain-expected.json @@ -0,0 +1,32 @@ +[ + { + "coredns": { + "stats": { + "dns": { + "request": { + "type": { + "count": { + "total": 440 + } + } + } + }, + "server": "dns://:53", + "type": "A", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + } +] \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/_meta/testdata/response_size.plain b/metricbeat/module/coredns/stats/_meta/testdata/response_size.plain new file mode 100644 index 000000000000..ff374bced350 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/response_size.plain @@ -0,0 +1,19 @@ +# HELP coredns_dns_response_size_bytes Size of the returned response in bytes. +# TYPE coredns_dns_response_size_bytes histogram +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="0.0"} 0.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="100.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="200.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="300.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="400.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="511.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="1023.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="2047.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="4095.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="8291.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="16000.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="32000.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="48000.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="64000.0"} 440.0 +coredns_dns_response_size_bytes_bucket{proto="udp",server="dns://:53",zone=".",le="+Inf"} 440.0 +coredns_dns_response_size_bytes_sum{proto="udp",server="dns://:53",zone="."} 29480.0 +coredns_dns_response_size_bytes_count{proto="udp",server="dns://:53",zone="."} 440.0 diff --git a/metricbeat/module/coredns/stats/_meta/testdata/response_size.plain-expected.json b/metricbeat/module/coredns/stats/_meta/testdata/response_size.plain-expected.json new file mode 100644 index 000000000000..4e90b48d7936 --- /dev/null +++ b/metricbeat/module/coredns/stats/_meta/testdata/response_size.plain-expected.json @@ -0,0 +1,50 @@ +[ + { + "coredns": { + "stats": { + "dns": { + "response": { + "size": { + "bytes": { + "bucket": { + "+Inf": 440, + "0": 0, + "100": 440, + "1023": 440, + "16000": 440, + "200": 440, + "2047": 440, + "300": 440, + "32000": 440, + "400": 440, + "4095": 440, + "48000": 440, + "511": 440, + "64000": 440, + "8291": 440 + }, + "count": 440, + "sum": 29480 + } + } + } + }, + "proto": "udp", + "server": "dns://:53", + "zone": "." + } + }, + "event": { + "dataset": "coredns.stats", + "duration": 115000, + "module": "coredns" + }, + "metricset": { + "name": "stats" + }, + "service": { + "address": "127.0.0.1:55555", + "type": "coredns" + } + } +] \ No newline at end of file diff --git a/metricbeat/module/coredns/stats/stats_integration_test.go b/metricbeat/module/coredns/stats/stats_integration_test.go deleted file mode 100644 index c7766ff91e03..000000000000 --- a/metricbeat/module/coredns/stats/stats_integration_test.go +++ /dev/null @@ -1,89 +0,0 @@ -// Licensed to Elasticsearch B.V. under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Elasticsearch B.V. licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// +build integration - -package stats - -import ( - "fmt" - "os" - "testing" - - "github.com/elastic/beats/libbeat/common" - "github.com/elastic/beats/libbeat/tests/compose" - mbtest "github.com/elastic/beats/metricbeat/mb/testing" -) - -func TestData(t *testing.T) { - compose.EnsureUp(t, "coredns") - // TODO: Use this function to find if an event is the wanted one - eventIs := func(eventType string) func(e common.MapStr) bool { - return func(e common.MapStr) bool { - hasEvent, _ := e.HasKey(eventType) - return hasEvent - } - } - dataFiles := []struct { - eventType string - path string - }{ - {"coredns.stats.panic.count.total", "./_meta/data_panic_event.json"}, - {"coredns.stats.dns.request.count.total", "./_meta/data_request_count_event.json"}, - {"coredns.stats.dns.request.size.bytes", "./_meta/data_size_bytes_event.json"}, - {"coredns.stats.dns.request.duration.ns", "./_meta/data_request_duration_ns_event.json"}, - {"coredns.stats.dns.response.rcode", "./_meta/data_response_rcode_event.json"}, - {"coredns.stats.dns.request.type", "./_meta/data_request_type_event.json"}, - } - f := mbtest.NewReportingMetricSetV2(t, getConfig()) - - for _, df := range dataFiles { - t.Run(fmt.Sprintf("event type:%s", df.eventType), func(t *testing.T) { - err := mbtest.WriteEventsReporterV2Cond(f, t, df.path, eventIs(df.eventType)) - if err != nil { - t.Fatal("write", err) - } - }) - } - -} - -func getConfig() map[string]interface{} { - return map[string]interface{}{ - "module": "coredns", - "metricsets": []string{"stats"}, - "hosts": []string{GetEnvHost() + ":" + GetEnvPort()}, - } -} - -func GetEnvHost() string { - host := os.Getenv("COREDNS_HOST") - - if len(host) == 0 { - host = "127.0.0.1" - } - return host -} - -func GetEnvPort() string { - port := os.Getenv("COREDNS_PORT") - - if len(port) == 0 { - port = "9153" - } - return port -} diff --git a/metricbeat/module/coredns/stats/stats_test.go b/metricbeat/module/coredns/stats/stats_test.go deleted file mode 100644 index 053ed67b17a2..000000000000 --- a/metricbeat/module/coredns/stats/stats_test.go +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to Elasticsearch B.V. under one or more contributor -// license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright -// ownership. Elasticsearch B.V. licenses this file to you under -// the Apache License, Version 2.0 (the "License"); you may -// not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package stats - -import ( - "testing" - - "github.com/elastic/beats/metricbeat/helper/prometheus/ptest" -) - -const testFile = "_meta/test/metrics" - -func TestEventMapping(t *testing.T) { - ptest.TestMetricSet(t, "coredns", "stats", - ptest.TestCases{ - { - MetricsFile: "./_meta/test/metrics", - ExpectedFile: "./_meta/test/metrics.expected", - }, - }, - ) -}