Splunk Search

How to convert this SQL query to splunk search

Explorer

Hi ,
I have a sql query ,
Count distinct CHNL where MSGNUM like 'cma%' group by MSGTM.
Result should get display in hourly basis,

all the CHNL , MSGNUM , MSGTM is the column name , which has values . Kindly need your help to convert it .Result should be in hourly basis.

1 Solution

SplunkTrust
SplunkTrust

Try something like,

index=foo sourceltype=bar MSG_NUM=cma* 
| bucket span=1h _time
| stats dc(CHNL) as uniq_channels by _time MSG_TM

or

index=foo sourceltype=bar MSG_NUM=cma* 
| timechart span=1h  dc(CHNL)  by MSG_TM

View solution in original post

SplunkTrust
SplunkTrust

Try something like,

index=foo sourceltype=bar MSG_NUM=cma* 
| bucket span=1h _time
| stats dc(CHNL) as uniq_channels by _time MSG_TM

or

index=foo sourceltype=bar MSG_NUM=cma* 
| timechart span=1h  dc(CHNL)  by MSG_TM

View solution in original post

Explorer

Thank you so much it works perfect with few modification.

0 Karma

SplunkTrust
SplunkTrust

Is your data already indexed or are you trying to read a SQL database from Splunk? If the former, see http://docs.splunk.com/Documentation/Splunk/6.5.2/SearchReference/SQLtoSplunk. If the latter, check out the Splunk DB Connect app.

---
If this reply helps you, an upvote would be appreciated.
0 Karma