Dashboards & Visualizations

How to join changes queries data output?

Dzmitry
Explorer

Hello

I found a strange behavior of the join command.

Here are two queries:

1) search status=pass | chart dc(id) as pass by name

2) search status=failed | chart dc(id) as failed by name

then I try to join these queries to get one table:

3) search status=pass | chart dc(id) as pass by name | table name pass
| join name [ search status=failed | chart dc(id) as failed by name | table name failed ]
| table name pass failed

For some reason "failed" column values by the query #2 are different to values from join in the query #3, but "pass" column valuesare the same:

query 1 table   query 2 table  
name pass name  failed
Tom  12 Tom  4
Jerry 13 Jerry 5

 

query 3 table    
name pass failed
Tom 12 7
Jerry 13 9
Labels (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @Dzmitry ,

probably you have more than 50,000 results in the subsearch.

Anyway, use join only if you haven't any other solution, so explore something like this:

 

index=your_index (status="pass" OR status="failed")
| stats 
   dc(eval(if(status="pass",id,""))) AS pass 
   dc(eval(if(status="failed",id,""))) AS failed 
   BY name

 

Ciao.

Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @Dzmitry ,

probably you have more than 50,000 results in the subsearch.

Anyway, use join only if you haven't any other solution, so explore something like this:

 

index=your_index (status="pass" OR status="failed")
| stats 
   dc(eval(if(status="pass",id,""))) AS pass 
   dc(eval(if(status="failed",id,""))) AS failed 
   BY name

 

Ciao.

Giuseppe

Dzmitry
Explorer

Hi Giuseppe
Thank you for the help

May I ask one more question?
In case when I have to use count command
1) search status='passed' | stats count(status) as pass by name
2) search status='failed' | stats count(status) as failed by name
then I try to combine them:
3) 
| stats
count(eval(if(status="pass", status, 0))) AS passed
count(eval(if(status="failed" , status, 0))) AS failed
BY name
| table name passed failed

Columns have same values

query 3 tablepassfailed
Tom1616
Jerry1818

 

0 Karma

Dzmitry
Explorer

| stats
count(eval(status="pass")) AS passed
count(eval(status="failed" )) AS failed
BY name

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Dzmitry,

yes, in the stats command you can put more functions, also both dc and count and you can use eval in each of them.

Ciao,

Giuseppe

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

There doesn't appear to be anything wrong with the queries so perhaps it is something about your data or the actual queries rather than the example ones.

Please can you provide some real, but anonymised, data or indeed fabricated data, demonstrating the issue?

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...