Splunk Search

Metrics vs Events

brandonamp123
Explorer

Is there a way to use the results of a metrics search as a field value(s) for an event search?

For example, a specific metrics search will display a list of hosts that meet a certain criteria. I would like to take these host results and further integrate them into an event search as the list of hosts to evaluate. The event data in my environment does not log these criteria, while my metrics dimensions do.

Is there another recommended approach to tackle this?

Thanks!

1 Solution

richgalloway
SplunkTrust
SplunkTrust

What have you tried so far? Putting the metrics search within a subsearch should work.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

jpolvino
Builder

If I understand your question, you can name your stats output fields, and then apply some condition on those. For example:
| stats avg(duration) AS AvgDur by host
| where AvgDur>123

And you can do a subsearch to get to a list of hosts you're interested, and then do further refinement on those. For example:
[search your_search_to_get_to_hosts | format]
index=...

The first part can generate a number of hosts that meet criteria, the format line can produce an OR-list of them, and then that list is used as criteria into the follow-on search. Take a look at the format docs to leverage this powerful command.

0 Karma

brandonamp123
Explorer

Very helpful information, thank you!

0 Karma

richgalloway
SplunkTrust
SplunkTrust

What have you tried so far? Putting the metrics search within a subsearch should work.

---
If this reply helps you, Karma would be appreciated.
0 Karma

brandonamp123
Explorer

Subsearch worked, thanks Rich!

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Please accept the answer to help future readers.

---
If this reply helps you, Karma would be appreciated.
0 Karma
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 ...