AppD Archive

Data Collectors for HTTP Session Attributes

CommunityUser
Splunk Employee
Splunk Employee

Is it possible to use an expression to retrieve a value from an HTTP session? I'm trying to capture the username for each HTTP request. The username is stored in a UserProfile object stored as a session attribute with key of 'userProfile'.

I have added a method Data Collector to retrieve the username from the UserProfile on method 'getStaffName()'. I have also added an HTTP data collector that retrieves the sessionkey 'userProfile'. Unfortunately, the getStaffName method does not appear to be called for every request, and the UserProfile object does not have a 'toString' defined.

Is it possible to use an expression to extract a specific field from an object stored as a session attribute?

0 Karma

Arun_Dasetty
Super Champion

Hi,

Have you checked below custom expression referred in below screenshot and see if that helps here:

image.png

Regards,

Arun

0 Karma

CommunityUser
Splunk Employee
Splunk Employee

Unfortunately, that only works when naming a Business Transaction. If you want to use a Data Collector to extract data from a session attribute, it gets a bit more difficult.

 For example, here is the definition of the Data Collector:

image.png

you can see the output of the data collector in HTTP Params, but since there is not toString, it's pretty useless.

image.png

So the question is, can I use an expression when defining a session key for a data instead of a fixed value?

0 Karma

CommunityUser
Splunk Employee
Splunk Employee

Since I am only attemptive to retrieve the user id, I was able to use an expression on User Principal to retrieve the user id I need.

image.png

0 Karma

Arun_Dasetty
Super Champion

Hi David,

i meant sample config, as i stated and you have noticed custom expression is applicable for both BT and http collector collection, good to hear custom expression helped here.

0 Karma
Get Updates on the Splunk Community!

September Community Champions: A Shoutout to Our Contributors!

As we close the books on another fantastic month, we want to take a moment to celebrate the people who are the ...

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...

What’s New in Splunk Observability – September 2025

What's NewWe are excited to announce the latest enhancements to Splunk Observability, designed to help ITOps ...