Splunk Search

How to display two timecharts on one chart

jerrysplunk88
Explorer

trying to display two timecharts together, to make it easy to spot the time when no response received for the request sent.

the search looks like this

index="production   "sending request"  | dedup requestId
| timechart span=1h sum(count) as count1

| append [search index="production"  "response received"
| dedup requestId | timechart span=1h sum(count) as count2]

this is not showing the two columns (count1 and count2) I was hoping to see,  appendcol doesn't work either .

 

I tried just using just count

index="production   "sending request"  | dedup requestId
| timechart span=1h count

| append [search index="production"  "response received"
| dedup requestId | timechart span=1h count]

this shows only one column called count.

 

Any help is greatly appreciated!

Labels (3)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@jerrysplunk88 

Can you please try this?

index="production" ("sending request" OR "response received")
| dedup requestId
| timechart sum(eval(if(match(_raw,"sending request"),1,0))) as count1, sum(eval(if(match(_raw,"response received"),1,0))) as count2

 

My Sample Search :

| makeresults | eval raw="aaaaaa sending request bbbbb|cccccc response received dddd|aaaaaa sending request bbbbb", raw=split(raw,"|")| mvexpand raw | rename raw as _raw
|eval requestId=1 | accum requestId
| rename comment as "Upto Now is sample data only" 
| dedup requestId
| timechart sum(eval(if(match(_raw,"sending request"),1,0))) as count1, sum(eval(if(match(_raw,"response received"),1,0))) as count2


 Thanks
KV
▄︻̷̿┻̿═━一

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

0 Karma

jerrysplunk88
Explorer

Thanks for the solution, I know it could work but in my case, the request and response have the same request ID so putting them in one search and dedup will get the wrong count.

Is there any way to use two searches and combine the results?

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@jerrysplunk88 

Can you please try this?

YOUR_SEARCH
| eval sr1=if(match(_raw,"sending request"),requestId,null()), sr2=if(match(_raw,"response received"),requestId,null())
| timechart dc(sr1) as count1, dc(sr2) as count2

 

My Sample Search :

| makeresults | eval raw="aaaaaa sending request bbbbb&&cccccc response received dddd|aaaaaa sending request bbbbb", raw=split(raw,"|") | mvexpand raw 
|eval requestId=1 | accum requestId | eval raw=split(raw,"&&") | mvexpand raw  | rename raw as _raw
| rename comment as "Upto Now is sample data only" 
| eval sr1=if(match(_raw,"sending request"),requestId,null()), sr2=if(match(_raw,"response received"),requestId,null())
| timechart dc(sr1) as count1, dc(sr2) as count2

Thanks
KV
▄︻̷̿┻̿═━一

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

Get Updates on the Splunk Community!

Shape the Future of Splunk: Join the Product Research Lab!

Join the Splunk Product Research Lab and connect with us in the Slack channel #product-research-lab to get ...

Auto-Injector for Everything Else: Making OpenTelemetry Truly Universal

You might have seen Splunk’s recent announcement about donating the OpenTelemetry Injector to the ...

[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 ...