Getting Data In

Need help rewriting DNS log lines

the_wolverine
Champion

I have DNS log lines that look like the following:

(4)mail(6)google(3)com(0)
(7)twitter(3)com(0)
(12)spreadsheets(1)l(6)google(3)com(0)

How would I configure rewriting so that Splunk will display them in a more appealing format?

mail.google.com
twitter.com
spreadsheets.l.google.com
Tags (1)
0 Karma
1 Solution

dwaddle
SplunkTrust
SplunkTrust

Can you use rex's sed mode? This may be a little too indiscriminate, but:

blah | rex mode=sed "s/\(\d\)/\./g"

View solution in original post

the_wolverine
Champion
props.conf

[dns]
SEDCMD-dns = s/\(\d\)/\./g s/\(\d\d\)/\./g

* Splunk didn't seem to like \d? so I used \d\d for the cases where we have 2 digits: (12)
0 Karma

the_wolverine
Champion

Ah ok, thanks for that. I can streamline that REGEX now 🙂

0 Karma

gkanapathy
Splunk Employee
Splunk Employee

You need \d+, not \d?. \d? means zero or one digit. If there are never more than two, you can use \d{1,2}

0 Karma

dwaddle
SplunkTrust
SplunkTrust

Can you use rex's sed mode? This may be a little too indiscriminate, but:

blah | rex mode=sed "s/\(\d\)/\./g"

the_wolverine
Champion

Thank you! It seems you don't need the escape for '.' for some reason -- Ultimately, I will use sedcmd to do this.

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