Splunk Search

How to parse field data with delimiter from dbxquery result?

LearningGuy
Motivator

how to parse field data with delimiter from dbxquery result?
For example: Dbxquery result is
FW Rule name: DNS
FW Rule:  "protocol":udp","port:53","dest_IP:10.10.10.1","direction:ingress"
I would like to have a FW rule display in a separate table in dashboard
Dropdown menu: FW Rule: DNS
Protocol   |  Port  | Dest IP           | Direction
UDP            |   53    | 10.10.10.1   | Ingress

Thanks

0 Karma

richgalloway
SplunkTrust
SplunkTrust

If "protocol":udp" contains an extra quotation mark before the colon then this SPL should do the job.  Otherwise, we may have to resort to rex commands.

<<your dhxquery command>>
| extract pairdelim=",\"", kvdelim=":"
| rename protocol as Protocol, port as Port, dest_IP as "Dest IP", direction as Direction
| table Protocol Port "Dest IP" Direction
---
If this reply helps you, Karma would be appreciated.
0 Karma

LearningGuy
Motivator

Hello,
My apology. Here's actually the format:
[  {"protocol":"value","port":"value","destIP":value}
    {"protocol":"value","port":"value","destIP":value}
    {"protocol":"value","port":"value","destIP":value} ]
Note that value can be within bracket "value", can also be value (without quote)..   this is just an example..  actual data has more key pair and more rows. Thanks

Output needed:
protocol    |    Port    |   Dest IP 
   TCP          |     22       |   10.10.10.1
   UDP          |     53       |   10.10.10.2
   TCP          |      80       |   10.10.10.3   

0 Karma

richgalloway
SplunkTrust
SplunkTrust

See if this works better.  The sample event is not quite JSON so the JSON SPL commands won't work. That means parsing the event manually.

| makeresults 
| eval _raw="[  {\"protocol\":\"value\",\"port\":\"value\",\"destIP\":value}
{\"protocol\":\"value\",\"port\":\"value\",\"destIP\":value}
{\"protocol\":\"value\",\"port\":\"value\",\"destIP\":value} ]" 
``` Above creates test data.  Remove IRL ```
``` Strip off brackets and break at newlines ```
| eval data=split(trim(_raw,"][ "),"
")
``` Put each line in a different event ```
| mvexpand data
``` Extract fields ```
| rex field=data "protocol\":\"?(?<protocol>[^,\"}]+)"
| rex field=data "port\":\"?(?<Port>[^,\"}]+)"
| rex field=data "destIP\":\"?(?<destIP>[^,\"}]+)"
| rename destIP as "Dest IP"
| table protocol Port "Dest IP"

  

---
If this reply helps you, Karma would be appreciated.
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...