Splunk Search

Search in single table with multiple stats

mawani
Engager

Hello,

I am having logs in splunk in below manner.

timestamp "LOGGER= PAGE NAME1 Other text"
timestamp "LOGGER= PAGE NAME1 Other text"
timestamp "LOGGER= PAGE NAME2 Other text"
timestamp "LOGGER= PAGE NAME2 Other text"
timestamp "LOGGER= PAGE NAME3 Other text"
timestamp "LOGGER= PAGE NAME3 Other text"
timestamp "LOGGER= PAGE NAME1 Other text"


I formatted search query
index=index-name ns="namespace" | rex field=_raw "LOGGER=\s*(?<PAGE_NAME1>PAGE NAME1*)" | stats count by PAGE_NAME1
| append [search
index=index-name ns="namespace" | rex field=_raw "LOGGER=\s*(?<PAGE_NAME2>PAGE NAME2*)" | stats count by PAGE_NAME2 ]
| append [search
index=index-name ns="namespace" | rex field=_raw "LOGGER=\s*(?<PAGE_NAME3>PAGE NAME3*)" | stats count by PAGE_NAME3 ]


Got result like

PAGE_NAME1CountPAGE_NAME2PAGE_NAME3
PAGE NAME13  
 2PAGE NAME2 
 2 PAGE NAME3


I am looking result should look below

Page NamePages Visited
PAGE_NAME13
PAGE_NAME32
PAGE_NAME32

Any idea how to format search query ?

Labels (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Try like this

index=index-name ns="namespace" | rex field=_raw "LOGGER=\s*(?<PAGE_NAME>(PAGE NAME1|PAGE NAME2|PAGE NAME3)*)" | stats count by PAGE_NAME1

View solution in original post

0 Karma

somesoni2
Revered Legend

Try like this

index=index-name ns="namespace" | rex field=_raw "LOGGER=\s*(?<PAGE_NAME>(PAGE NAME1|PAGE NAME2|PAGE NAME3)*)" | stats count by PAGE_NAME1
0 Karma

mawani
Engager

Thank You for very quick response and it is working

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...