I'm trying to build a query in humio as below
regex(regex=".*MY NAME IS (?)", field=MESSAGE) | MESSAGE=${name}
Example of my server logs:
- MY NAME IS John
- John logged in on Monday
- MY NAME IS SID
- SID logged in on Tuesday
- SID logged out
- LOHI logged in on Wednesday
- LOHI logged out
First part of the query is a regex function trying to retrieve all records that start with MY NAME IS from MESSAGE column and take the name and then I want to provide that name value to second statement to search the MESSAGE column data
So per above server log example: I need a query that can return below rows in HUMIO:
- MY NAME IS John
- John logged in on Monday
- MY NAME IS SID
- SID logged in on Tuesday
- SID logged out
it should not return below rows as there is no MY NAME IS log statement
- LOHI logged in on Wednesday
- LOHI logged out
Okay, you're looking for something like this then:
This takes a bit of work, since Humio can't check if a string contains a dynamic substring (at the moment). If the
MESSAGE
field has a limited number of permutations that you know up front, you can do something like this:The
join
lets you combine two sets of data. In this case, the firstregex
finds all applicable user names, and the subquery extracts the user names from the other log events, so you can get the events that have a match.If you go for this approach, you can also consider doing the
match
inside a parser, such that there is always auserName
field ready to work with.Alternatively, if you control the logs yourself, maybe you can tweak the messages by adding a user name field at the time they are sent?
Then the query would be much more trivial to do, as the
join
subquery only needs to look for log events that contain any user name that it can join on:I hope some of this is useful :)