Expire logstash indexes
authorTom Hughes <tom@compton.nu>
Wed, 29 Jul 2015 17:39:41 +0000 (18:39 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 29 Jul 2015 17:39:41 +0000 (18:39 +0100)
cookbooks/logstash/recipes/default.rb
cookbooks/logstash/templates/default/expire.erb [new file with mode: 0644]

index b2932aa..55675fa 100644 (file)
@@ -53,6 +53,13 @@ service "logstash" do
   supports :status => true, :restart => true
 end
 
+template "/etc/cron.daily/expire-logstash" do
+  source "expire.erb"
+  owner "root"
+  group "root"
+  mode 0755
+end
+
 forwarders = search(:node, "recipes:logstash\\:\\:forwarder")
 
 forwarders.each do |forwarder|
diff --git a/cookbooks/logstash/templates/default/expire.erb b/cookbooks/logstash/templates/default/expire.erb
new file mode 100644 (file)
index 0000000..fcfd85a
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+D=$(date --date="4 days ago" +"%Y.%m.%d")
+
+curl -XDELETE "http://localhost:9200/logstash-${D}"