Splunk Search

splunk regex field extraction

Saeed-Hajitorab
New Member

Hello

i want to extract ip field from a log but i give error.

this is a part of my log: ",\"SourceIp\":\"10.10.6.0\",\"N

i want 10.10.6.0 as a field.

can you help me?

 

Labels (1)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

This looks awfully close to a part of a json structure inserted as a string field in another json structure.

It is bad on at least two levels.

1) Embedding json as escaped string prevents it from being properly parsed by Splunk

2) Extracting from structured data with regexes is asking for trouble

richgalloway
SplunkTrust
SplunkTrust

What have you tried so far?  What error do you get?  Are you trying to extract the field at index-time or search-time?

Have you tried this rex command in your search?

| rex "SourceIp\\\\\\":\\\\\\"(?<SourceIp>[\d\.]+)"
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Dashboards: Hiding charts while search is being executed and other uses for tokens

There are a couple of features of SimpleXML / Classic dashboards that can be used to enhance the user ...

Splunk Observability Cloud's AI Assistant in Action Series: Explaining Metrics and ...

This is the fourth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how ...

Brains, Bytes, and Boston: Learn from the Best at .conf25

When you think of Boston, you might picture colonial charm, world-class universities, or even the crack of a ...