All Apps and Add-ons

How to get current app name in a search ?

yoho
Contributor

Is there a way to get the current app name in a search ?

I've found how to get the current user name (| rest splunk_server=local /services/authentication/current-context | table username) but I would also need the current app.

The app I'm building is looking in splunk access logs for its own name, so that it displays some statistics about itself, like response time, etc...

 

Labels (1)
0 Karma
1 Solution

thambisetty
SplunkTrust
SplunkTrust

Thanks to @martin_mueller  

 

| rest splunk_server=local /services/authentication/current-context 
| table username 
| eval 
    [ rest /services/search/jobs splunk_server=local 
    | addinfo 
    | where sid=info_sid 
    | rename eai:acl.app as my_app_name 
    | return my_app_name]

 

————————————
If this helps, give a like below.

View solution in original post

yoho
Contributor

It looks like this command doesn't work on a search head cluster because the current sid returned by addinfo is not (yet) in the list of jobs. It's a pitty there's no simple way to get the current app name, except in dashboards.

0 Karma

yoho
Contributor

Thank you both for your answers, I need it in a search but your answer is also very useful @martin_mueller !

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

If this is in a dashboard then you don't need to launch a subsearch, instead you can use the token `$env:app$`: https://docs.splunk.com/Documentation/Splunk/8.0.6/Viz/tokens#Use_global_tokens_to_access_environmen...

thambisetty
SplunkTrust
SplunkTrust

Thanks to @martin_mueller  

 

| rest splunk_server=local /services/authentication/current-context 
| table username 
| eval 
    [ rest /services/search/jobs splunk_server=local 
    | addinfo 
    | where sid=info_sid 
    | rename eai:acl.app as my_app_name 
    | return my_app_name]

 

————————————
If this helps, give a like below.
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...