Getting Data In

Split Indexing from JSON

mtaylor78
Engager

So we have are pulling host logs on an EC2 instance and dropping them in an S3 Bucket. Our Splunk Heavy Forwarder is grabbing the logs and pushing them to Splunk Cloud. As we can easily pull the JSON log files into Splunk, there is one specific field inside the JSON document that we want to extract and push to another index.

{"message":"type=NETFILTER_CFG msg=audit(1491557469.510:18655): table=nat family=2 entries=146","@version":"1","@timestamp":"2017-04-07T09:31:09.880Z","path":"/systemlogs/audit/audit.log","host":"generichost","tags":["auditd"],"aws_region":"us-east-1","prod_status":"lalaland","aws_az":"us-east-1a","kluster_name":"klustername","kluster_prefix":"klust-pre","service_name":"audit","service_log":"audit"}

What I am trying to do is to extract only the "message" and ship it another index called aws_auditd

"message":"type=NETFILTER_CFG msg=audit(1491557469.510:18655): table=nat family=2 entries=146"

The regex that I have found for it is:

(\"message\":)\"([^\,}]*)\"

but I have no idea how to perform the function. Can someone advise me?

0 Karma

woodcock
Esteemed Legend

You need 2 pieces. First you need to strip out everything but the message field. Do that like this:

In props.conf on your HF:

[your sourcetype here]
SEDCMD-fix_message_prefix = s/^{\"message\":\"/message=/
SEDCMD-strip_non_message_suffix = s/\",\".*$//"
TRANSFORMS-set= setnull,setparsing

Then you need to conditionally keep only this part of the JSON stream; in transforms.conf on your HF:

[setnull]
REGEX = .
DEST_KEY = queue
FORMAT = nullQueue

[setparsing]
REGEX = ^message=
DEST_KEY = queue
FORMAT = indexQueue
0 Karma

somesoni2
Revered Legend

So want complete json to be in one index and just the message into another index? I don't believe there is an option at index time to send same event or portion of a single event to two indexes. My suggestion would to have the data fully ingested in one index and then setup a summary indexing search to filter only the relevant portion and index it to other index. Generally summary indexing is used for optimal searching/reporting but it's design helps in this kind of use-cases as well (save processed data to a different index). See below link for more details on summary indexing.
http://docs.splunk.com/Documentation/Splunk/6.5.2/Knowledge/Usesummaryindexing

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