Skip to content

String expansion on document_id setting #153

@ggrossetie

Description

@ggrossetie

I'm using string expansion (i.e. %{foo}) on document_id setting:

elasticsearch {
  document_id => "%{foo}"
}

The current behavior is:

  • if the event has foo == "bar" then this string: "%{foo}" will return "bar"
  • if a %{foo} value does not exist, then no substitution occurs.

As defined in https://github.com/elastic/logstash/blob/master/lib/logstash/event.rb#L224

I think it's safer to let ElasticSearch generates a document id rather than index a document with id %{foo}. One major issue is that ElasticSearch will overwrite existing entries with the same ID %{foo} 😞

IMHO the default behavior for document_id should be:

  • if the event has foo == "bar" then this string: "%{foo}" will return "bar"
  • if a %{foo} value does not exist, then return nil (and let ElasticSearch generates a document id)

(or at least make this behavior configurable)

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions