Hello,
I have a requirement to extract last 2 characters from a given string. Please let me know which logstash function I can use to achieve this.
Thanks,
Kiran
Hello,
I have a requirement to extract last 2 characters from a given string. Please let me know which logstash function I can use to achieve this.
Thanks,
Kiran
You can do that using grok.
grok { match => [ "somefield", "(?<lastTwo>..)$" ] }
Hi Badger,
Thanks for the reply, can you please give an example to understand more.
Thanks
I am using a grok custom pattern. It matches two characters (..) anchored at the end of a line / string (using $).
Note that if you pass a multi-line field to this grok it will match the end of the first line. If you want to match the end of a multi-line field then change $ to \z.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.