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!

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

Splunk Decoded: Business Transactions vs Business IQ

It’s the morning of Black Friday, and your e-commerce site is handling 10x normal traffic. Orders are flowing, ...

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...