Set indices based on a field value


I'm trying to send my logs to multiple indices based on a field value.
The exemple in the documentation works fine :
But it is based on the content of the message.

I want to do something like this :

   - index: "functional-%{+yyyy.MM.dd}"
          document_type: functional-log
   - index: "technichal-%{+yyyy.MM.dd}"
          document_type: technichal-log
   - index: "other-%{+yyyy.MM.dd}"
          document_type: other-log

The documentation doesn't explain the keyword I can use after the "when" field.
Currently i'm searching information in filebeat github with no success.

How can I do this indices mapping ? Can I find more information somewhere ?

Create multiple indexes while pushing data from filebeat to elasticsearch
(Andrew Kroh) #2

The conditions available should be the same as what are using with the processors. See Please open a new issue in the beats repo so that this gets added to the indices config documentation.

The when condition should be at the same indentation level as index so move yours to the left a bit.


Thanks, this works with this configuration :

  - index: "functional-%{+yyyy.MM.dd}"
      logger_name: "functional"
  - index: "technical-%{+yyyy.MM.dd}"
      logger_name: "technical"
  - index: "other-%{+yyyy.MM.dd}"
      logger_name: "other"

I open a issue here :

(Steffen Siering) #4

why exactly do you need indices? Why didn't you configure:

  index: '%{[logger_name]}-%{+yyyy.MM.dd}'


I updated your ticket, so we will properly document index setting capabilities.


Because I didn't know that we can do this "%{[logger_name]}" in an index name.
Thanks for this information.

(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.