Getting Data In

Parsing Multimetric Logs

grexo94
Engager

Hi all,I am trying to parse multiple nested Multimetric logs as metrics and am failing.The following source type works when I read logs individually, e.g.


{"event":"metric","metric_name:my_metric_1":2,"metric_name:my_metric_2":2.1}

 

or pretty printed:


{
      "event": "metric",
      "metric_name:my_metric_1": 2.0,
      "metric_name:my_metric_2": 2.1
    }[json_metrics_singleevent]
SHOULD_LINEMERGE = false
INDEXED_EXTRACTIONS = JSON
KV_MODE = none

____________________________________________________________________________
in reality, logs look like this:
{"data":[{"event":"metric","metric_name:my_metric_1":0,"metric_name:my_metric_2":0.1},{"event":"metric","metric_name:my_metric_1":1,"metric_name:my_metric_2":1.1},{"event":"metric","metric_name:my_metric_1":2,"metric_name:my_metric_2":2.1}]}or pretty printed:{
  "data": [
    {
      "event": "metric",
      "metric_name:my_metric_1": 0.0,
      "metric_name:my_metric_2": 0.1
    },
    {
      "event": "metric",
      "metric_name:my_metric_1": 1.0,
      "metric_name:my_metric_2": 1.1
    },
    {
      "event": "metric",
      "metric_name:my_metric_1": 2.0,
      "metric_name:my_metric_2": 2.1
    }
  ]
}

 

Sourcetype:

[json_metrics_multievents]
SHOULD_LINEMERGE = false
INDEXED_EXTRACTIONS = JSON
LINE_BREAKER = (\{\"data\"\:\[)|(\,)\{"event|(\]\})

 

--> doesn't work. I am getting the response, the logs are not properly structured.Can someone help please?

Labels (1)
0 Karma
1 Solution

VatsalJagani
SplunkTrust
SplunkTrust

@grexo94 - Basically, I think the problem you have is with JSON List. There are two approaches that I could think of from which you can start:

 

I hope this helps!!! 

View solution in original post

VatsalJagani
SplunkTrust
SplunkTrust

@grexo94 - Basically, I think the problem you have is with JSON List. There are two approaches that I could think of from which you can start:

 

I hope this helps!!! 

grexo94
Engager

thank you, yes, these will be my plan b & c's.

 

I was wondering why i simply cannot use a linebreaker the way i am used to for event-indexing, but i simply accept that for logs that i want to index as metrics

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!

Keep the Learning Going with the New Best of .conf Hub

Hello Splunkers, With .conf26 getting closer, there’s already a lot of excitement building around this year’s ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

How to find the worst searches in your Splunk environment and how to fix them

Everyone knows Splunk is a powerful platform for running searches and doing data analytics. Your ...