I have text that is not well formatted, and I'm looking for occurrences of some text. In one spot, the text is easy to identify, so I'm identifying the text, and then finding all instances of that text in other areas of the log.
I currently have the following search working nicely to show me the lines I want to look at.
index=my_index [search index=my_index "[mysearch=" | rex "[mysearch=(?<mytext>[^\]]*)" | makemv delim="," mytext | rename mytext to query | fields query]
Given text like such:
[mysearch=111,222,333] Some random text and a row I want
[mysearch=444] Some random text and a row I want
[some silly line] this would not appear with the above query
[some other log] Text that has 111 and 444 and a row I want but also numbers I do not want to count 1 2 3 555
[some silly line] this would not appear with the above query 555 4 2 3 4 8 4444
My search pulls the correct three rows out. Now I'd like to count the occurrences of 111 and 222 and 333 and 444. For the above three lines giving me 2 counts for 111 and 444, and 1 count for 222 and 333, but I can't figure out how to get something like "stats count by mytext" to work.
Any suggestions?
Thanks.
Try this:
| your search here
| rex max_match=0 "=?(?<mytext>\d+)\,?"
| mvexpand mytext
| stats count by mytext
This is the output I'm getting based on the example given above:
mytext count
111 2
222 1
333 1
444 2
Thanks! Worked perfectly!
edit: I thought this was working, but the counts were far lower than I expected. I've modified the original question to show where I think some of the road bumps occur