From 842000566b5d7cab0a7ed5b1cd1ee00962175a2b Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 21 Aug 2018 09:39:25 +0100 Subject: [PATCH] elasticsearch-curator: add test --- nixos/tests/elk.nix | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/nixos/tests/elk.nix b/nixos/tests/elk.nix index 4c5c441ca265..665e27a05534 100644 --- a/nixos/tests/elk.nix +++ b/nixos/tests/elk.nix @@ -63,6 +63,33 @@ let package = elk.kibana; elasticsearch.url = esUrl; }; + + elasticsearch-curator = { + enable = true; + actionYAML = '' + --- + actions: + 1: + action: delete_indices + description: >- + Delete indices older than 1 minute (based on index name), for logstash- + prefixed indices. Ignore the error if the filter does not result in an + actionable list of indices (ignore_empty_list) and exit cleanly. + options: + ignore_empty_list: True + disable_action: False + filters: + - filtertype: pattern + kind: prefix + value: logstash- + - filtertype: age + source: name + direction: older + timestring: '%Y.%m.%d' + unit: minutes + unit_count: 1 + ''; + }; }; }; }; @@ -91,6 +118,9 @@ let # See if logstash messages arive in elasticsearch. $one->waitUntilSucceeds("curl --silent --show-error '${esUrl}/_search' -H 'Content-Type: application/json' -d '{\"query\" : { \"match\" : { \"message\" : \"flowers\"}}}' | jq .hits.total | grep -v 0"); $one->waitUntilSucceeds("curl --silent --show-error '${esUrl}/_search' -H 'Content-Type: application/json' -d '{\"query\" : { \"match\" : { \"message\" : \"dragons\"}}}' | jq .hits.total | grep 0"); + $one->systemctl("stop logstash"); + $one->systemctl("start elasticsearch-curator"); + $one->waitUntilSucceeds("! curl --silent --show-error '${esUrl}/_cat/indices' | grep logstash | grep -q ^$1"); ''; }; in mapAttrs mkElkTest {