Skip to content

Filter log with single word with grep #6634

Answered by RicardoAAD
BlaBlaGITTE asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @BlaBlaGITTE
To exclude all records with only one word(with no blank spaces), you can use this regex ^(\w+)$.

Config example:

[INPUT]
   name tail
   path test.log
   read_from_head true
[FILTER]
   name   grep
   match  *
   exclude log ^(\w+)$
[OUTPUT]
   name stdout
   match *

Log example:

THIS LINE HAS FIVE WORDS


ALL
THESE
LINES
HAVE
ONE
WORD
THIS IS A MULTIWORD LINE
AND
NO
BLANK
SPACES

Fluent bit output:

gh-6634$ ../fluent-bit -c config2.conf
Fluent Bit v2.0.9
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2023/01/23 15:52:16] [ info] [fluent bit] version=2.0.9, commit=27f490ccee, p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@BlaBlaGITTE
Comment options

Answer selected by RicardoAAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #6628 on January 02, 2023 19:05.