<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How do I rename unknown field name in a JSON file? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-rename-unknown-field-name-in-a-JSON-file/m-p/444481#M77372</link>
    <description>&lt;P&gt;Hi @sebastianstruwe&lt;/P&gt;

&lt;P&gt;Did the answer below solve your problem? If so, please resolve this post by approving it! If your problem is still not solved, keep us updated so that someone else can help ya. Thanks for posting!&lt;/P&gt;</description>
    <pubDate>Wed, 24 Oct 2018 22:16:37 GMT</pubDate>
    <dc:creator>mstjohn_splunk</dc:creator>
    <dc:date>2018-10-24T22:16:37Z</dc:date>
    <item>
      <title>How do I rename unknown field name in a JSON file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-rename-unknown-field-name-in-a-JSON-file/m-p/444479#M77370</link>
      <description>&lt;P&gt;Hi Splunker,&lt;/P&gt;

&lt;P&gt;I want to rename an unknown field name from a JSON file. Please find the minimal example below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"timestamp": "2018-10-24T08:46:02.205664", 
"type": "sw", 
"serial": {"Switchah3nv": "000123456789"}, 
"system_time": "Wed Oct 24 08:46:04 CEST 2018", 
.....
}

{"timestamp": "2018-10-24T08:47:02.205664", 
"type": "fw", 
"serial": {"Switchcklaie7": "000987654321"}, 
"system_time": "Wed Oct 24 08:47:04 CEST 2018", 
.....
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm trying to make a table for all the serial numbers. So something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;hostname      | serial_number
Switchah3nv  |000123456789
Switchcklaie7 |000987654321
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm able to rename one serial by using &lt;CODE&gt;| rename serial.Switchah3nv AS serial_number&lt;/CODE&gt; , but I need something like &lt;CODE&gt;| rename serial.{} AS serial_number&lt;/CODE&gt; or  &lt;CODE&gt;| rename serial.hostname AS serial_number&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;So anyone got an idea?&lt;/P&gt;

&lt;P&gt;Best regards,&lt;/P&gt;

&lt;P&gt;Sebastian&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 13:47:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-rename-unknown-field-name-in-a-JSON-file/m-p/444479#M77370</guid>
      <dc:creator>sebastianstruwe</dc:creator>
      <dc:date>2018-10-24T13:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I rename unknown field name in a JSON file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-rename-unknown-field-name-in-a-JSON-file/m-p/444480#M77371</link>
      <description>&lt;P&gt;Something like the following should work for you (this is a run-anywhere search that you can copy/paste into your Splunk search bar and it will run):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval data="{\"timestamp\": \"2018-10-24T08:46:02.205664\", 
 \"type\": \"sw\", 
 \"serial\": {\"Switchah3nv\": \"000123456789\"}, 
 \"system_time\": \"Wed Oct 24 08:46:04 CEST 2018\",}"
| rex field=data "\"serial\": \{\"(?&amp;lt;hostname&amp;gt;[^\"]*)\": \"(?&amp;lt;serial_number&amp;gt;[^\"]*)\""
| table hostname, serial_number
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The &lt;CODE&gt;rex&lt;/CODE&gt; line is probably the only line (with the exception of the &lt;CODE&gt;table&lt;/CODE&gt; line) that you really need to worry about, but it shows what you can do with the search to get the data that you want. The &lt;CODE&gt;field=data&lt;/CODE&gt; part of the &lt;CODE&gt;rex&lt;/CODE&gt; line will probably have to be changed to match your data.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:13:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-rename-unknown-field-name-in-a-JSON-file/m-p/444480#M77371</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2018-10-24T14:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I rename unknown field name in a JSON file?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-rename-unknown-field-name-in-a-JSON-file/m-p/444481#M77372</link>
      <description>&lt;P&gt;Hi @sebastianstruwe&lt;/P&gt;

&lt;P&gt;Did the answer below solve your problem? If so, please resolve this post by approving it! If your problem is still not solved, keep us updated so that someone else can help ya. Thanks for posting!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 22:16:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-rename-unknown-field-name-in-a-JSON-file/m-p/444481#M77372</guid>
      <dc:creator>mstjohn_splunk</dc:creator>
      <dc:date>2018-10-24T22:16:37Z</dc:date>
    </item>
  </channel>
</rss>

