Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show results from two splunk queries into one

Tags:

join

splunk

I have two separate splunk queries: 1st Query : Outputs unique user count in last 24 hours 2nd Query : Outputs unique users count in last 24 hours in geo = US

I want to create a timechart that will show , a line chart with % of user everyday from US.

How can this be achieved.

like image 338
A-D Avatar asked Jan 06 '17 22:01

A-D


People also ask

What are Splunk queries?

A Splunk query is used to run a specific operation within the Splunk software. A Splunk query uses the software's Search Processing Language to communicate with a database or source of data. This allows data users to perform analysis of their data by querying it.


2 Answers

You can join the two queries by using :

|

So your query can look like this:

{firstQuery} as countUS| {secondQuery} as countTotal | eval perc=countUS/countTotal
like image 59
Pritam Banerjee Avatar answered Sep 19 '22 15:09

Pritam Banerjee


You can use a conditional to count those from US

Example query:

index=data | timechart dc(user) as dc_user, dc(eval(if(geo=US,user,NULL))) as us_user | eval perc_us=round(us_user/dc_user*100,2) | table _time, perc_us

Alternatively you can use the SPL join command but that would be less efficient as it would have to read the data twice and join the results.

like image 33
user2207243 Avatar answered Sep 16 '22 15:09

user2207243