Splunk Search

Search same transaction_id in 2 different services.

onthakur
Explorer

Team,

 

I have a situation where user is calling service 1 and then service1 calls service2 using same transaction_id
sometime it happens that user is calling service 1 but it is not calling service2 and vise versa.

I need a query which will show result in table format and show yes/No if service 1/2 called or not.

transaction_id , service1_status , service2_status.

1234 , yes ,yes

5678, yes, No

Ex :-

log of service 1 :- <timestamp> <transaction_id> <service1 URL>
log of service 2 :- <timestamp> <transaction_id> <service2 URL>

 

Labels (1)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

Given that a transaction_id would either not exist if a user never calls service 1, or it doesn't matter to your problem, service1_status is superfluous.  Is this correct?  I also do not see service URL as part of required output.  As such, @gcusello's solution can be further simplified.  More than that, I'm not sure if service is an existing field.  On the other hand, the two services are probably logged into different sources or different sourcetypes or both different.  I will assume that service 1 logs into source1 and service 2 logs into source 2.

 

source IN (source1, source2)
| stats 
     dc(source) AS service_count
     BY transaction_id
| eval status1 = "yes",
     status2=if(service_count > 1,"yes","no")
| table transaction_id status1 status2

 

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @onthakur ,

you can use something like this:

<your_search>
| stats 
     dc(service) AS service_count
     values(service) AS service
     values(url) AS url
     BY transaction_id
| eval 
     status1=if(service_count=2 OR service_count=1 AND service="service1","yes","not"),
     status2=if(service_count=2 OR service_count=1 AND service="service2","yes","not")
| table transaction_id url status1 status2

Ciao.

Giuseppe

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| chart count by transaction_id, url

Where the count for the url is greater than zero, the service has been called

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...