HI Guys,
I have a url like this:
https://localhost/Client/V2/clients/23423/acc/view
https://localhost/Client/V2/clients/23424/acc/view
https://localhost/Client/V2/clients/23425/acc/view
https://localhost/Client/V2/clients/23423/acc/basic
https://localhost/Client/V2/clients/23423/acc/basic
https://localhost/Client/V2/clients/23423/acc/basic
https://localhost/Client/V2/clients/23425/acc/basic
I want to group into two rows
url | count
https://localhost/Client/V2/clients/*/acc/view| 3
https://localhost/Client/V2/clients/*/acc/basic | 4
How can I aggregate?
It is a url field.
I tried with
rex field=url
"https://localhost/Client/V2/clients/(\d+)/*"
| table url
but it did not work.
Please try the following,
| eval new=case(like(_raw,"%/acc/basic"),"basic",like(_raw,"%/acc/view"),"view") | stats count by new
Results
new count
basic 4
view 3
Works as well
| eval new=case(match(_raw,".*?basic"),"basic",match(_raw,".*?view"),"view") | stats count by new
Results
new count
basic 4
view 3
Hi @codebased,
I'm not really sure what the problem is, as you are not going to achieve a count with your regex command.
Let me suggest a possible solution:
yoursearch | rex mode=sed field=url "s/^([^\/]+\/\/[^\/]+\/[^\/]+\/[^\/]+\/[^\/]+\/)\d+(\/.+)/\1*\2/g"| stats count by url
https://regex101.com/r/Ts3HpN/1
It might look a bit cryptic, but it should work for your sample data.
Tell me if it helps!