Getting Data In

How to extract json from event with = separated values?

zachsisinst
Explorer

 

Hello, I have the following type of event, and I would like to extract the `tags` field into its respective fields. 

 

2022-10-17 06:50:00.997, root_device_name="/dev/sda1", root_device_type="ebs",  state_name="running", subnet_id="subnet-REDACTED", tags="{"App": "myapp", "Name": "myserver", "Owner": "myteam", "Scope": "myscope", "AWSBackup": "True", "Environment": "myenv", "Compliance requirement": "N/A"}", virtualization_type="hvm",  vpc_id="vpc-REDACTED"

 



I have tried the following which did not work for me: 

 

index=myindex sourcetype=mysourcetype earliest=@d i-REDACTED source=awsec2instances
| spath input=tags 

 

How do I extract these JSON fields from an event like this? 

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| rex "tags=\"(?<tags>\{[^\}]+\})"
| spath input=tags
0 Karma
Get Updates on the Splunk Community!

Splunk MCP & Agentic AI: Machine Data Without Limits

  Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization ...

Finding Based Detections General Availability

Overview  We’ve come a long way, folks, but here in Enterprise Security 8.4 I’m happy to announce Finding ...

Get Your Hands Dirty (and Your Shoes Comfy): The Splunk Experience

Hands-On Learning and Technical Seminars  Sometimes, you just need to see the code. For those looking for a ...