Inserting text file containing key-value pairs into Elastic Search using Logstash

Hello All,

I'm relatively new to Elastic Stack. I wanted to understand how I can insert each record(line) as an individual document into Elastic Search from my text file using Logstash.

Below is a sample content of my file:
name=John|age=30|city=NewYork|country=USA
name=Alice|age=25|city=London|country=UK
name=Raj|age=35|city=Mumbai|country=India

Would really appreciate any help on this!

Welcome!

You can use a file input, then a dissect filter and then an Elasticsearch output.

But I'd probably try to use filebeat instead and use the dissect processor. Look at Dissect strings | Filebeat Reference [8.15] | Elastic

If this does not work, you could also try the dissect processor in Elasticsearch: Dissect processor | Elasticsearch Guide [8.15] | Elastic

1 Like

Thanks David
Appreciate the quick response!

You can use KV filter. Something like this:

   kv { 
      source => "message"
      value_split => "="
      field_split => "|"
   }

Since it's a simple format, grok is also applicable.

2 Likes