Logstash pipeline configuration. Can someone please hep me? Thank you

Hello Everyone, Can someone please help me on this one?

data in the kafka topic test sample:
{
"id": "2001",
"name": "XYZ",
"address" : "safwq",
"phone": "1656161"
}

Sample Logstash configuration for creating a simple

input {
kafka {
bootstrap_servers => "localhost:9092"
group_id => "test-consumer-group"
topics => ["test"]
auto_offset_reset => "earliest"
codec => json
}
}
filter {

}
output {
stdout { codec => rubydebug }
Elasticsearch {
hosts => ["localhost:9200"]
codec => json
index => "sample-%{[id]}-%{+MM.YYYY}"
}
}

Here I'm trying to create a logstash pipeline, I'm able to do it but now I wanted to add a filter:
i.e the total length of the id should be 10. and if it is not 10 then i need to add leading zeroes.
For aboove sample:
output of the index should be like :

sample-0000002001-04.2022

if the id is 1 then it should be

sample-0000000001-04.2022

the length of id can be equal to 10 or less than 10.

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