Splunk Search

Extract certain rows of column with data starting on certain keywords

gemrose
Explorer

I am looking for a solution to extract rows containing certain keywords from column "X".  and the remaining data will add to "Total". For example any keyword with SI or SB will be added to count field "Log" and the other entries excluding empty cell will be added to count field "Total".

SNOX

1

400
2SI-SCRIPT-ERROR
3(SI-BPR-01)
4SB-Timeout
5SB-OrderFound
6(SB-BPR-02)--(SB-EXL-001)
7201
8SI-RAS-200
9<empty>

 

Labels (5)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

Something like

| where match(X, "\b(SI|SB)\b")
| stats sum(SNO) as SNO_total

Here is a full emulation

| makeresults format=csv data="SNO,	X
1,400
2,	SI-SCRIPT-ERROR
3,	(SI-BPR-01)
4,	SB-Timeout
5,	SB-OrderFound
6,	(SB-BPR-02)--(SB-EXL-001)
7,	201
8,	SI-RAS-200
9,"
``` data emulation above ```
| where match(X, "\b(SI|SB)\b")
| stats sum(SNO) as SNO_total

Result is

SNO_total
28

View solution in original post

0 Karma

yuanliu
SplunkTrust
SplunkTrust

Something like

| where match(X, "\b(SI|SB)\b")
| stats sum(SNO) as SNO_total

Here is a full emulation

| makeresults format=csv data="SNO,	X
1,400
2,	SI-SCRIPT-ERROR
3,	(SI-BPR-01)
4,	SB-Timeout
5,	SB-OrderFound
6,	(SB-BPR-02)--(SB-EXL-001)
7,	201
8,	SI-RAS-200
9,"
``` data emulation above ```
| where match(X, "\b(SI|SB)\b")
| stats sum(SNO) as SNO_total

Result is

SNO_total
28
0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...