Splunk Search

Display in table each unique value and additional field?

splunk_95
Explorer

Hi all,

I am a very new splunk user and would like to conduct produce a table with of each unique ID and the corresponding error message.

For context, each 'event' looks similar to this:

'Date (?) name (?) error details'

So I have managed to extract the ID and ErrorID, but there are often multiple events of the same ID as that particular doc gets updated.

My thinking was to get each unique value of ID and then the corresponding ErrorID, but im not sure how will splunk know which particular event of say (ID=123) to use for the ErrorID (note that for say all 5 instances of ID=123, ErrorID would most likely be the same).

Would one way be telling it to use the first instance of ID to display ErrorID?

I have searched through threads but no one has quite as what I need I believe, I think I may need to use 'Dedup' but not entirely how to make it get the corresponding ErrorID

Cheers everyone - literally any help would be appreciated.

0 Karma

DalJeanis
Legend

As a general case, I've found dedup to be expensive, and I haven't been able to figure out in what cases it is and when it isn't. As long as the events have a _time value, you can use stats with earliest(foo) to get the first value of variable foo.

your search that gets _time, uniqueID and errorID
| stats min(_time) as _time, earliest(errorID) as errorID by uniqueID
0 Karma

mdsnmss
SplunkTrust
SplunkTrust

I believe you are right in using dedup. You can specify multiple fields to dedup by and I think that is what you need:

| dedup ID ErrorID

This will give you all of the possible unique combinations of ID and ErrorID

splunk_95
Explorer

Thanks - out of interest would you know how I could replicate this in a timechart? Im thinking of using dc(distinct count) something like:
dc(ID,ErrorID)? But do you think there would be a better way?
Or is there a way of getting the number of instances of unique combinations? Thinking of maybe using evaland assign a variable this value then usingstats count

0 Karma

woodcock
Esteemed Legend

Create an amalgam field with | eval amalgam = ID . "::::" . ErrorID and timechart with dc(amalgam).

0 Karma

woodcock
Esteemed Legend

Dedup will give you the most recently occurring event for each combination, if you need the first event, just add | reverse before | dedup ....

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 ...