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!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...