Splunk AppDynamics

Getting the last object in a list for a .NET data collector

Harrison_Clark
Explorer

 I'm setting up some new data collectors and need to retrieve the last item in a list in the getter chain.  I'm currently just grabbing the 7th item, but this list has variable sizes and the element I want should always be the last item.  I have tried List.[int/-1], but that didn't work and I get an "Unable to process" error message in the data collector.

Has anyone been able to do this?

Labels (1)
0 Karma

Raunak_Mohanty
Builder

Hi Harrison,

  I dont think -ve indexes on List are allowed by CLR. We are looking for some alternatives for you Last(),LastorDefault() could be an option but these are extesnion methods so checking if these are supported.

Thanks,

Raunak

0 Karma

Harrison_Clark
Explorer

Hi Raunak,

I did try .Last(), but it did not work either.  Based on what I could find, that method requires System.Linq

0 Karma

Raunak_Mohanty
Builder

Hi Harrison,

  Yes that is correct observation. Since these method are extension methods ( static by nature) we wont be able use getters.

We have tried various other alternatives with out any success. At this point of time we are going ahead and creating an enhacement request for the dev team to better getter supportability on Collections.

At this point only alternative is to use index ( may be define the collector on few indexes if you know max number of items) 

Or apply the MIDC on some property which has this value or create a instance level property and assign the last value of the List to this property. I know this is not elegant solution but enhancement should give us better capability  

Thanks,

Raunak

0 Karma
Get Updates on the Splunk Community!

Get Schooled with Splunk Education: Explore Our Latest Courses

At Splunk Education, we’re dedicated to providing incredible learning experiences that cater to every skill ...

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL  The Splunk AI Assistant for SPL ...

Buttercup Games: Further Dashboarding Techniques (Part 5)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...