-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new parser to be abble to simply count lines that match pattern #16033
Comments
Je me retrouve avec le même besoin de devoir récupérer le nombre d'occurrence sur une pattern recherchée. Je suis intéressé pour cette évolution |
Could we please stick to English here so everyone can participate in the discussion!? |
@tguenneguez would it make sense to extend the grok parser to be able to do this? The reason is that there are already many predefined patterns that can be used for matching... Furthermore, I wonder what the use case of |
my point of view on the proposals
For a typical user (not a telegraf expert, or a developer of the solution), it is almost impossible to implement this system and make it work. |
@tguenneguez let me address some things you assume:
No, that's wrong. Grok uses regular expression just like what you've shown in your initial post. With grok you just do have the additional benefit of being able to use predefined patterns instead of having the need to come up with regexp for standard things.
Yeah but you could also use a "not matching" regexp for exactly this. Why do you assume that someone in general would be interested in this? Alternatively, we could define a flag that generates a "remaining" metric output which sets a special value. In my view we should have [[inputs.file]]
files = ["example"]
data_format = "grok"
grok_named patterns = [
{ name = "2XX", pattern = " 2\d{2} " },
{ name = "3XX", pattern = " 3\d{2} " },
{ name = "4XX", pattern = ""%{WORD:method} %{PATH:path} HTTP/.?\..?" 4\d{2} " },
{ name = "5XX", pattern = ""%{WORD:method} %{PATH:path} HTTP/.?\..?" 5\d{2} " },
{ name = "default" }
] which should result in
You then can aggregate over the methods and count the patterns if you wish. What do you think? |
Use Case
Be abble to simply count number of line in a stream that match or not a pattern.
I will developpe this plugin, but first I share the goal.
Sample of specification :
Pattern Parser Plugin
The
pattern
parser creates metrics from a stream containing lines.It counts number of lines matching a pattern.
Configuration
Metrics
One metric is created for each search with tag "tag_name" contain "tag_value".
Examples
Config:
Input:
Output:
Config:
Input:
Output:
Expected behavior
Have a simple plugin to count lines that match a pattern.
Actual behavior
In fact, some use cases are possible by combining grok and aggregator, but it is very heavy to implement.
It is also very difficult to configure these plugins well, especially with logs whose content is not precisely structured. For example, counting the words "Error" anywhere in a string.
Finally, if no line matches, no value is returned.
Additional info
No response
The text was updated successfully, but these errors were encountered: