My case is using logstash/rabbitmq/graylog2.
I have to use ES 0.18.7 to store messages for Graylog2 since ES 0.18.7
is required by logstash.
The index created by Graylog2 server is "graylog2". All the messages
are indexed by "graylog2".
Now I want to purge messages with 3 minutes expiration (3m is for
test), so I want to use TTL feature of index.
{code}
curl -XPOST 'localhost:9200/graylog2/_close'
{"ok":true,"acknowledged":true}
curl -XPUT http://localhost:9200/graylog2/_settings -d '{"graylog2":
{"_ttl" : { "enabled" : true, "default" : "3m"},"settings":
{"index.number_of_shards":"5","index.number_of_replicas":"1"}}}'
curl -XGET http://localhost:9200/graylog2/_settings
{"graylog2":{"settings":
{"index.number_of_shards":"5","index.number_of_replicas":"1","index.graylog2._ttl.enabled":"true","index.graylog2.settings.index.number_of_shards":"5","index.graylog2._ttl.default":"3d","index.graylog2.settings.index.number_of_replicas":"1"}}}
curl -XPOST 'localhost:9200/graylog2/_open'
{code}
I didn't see any messages deleted after 40 minutes'
observation(messages kept growing and never deleted from Graylog2 Web
GUI) but I thought new messages would be deleted once ttl over 3m.
Could you help me?
Besides, I set TTL for index level, does this mean the whole index
would be deleted after the ttl period, or the messages of the index
would be purged?
I also tried to set ttl according to
http://dev.nuclearrooster.com/2012/05/15/enable-elasticsearch-ttl-for-graylog2-messages/
but nothing changed.
-- check the mapping of graylog2
curl http://localhost:9200/graylog2/message/_mapping
{"message":{"dynamic_templates":[{"store_generic":{"mapping":
{"index":"not_analyzed"},"match":"*"}}],"properties":{"message":
{"analyzer":"whitespace","type":"string"},"level":
{"type":"long"},"host":
{"index":"not_analyzed","type":"string"},"facility":
{"index":"not_analyzed","type":"string"},"file":
{"index":"not_analyzed","type":"string"},"full_message":
{"analyzer":"whitespace","type":"string"},"line":
{"type":"long"},"created_at":{"type":"double"},"streams":
{"index":"not_analyzed","type":"string"}}}}[
-- add ttl setting
curl http://localhost:9200/graylog2/message/_mapping -XPUT -d
'{"message":{"dynamic_templates":[{"store_generic":{"mapping":
{"index":"not_analyzed"},"match":"*"}}],"_ttl" : { "enabled" : true,
"default" : "30d"},"properties":{"message":
{"analyzer":"whitespace","type":"string"},"level":
{"type":"long"},"host":
{"index":"not_analyzed","type":"string"},"facility":
{"index":"not_analyzed","type":"string"},"file":
{"index":"not_analyzed","type":"string"},"full_message":
{"analyzer":"whitespace","type":"string"},"line":
{"type":"long"},"created_at":{"type":"double"},"streams":
{"index":"not_analyzed","type":"string"}}}}'
{"ok":true,"acknowledged":true}
-- check mapping setting after adding ttl, but nothing changed
curl http://localhost:9200/graylog2/message/_mapping
{"message":{"dynamic_templates":[{"store_generic":{"mapping":
{"index":"not_analyzed"},"match":"*"}}],"properties":{"message":
{"analyzer":"whitespace","type":"string"},"level":
{"type":"long"},"host":
{"index":"not_analyzed","type":"string"},"facility":
{"index":"not_analyzed","type":"string"},"file":
{"index":"not_analyzed","type":"string"},"full_message":
{"analyzer":"whitespace","type":"string"},"line":
{"type":"long"},"created_at":{"type":"double"},"streams":
{"index":"not_analyzed","type":"string"}}}}
Regards,