Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change index config in elasticsearch output #4771

Closed
ruflin opened this issue Jul 27, 2017 · 7 comments
Closed

Change index config in elasticsearch output #4771

ruflin opened this issue Jul 27, 2017 · 7 comments
Labels
discuss Issue needs further discussion. libbeat

Comments

@ruflin
Copy link
Contributor

ruflin commented Jul 27, 2017

In beats the elasticsearch index is currently defined as following:

output.elasticsearch.index: "metricbeat-%{[beat.version]}-%{+yyyy.MM.dd}"

This combines the index name with the pattern of the daily indices. The problem that this now brings is that index template pattern and the index name with its pattern should correlate. This means for metricbeat-%{[beat.version]}-%{+yyyy.MM.dd} the template pattern metricbeat-%{[beat.version]}-* is needed. By default this works as expected but breaks if someone changes the pattern logic.

As the index name part in the config contains also the pattern part, it cannot be used for the index template logic. So far we just assume someone didn't change the config. So if someone removed for example the version part from the index name and replaced it with something else, the template will not be loaded.

To solve this problem I suggest to split up the index into two parts:

index: metricbeat-%{[beat.version]}
index_pattern: -%{+yyyy.MM.dd}

Like this the index.name part can be used in the template for setup.template.name and for setup.template.pattern also the index name + * can be used. See #4769

The above change can be made in 2 ways:

Option 1: Non breaking but template magic?

We could introduce index_pattern instead of index.name and index.pattern. If not set, the index.pattern would be empty and everything would work as before. Like this we would not have a breaking change. But if someone uses a new config it would ship with the following:

index.name: metricbeat-%{[beat.version]}
index.pattern: -%{+yyyy.MM.dd}

The problem with this is the old index settigns are used, the auto generation of the template could be wrong as it will include the daily patterns. We could add some magic that detects the daily pattern and removes it but sounds like too much magic to me.

Option 2: Breaking change

We can't have index and index.name as the two will conflict (values vs object). If we introduce the namespaced option above this is a breaking change. If we do a breaking change, we could offer a script that automatically splits up pattern and index name if defaults are used. The good part about the breaking change is that users become aware that this now also has some relation to the template.

@ruflin ruflin added the discuss Issue needs further discussion. label Jul 27, 2017
@andrewkroh
Copy link
Member

Relates to #4724.

@monicasarbu
Copy link
Contributor

monicasarbu commented Nov 20, 2017

I think ideally would be to configure the template and the index in one place under the setup.template and setup.index, considering that one output is enabled at a time.
For example:

setup.index.name=filebeat=%{[beat.version]}

# setup.index.pattern = setup.index.name +yyyy.MM.dd
setup.index.pattern=-%{+yyyy.MM.dd}

# equal to setup.index.name
setup.template.name=

# the template pattern equals setup.template.name + setup.template.pattern
setup.template.pattern=-*

In order to be able to remove the index configuration from the outputs, we need to do some adjustments. For example, for Logstash, the index=filbeat by default. We need to send as metadata not only filebeat but also the Beat version and date ({yyyy.MM.dd}) (what is configured in the setup.index.pattern) and concatenated it in Logstash.

@ruflin
Copy link
Contributor Author

ruflin commented Nov 21, 2017

It's an interesting idea to remove the index pattern from elasticsearch output and move it to setup. This brings related config options closer together. Index is something specific to the ES output but at the same time it's a core to how the beats work and handle data in ES.

It would be great if having all this as meta information would also make it work through Kafka for example.

@ruflin ruflin added the libbeat label Feb 26, 2018
@kazizi-swe
Copy link

@monicasarbu and @ruflin , I cannot change my default Metricbeat index name for Elasticsearch. Did you guys find a fix? I appreciate if you can share it with me.

@ph
Copy link
Contributor

ph commented Jan 3, 2020

@ruflin Is this solved by the new indexing strategy in EPM? If so can we close this issue?

@ruflin
Copy link
Contributor Author

ruflin commented Jan 6, 2020

@ph The new indexing strategy is not going to fix this for Filebeat and Metricbeat but for the agent by not loading the template anymore from the agent side.

I'm good with closing this more with "wont fix" for MB and FB.

@ph
Copy link
Contributor

ph commented Jan 6, 2020

Going to close this as "wont fix"

@ph ph closed this as completed Jan 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Issue needs further discussion. libbeat
Projects
None yet
Development

No branches or pull requests

5 participants