Getting Data In

Remove { } from json file before indexing

abilis
Explorer

HI,

i am trying to index a local json file, but when going trough the sourcetype the predefined json source type is not reading the file properly..splunk put everything in one line...no detecting time format or something (see attached file)

then i found that splunk is not indexing separate events because the json file starts with { and ends with } if i removed those character splunk will give me a line per event.

does someone knows how I can remove the { at the beginning and the } at the end with splunk before indexing?

i'm putting this when i go through wizard data inpout local file in the advance section

SEDCMD-removesymbol = s/^{/g (this is not working)

thanks
{
"records":
[

     {
         "time": "2018-05-11T13:29:03Z",        
          "GatewayId": "4r566-5678-4753-968f-34568",
          "Region": "unknown",
           "operationName": "ApplicationGatewayAccess",
           "category": "ApplicationGatewayAccessLog",
         }
     ,

{
"time": "2018-05-11T13:29:05Z",

"GatewayId": "4r566-ae57-dfg543-968f-xxx45t67",
"Region": "unknown",
"operationName": "ApplicationGatewayAccess",
"category": "ApplicationGatewayAccessLog",
}
}

can someone please help me ?

thanks

0 Karma

abilis
Explorer

I've being working in this issue for two days and still don't undestand what the SEDCMD-class = s/^{//g is NOT removing the starting" { " during the data preview. if i dont remove the starting " { " from the .json file i'm trying to index, splunk will put all the events in 1 line

i have tried many combinations but still not working..data preview always show all event in one line,
SEDCMD-class =s/^{//g
SEDCMD-class =s/^{//
SEDCMD-class =s/{//g
SEDCMD-class =s/{/

when removing manually the starting " { ", splunk is able to display 1 event per record in the .json file...all my .json files start with " { " and this is how Microsoft format it...don't know why

can someone help me to figure this out ???

{
"records":
[

          {
              "time": "2018-05-11T13:29:03Z",        
               "GatewayId": "4r566-5678-4753-968f-34568",
               "Region": "unknown",
                "operationName": "ApplicationGatewayAccess",
                "category": "ApplicationGatewayAccessLog",
              }
          ,

{
"time": "2018-05-11T13:29:05Z",
"GatewayId": "4r566-ae57-dfg543-968f-xxx45t67",
"Region": "unknown",
"operationName": "ApplicationGatewayAccess",
"category": "ApplicationGatewayAccessLog",
}
}
0 Karma

xpac
SplunkTrust
SplunkTrust

Hey,

you're only missing a single char: s/^{//g 😉

Hope that helps - if it does I'd be happy if you would upvote/accept this answer, so others could profit from it. 🙂

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!

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...

SplunkTrust Application Period is Officially OPEN!

It's that time, folks! The application/nomination period for the 2026-2027 SplunkTrust is officially open. If ...