diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/40_search.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/40_search.yml new file mode 100644 index 0000000000000..5227377249e66 --- /dev/null +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/40_search.yml @@ -0,0 +1,261 @@ +setup: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + indices.create: + index: test + body: + settings: + index: + mode: time_series + mappings: + properties: + "@timestamp": + type: date + metricset: + type: keyword + time_series_dimension: true + k8s: + properties: + pod: + properties: + uid: + type: keyword + time_series_dimension: true + name: + type: keyword + ip: + type: ip + network: + properties: + tx: + type: long + rx: + type: long + - do: + bulk: + refresh: true + index: test + body: + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.1", "network": {"tx": 2001818691, "rx": 802133794}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:24.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.1", "network": {"tx": 2005177954, "rx": 801479970}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:44.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.1", "network": {"tx": 2006223737, "rx": 802337279}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:51:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.2", "network": {"tx": 2012916202, "rx": 803685721}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:03.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434521831, "rx": 530575198}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:23.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434577921, "rx": 530600088}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:53.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434587694, "rx": 530604797}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:51:03.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434595272, "rx": 530605511}}}}' + +--- +query a dimension: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + search: + index: test + body: + query: + match: + k8s.pod.uid: 947e4ced-1786-4e53-9e0c-5c447e959507 + + - match: {hits.total.value: 4} + +--- +query a metric: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + search: + index: test + body: + query: + range: + k8s.pod.network.tx: + gt: 2006223737 + + - match: {hits.total.value: 1} + +# TODO add test showing that quering _tsid fails + +--- +fetch a dimension: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + search: + index: test + body: + fields: + - field: k8s.pod.uid + query: + query_string: + query: '+@timestamp:"2021-04-28T18:51:04.467Z" +k8s.pod.name:cat' + + - match: {hits.total.value: 1} + - match: {hits.hits.0.fields.k8s\.pod\.uid: [947e4ced-1786-4e53-9e0c-5c447e959507]} + +--- +fetch a metric: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + search: + index: test + body: + fields: + - field: k8s.pod.network.tx + query: + query_string: + query: '+@timestamp:"2021-04-28T18:51:04.467Z" +k8s.pod.name:cat' + + - match: {hits.total.value: 1} + - match: {hits.hits.0.fields.k8s\.pod\.network\.tx: [2012916202]} + - is_false: hits.hits.0.fields._tsid # tsid isn't fetched by default + +--- +fetch a tag: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + search: + index: test + body: + fields: + - field: k8s.pod.ip + query: + query_string: + query: '+@timestamp:"2021-04-28T18:51:04.467Z" +k8s.pod.name:cat' + + - match: {hits.total.value: 1} + - match: {hits.hits.0.fields.k8s\.pod\.ip: ['10.10.55.2']} + - is_false: hits.hits.0.fields._tsid # tsid isn't fetched by default + +# TODO add test to fetch the tsid + +--- +aggregate a dimension: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + search: + index: test + body: + size: 0 + aggs: + uids: + terms: + field: k8s.pod.uid + + - match: {hits.total.value: 8} + - match: {aggregations.uids.buckets.0.key: 947e4ced-1786-4e53-9e0c-5c447e959507} + - match: {aggregations.uids.buckets.0.doc_count: 4} + - match: {aggregations.uids.buckets.1.key: df3145b3-0563-4d3b-a0f7-897eb2876ea9} + - match: {aggregations.uids.buckets.1.doc_count: 4} + +--- +aggregate a metric: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + search: + index: test + body: + size: 0 + aggs: + uids: + terms: + field: k8s.pod.uid + aggs: + max_rx: + max: + field: k8s.pod.network.rx + + - match: {hits.total.value: 8} + - match: {aggregations.uids.buckets.0.key: 947e4ced-1786-4e53-9e0c-5c447e959507} + - match: {aggregations.uids.buckets.0.doc_count: 4} + - match: {aggregations.uids.buckets.0.max_rx.value: 803685721} + - match: {aggregations.uids.buckets.1.key: df3145b3-0563-4d3b-a0f7-897eb2876ea9} + - match: {aggregations.uids.buckets.1.doc_count: 4} + - match: {aggregations.uids.buckets.1.max_rx.value: 530605511} + +--- +aggregate a tag: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + search: + index: test + body: + size: 0 + aggs: + ips: + terms: + field: k8s.pod.ip + order: + _key: asc + + - match: {hits.total.value: 8} + - match: {aggregations.ips.buckets.0.key: 10.10.55.1} + - match: {aggregations.ips.buckets.0.doc_count: 3} + - match: {aggregations.ips.buckets.1.key: 10.10.55.2} + - match: {aggregations.ips.buckets.1.doc_count: 1} + - match: {aggregations.ips.buckets.2.key: 10.10.55.3} + - match: {aggregations.ips.buckets.2.doc_count: 4} + + +# TODO add a test aggregating the _tsid + +--- +field capabilities: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + field_caps: + index: test + fields: [k8s.pod.uid, k8s.pod.network.rx, k8s.pod.ip, _tsid] + + # TODO assert time_series_metric and time_series_dimension + - match: {fields.k8s\.pod\.uid.keyword.searchable: true} + - match: {fields.k8s\.pod\.uid.keyword.aggregatable: true} + - is_false: fields.k8s\.pod\.uid.keyword.indices + - is_false: fields.k8s\.pod\.uid.keyword.non_searchable_indices + - is_false: fields.k8s\.pod\.uid.keyword.non_aggregatable_indices + - match: {fields.k8s\.pod\.network\.rx.long.searchable: true} + - match: {fields.k8s\.pod\.network\.rx.long.aggregatable: true} + - is_false: fields.k8s\.pod\.network\.rx.long.indices + - is_false: fields.k8s\.pod\.network\.rx.long.non_searchable_indices + - is_false: fields.k8s\.pod\.network\.rx.long.non_aggregatable_indices + - match: {fields.k8s\.pod\.ip.ip.searchable: true} + - match: {fields.k8s\.pod\.ip.ip.aggregatable: true} + - is_false: fields.k8s\.pod\.ip.ip.indices + - is_false: fields.k8s\.pod\.ip.ip.non_searchable_indices + - is_false: fields.k8s\.pod\.ip.ip.non_aggregatable_indices + # TODO assert tsid once we build it: diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/50_alias.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/50_alias.yml new file mode 100644 index 0000000000000..21ddeb55b13c3 --- /dev/null +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/50_alias.yml @@ -0,0 +1,87 @@ +setup: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + indices.create: + index: test + body: + settings: + index: + mode: time_series + mappings: + properties: + "@timestamp": + type: date + metricset: + type: keyword + time_series_dimension: true + k8s: + properties: + pod: + properties: + uid: + type: keyword + time_series_dimension: true + name: + type: keyword + ip: + type: ip + network: + properties: + tx: + type: long + rx: + type: long + - do: + bulk: + refresh: true + index: test + body: + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.1", "network": {"tx": 2001818691, "rx": 802133794}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:24.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.1", "network": {"tx": 2005177954, "rx": 801479970}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:44.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.1", "network": {"tx": 2006223737, "rx": 802337279}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:51:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.2", "network": {"tx": 2012916202, "rx": 803685721}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:03.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434521831, "rx": 530575198}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:23.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434577921, "rx": 530600088}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:53.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434587694, "rx": 530604797}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:51:03.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434595272, "rx": 530605511}}}}' + +# TODO search on _tsid in an alias + +--- +index into alias: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + indices.put_alias: + index: test + name: test_alias + + - do: + bulk: + refresh: true + index: test_alias + body: + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:03.142Z", "metricset": "pod", "k8s": {"pod": {"name": "cow", "uid":"1c4fc7b8-93b7-4ba8-b609-2a48af2f8e39", "ip": "10.10.55.4", "network": {"tx": 1434521831, "rx": 530575198}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:23.142Z", "metricset": "pod", "k8s": {"pod": {"name": "cow", "uid":"1c4fc7b8-93b7-4ba8-b609-2a48af2f8e39", "ip": "10.10.55.4", "network": {"tx": 1434577921, "rx": 530600088}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:53.142Z", "metricset": "pod", "k8s": {"pod": {"name": "cow", "uid":"1c4fc7b8-93b7-4ba8-b609-2a48af2f8e39", "ip": "10.10.55.4", "network": {"tx": 1434587694, "rx": 530604797}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:51:03.142Z", "metricset": "pod", "k8s": {"pod": {"name": "cow", "uid":"1c4fc7b8-93b7-4ba8-b609-2a48af2f8e39", "ip": "10.10.55.4", "network": {"tx": 1434595272, "rx": 530605511}}}}' + - match: {errors: false} + + # TODO search on tsid once we generate it diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/60_add_dimensions.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/60_add_dimensions.yml new file mode 100644 index 0000000000000..f593f554824cb --- /dev/null +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/60_add_dimensions.yml @@ -0,0 +1,231 @@ +--- +add dimensions with put_mapping: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + indices.create: + index: test + body: + settings: + index: + mode: time_series + mappings: + properties: + "@timestamp": + type: date + + # TODO verify its an error to index without an declared dimensions #77731 + + - do: + indices.put_mapping: + index: test + body: + properties: + metricset: + type: keyword + time_series_dimension: true + + - do: + index: + index: test + refresh: true + body: + "@timestamp": "2021-04-28T18:35:24.467Z" + metricset: cat + + - do: + search: + index: test + body: + fields: + # TODO fetch the tsid + - field: "@timestamp" + + - match: {hits.total.value: 1} + # TODO Fetch the tsid + - match: {hits.hits.0.fields.@timestamp: ["2021-04-28T18:35:24.467Z"]} + +--- +add dimensions to no dims with dynamic_template over index: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + indices.create: + index: test + body: + settings: + index: + mode: time_series + mappings: + dynamic_templates: + - keywords: + match_mapping_type: string + mapping: + type: keyword + time_series_dimension: true + properties: + "@timestamp": + type: date + + - do: + index: + index: test + refresh: true + body: + "@timestamp": "2021-04-28T18:35:24.467Z" + metricset: cat + - match: {result: created} + + - do: + search: + index: test + body: + fields: + # TODO fetch the tsid + - field: "@timestamp" + - match: {hits.total.value: 1} + # TODO fetch the tsid + - match: {hits.hits.0.fields.@timestamp: ["2021-04-28T18:35:24.467Z"]} + +--- +add dimensions to no dims with dynamic_template over bulk: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + indices.create: + index: test + body: + settings: + index: + mode: time_series + mappings: + dynamic_templates: + - keywords: + match_mapping_type: string + mapping: + type: keyword + time_series_dimension: true + properties: + "@timestamp": + type: date + + - do: + bulk: + index: test + refresh: true + body: + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:24.467Z", "metricset": "cat"}' + - is_false: errors + + - do: + search: + index: test + body: + fields: + # TODO fetch tsid + - field: "@timestamp" + - match: {hits.total.value: 1} + # TODO fetch tsid + - match: {hits.hits.0.fields.@timestamp: ["2021-04-28T18:35:24.467Z"]} + +--- +add dimensions to some dims with dynamic_template over index: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + indices.create: + index: test + body: + settings: + index: + mode: time_series + mappings: + dynamic_templates: + - keywords: + match_mapping_type: string + mapping: + type: keyword + time_series_dimension: true + properties: + "@timestamp": + type: date + metricset: + type: keyword + time_series_dimension: true + + - do: + index: + index: test + refresh: true + body: + "@timestamp": "2021-04-28T18:35:24.467Z" + metricset: cat + other_dim: cat + - match: {result: created} + + - do: + search: + index: test + body: + fields: + # TODO fetch tsid + - field: "@timestamp" + - match: {hits.total.value: 1} + # TODO fetch tsid + - match: {hits.hits.0.fields.@timestamp: ["2021-04-28T18:35:24.467Z"]} + +--- +add dimensions to some dims with dynamic_template over bulk: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + indices.create: + index: test + body: + settings: + index: + mode: time_series + mappings: + dynamic_templates: + - keywords: + match_mapping_type: string + mapping: + type: keyword + time_series_dimension: true + properties: + "@timestamp": + type: date + metricset: + type: keyword + time_series_dimension: true + + - do: + bulk: + index: test + refresh: true + body: + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:24.467Z", "metricset": "cat", "other_dim": "cat"}' + - is_false: errors + + - do: + search: + index: test + body: + fields: + # TODO fetch tsid + - field: "@timestamp" + - match: {hits.total.value: 1} + # TODO fetch tsid + - match: {hits.hits.0.fields.@timestamp: ["2021-04-28T18:35:24.467Z"]} diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/70_dimension_types.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/70_dimension_types.yml new file mode 100644 index 0000000000000..80d049a7e43d2 --- /dev/null +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/70_dimension_types.yml @@ -0,0 +1,137 @@ +keyword dimension: + - skip: + features: close_to + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + indices.create: + index: test + body: + settings: + index: + mode: time_series + mappings: + properties: + "@timestamp": + type: date + uid: + type: keyword + time_series_dimension: true + + - do: + bulk: + refresh: true + index: test + body: + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:24.467Z", "uid": "947e4ced-1786-4e53-9e0c-5c447e959507", "voltage": 7.2}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:34.467Z", "uid": "947e4ced-1786-4e53-9e0c-5c447e959507", "voltage": 7.6}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:44.467Z", "uid": "947e4ced-1786-4e53-9e0c-5c447e959507", "voltage": 7.1}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:54.467Z", "uid": "947e4ced-1786-4e53-9e0c-5c447e959507", "voltage": 7.3}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:24.467Z", "uid": "df3145b3-0563-4d3b-a0f7-897eb2876ea9", "voltage": 3.2}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:34.467Z", "uid": "df3145b3-0563-4d3b-a0f7-897eb2876ea9", "voltage": 3.6}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:44.467Z", "uid": "df3145b3-0563-4d3b-a0f7-897eb2876ea9", "voltage": 3.1}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:54.467Z", "uid": "df3145b3-0563-4d3b-a0f7-897eb2876ea9", "voltage": 3.3}' + - is_false: errors + + # TODO aggregate on tsid + +--- +long dimension: + - skip: + features: close_to + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + indices.create: + index: test + body: + settings: + index: + mode: time_series + mappings: + properties: + "@timestamp": + type: date + id: + type: long + time_series_dimension: true + + - do: + bulk: + refresh: true + index: test + body: + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:24.467Z", "id": 1, "voltage": 7.2}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:34.467Z", "id": "1", "voltage": 7.6}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:44.467Z", "id": 1.0, "voltage": 7.1}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:54.467Z", "id": "001", "voltage": 7.3}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:24.467Z", "id": 2, "voltage": 3.2}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:34.467Z", "id": 2, "voltage": 3.6}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:44.467Z", "id": 2, "voltage": 3.1}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:54.467Z", "id": 2, "voltage": 3.3}' + + # TODO aggregate on tsid + +--- +ip dimension: + - skip: + features: close_to + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + indices.create: + index: test + body: + settings: + index: + mode: time_series + mappings: + properties: + "@timestamp": + type: date + ip: + type: ip + time_series_dimension: true + + - do: + bulk: + refresh: true + index: test + body: + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:24.467Z", "ip": "10.10.1.1", "voltage": 7.2}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:34.467Z", "ip": "10.10.1.1", "voltage": 7.6}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:44.467Z", "ip": "10.10.1.1", "voltage": 7.1}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:54.467Z", "ip": "::ffff:10.10.1.1", "voltage": 7.3}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:24.467Z", "ip": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", "voltage": 3.2}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:34.467Z", "ip": "2001:0db8:85a3:0:0:8a2e:0370:7334", "voltage": 3.6}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:44.467Z", "ip": "2001:0db8:85a3::8a2e:0370:7334", "voltage": 3.1}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:35:54.467Z", "ip": "2001:0db8:85a3::8a2e:0370:7334", "voltage": 3.3}' + + # TODO aggregate on tsid diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/80_index_resize.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/80_index_resize.yml new file mode 100644 index 0000000000000..b91b5e55150c5 --- /dev/null +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/80_index_resize.yml @@ -0,0 +1,162 @@ +setup: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + indices.create: + index: test + body: + settings: + index: + mode: time_series + number_of_shards: 3 + number_of_replicas: 0 + mappings: + properties: + "@timestamp": + type: date + metricset: + type: keyword + time_series_dimension: true + k8s: + properties: + pod: + properties: + uid: + type: keyword + time_series_dimension: true + name: + type: keyword + ip: + type: ip + network: + properties: + tx: + type: long + rx: + type: long + - do: + bulk: + refresh: true + index: test + body: + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.1", "network": {"tx": 2001818691, "rx": 802133794}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:24.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.1", "network": {"tx": 2005177954, "rx": 801479970}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:44.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.1", "network": {"tx": 2006223737, "rx": 802337279}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:51:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.2", "network": {"tx": 2012916202, "rx": 803685721}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:03.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434521831, "rx": 530575198}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:23.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434577921, "rx": 530600088}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:50:53.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434587694, "rx": 530604797}}}}' + - '{"index": {}}' + - '{"@timestamp": "2021-04-28T18:51:03.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434595272, "rx": 530605511}}}}' + + - do: + indices.put_settings: + index: test + body: + index.blocks.write: true + +--- +split: + - skip: + version: all + reason: shard splitting doesn't work yet + features: "arbitrary_key" + + - do: + indices.split: + index: test + target: test_split + body: + settings: + index.number_of_replicas: 0 + index.number_of_shards: 6 + + - do: + search: + index: test_split + body: + fields: + # TODO fetch tsid + query: + query_string: + query: '+@timestamp:"2021-04-28T18:51:04.467Z" +k8s.pod.name:cat' + + - match: {hits.total.value: 1} + # TODO test fetching tsid + +--- +shrink: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + features: "arbitrary_key" + + - do: + nodes.info: + node_id: data:true + - set: + nodes._arbitrary_key_: node_id + + - do: + indices.put_settings: + index: test + body: + index.routing.allocation.include._id: $node_id + + - do: + cluster.health: + wait_for_status: green + wait_for_no_relocating_shards: true + index: test + + - do: + indices.shrink: + index: test + target: test_shrink + body: + settings: + index.number_of_shards: 1 + + - do: + search: + index: test_shrink + body: + # TODO test fetching tsid + query: + query_string: + query: '+@timestamp:"2021-04-28T18:51:04.467Z" +k8s.pod.name:cat' + + - match: {hits.total.value: 1} + # TODO test fetching tsid + +--- +clone: + - skip: + version: " - 7.99.99" + reason: introduced in 8.0.0 + + - do: + indices.clone: + index: test + target: test_clone + + - do: + search: + index: test_clone + body: + # TODO test fetching tsid + query: + query_string: + query: '+@timestamp:"2021-04-28T18:51:04.467Z" +k8s.pod.name:cat' + + - match: {hits.total.value: 1} + # TODO test fetching tsid