Splunk Search

Search and filter by fieldname

OldManEd
Builder

I have a simple search query that is collecting data from XML. The search query is below;

sourcetype=someSourceType userid success* | rex \"FIELDA>(?<myfield>\[^\\<\]+)\"

And it gives me a bunch of data. And that's OK except my result set should not include anything where "myfield='123abc'".

Can someone tell me how to accomplish this task.
(I'm really new to Splunk.)

The input data looks like this;

<log>
    <FIELDA>111aaa</FIELDA>
</log>
<log>
    <FIELDA>123abc</FIELDA>
</log>
<log>
    <FIELDA>222bbb</FIELDA>
</log>
Tags (2)
0 Karma

OldManEd
Builder

Ayn,

Thanks but I tried that and it didn't work for some reason. But that's OK. I just came up with another solution. I added this to the query;

sourcetype=someSourceType userid success* NOT ("<FIELDA>123abc")  | rex \"FIELDA>(?<myfield>\[^\\<\]+)\"

And that seemed to work just fine.

Thanks for your suggestion.

0 Karma

jtrucks
Splunk Employee
Splunk Employee

I think there was some miscommunication. I suspect Ayn is suggesting doing:

sourcetype=someSourceType userid success* | rex \"FIELDA>(?[^\<]+)\" | search NOT myfield=123abc

Which will work.

--
Jesse Trucks
Minister of Magic

Ayn
Legend

If you're new to Splunk I'd advise you to look into why the other solution didn't work - not that the alternative solution isn't fine, just that the solution I provided should work just fine if you're extracting the field correctly.

0 Karma

Ayn
Legend

Add at the end:

... | search NOT myfield=...
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...