Splunk Search

Search for a specific subset of values

neilamoran
Explorer

Hi,

Not sure if the problem is the way I'm phrasing my query, but I'm having trouble finding anything that seems (to me, at least) related, so asking for the wisdom of the crowd instead.

If I'm looking for events with a particular subset of values of field x, is there a syntax, command or construction that can save me from typing:

index=myindex source=mysource (myfield=a OR myfield=b OR myfield=c OR myfield=d OR myfield=e)

Can I do something like:

index=myindex source=mysource myfield=in(a,b,c,d,e)

Or, even better:

index=myindex source=mysource myfield=in(a,c-e,h,j-q)

Thus returning all events where the value of myfield is a, c, d, e, h, j, k, l, m, n, o, p or q. I say this just to be really certain I'm explaining myself, and not to seem patronising, I hope. Ideally this would work with numerical values and expressions as well.

Sorry if this is completely obvious and I'm being thick - suffering a little from baby related lack of sleep(!) - just seems like it would be useful functionality and I'm far more certain that I have failed to spot how to do it than that it isn't there at all. Hey - if not, maybe there's room for a feature request!

Thanks in advance,

Neil

Tags (2)

neilamoran
Explorer

Thought I'd just comment on this to see if there's been any change - I've recently bemoaned its lack again when looking through Windows event logs, particularly here I'm looking for a number of different EventCodes, which aren't necessarily sequential so I can't just use less than/greater than to specify a range.

I know I could use macros, or eventtypes (and do, for some things) but its the ad hoc usage that I would really like to see.

Anyone? Bueller?

0 Karma

sdaniels
Splunk Employee
Splunk Employee

You could use a macro if this is something you are going to re-use frequently. There isn't a command to do what you want as far as i know unless you create your own custom search command.

http://docs.splunk.com/Documentation/Splunk/5.0/Search/Usesearchmacros

Here is an example of a macro:

http://wiki.splunk.com/Community:Plotting_a_linear_trendline

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...