<?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 How do I change field names (extracted field name) to field values? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-change-field-names-extracted-field-name-to-field-values/m-p/469875#M192081</link>
    <description>&lt;P&gt;I have a json structure that contains an object map:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
  "correlation_id": "f9535d13-f75b-4dd7-8c39-1e77b1559afe",
  "targeting_data": [
    {
      "attribute_values": {
        "1013": "005",
        "2056": "07",
        "2057": "01",
        "2058": "03",
        "2060": "02",
        "2065": "01",
        "2075": "04",
        "2080": "03",
        "2081": "01",
        "DMA": "803",
        "RECTYPE": "HD",
        "RECVCNT": "6",
        "STATE": "CA",
        "SVCPKGTIER": "5"
      },
      "origin": null
    }
  ],
  "timestamp": "2020-06-02T00:02:09.257+00:00",
  "zone_target_area": "195"
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do i take the fields extracted as targeting_data{}.attribute_values.1013, targeting_data{}.attribute_values.2056 and output the field names (1013, 2056) as values. I would like for my output to be a list of the map's keys.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 05:36:23 GMT</pubDate>
    <dc:creator>vasugazula</dc:creator>
    <dc:date>2020-09-30T05:36:23Z</dc:date>
    <item>
      <title>How do I change field names (extracted field name) to field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-change-field-names-extracted-field-name-to-field-values/m-p/469875#M192081</link>
      <description>&lt;P&gt;I have a json structure that contains an object map:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{
  "correlation_id": "f9535d13-f75b-4dd7-8c39-1e77b1559afe",
  "targeting_data": [
    {
      "attribute_values": {
        "1013": "005",
        "2056": "07",
        "2057": "01",
        "2058": "03",
        "2060": "02",
        "2065": "01",
        "2075": "04",
        "2080": "03",
        "2081": "01",
        "DMA": "803",
        "RECTYPE": "HD",
        "RECVCNT": "6",
        "STATE": "CA",
        "SVCPKGTIER": "5"
      },
      "origin": null
    }
  ],
  "timestamp": "2020-06-02T00:02:09.257+00:00",
  "zone_target_area": "195"
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How do i take the fields extracted as targeting_data{}.attribute_values.1013, targeting_data{}.attribute_values.2056 and output the field names (1013, 2056) as values. I would like for my output to be a list of the map's keys.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:36:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-change-field-names-extracted-field-name-to-field-values/m-p/469875#M192081</guid>
      <dc:creator>vasugazula</dc:creator>
      <dc:date>2020-09-30T05:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change field names (extracted field name) to field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-change-field-names-extracted-field-name-to-field-values/m-p/469876#M192082</link>
      <description>&lt;P&gt;@vasugazula &lt;/P&gt;

&lt;P&gt;Can you please try this? You will have your values in &lt;CODE&gt;map_s_keys&lt;/CODE&gt; field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | eval map_s_keys="" 
| foreach targeting_data{}.attribute_values.*  [ eval map_s_keys=if(map_s_keys="","&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;",  map_s_keys.","."&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;") ] | table map_s_keys
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Sample Search:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval _raw="{\"correlation_id\": \"f9535d13-f75b-4dd7-8c39-1e77b1559afe\",\"targeting_data\": [{\"attribute_values\": {\"1013\": \"005\",\"2056\": \"07\",\"2057\": \"01\",\"2058\": \"03\",\"2060\": \"02\",\"2065\": \"01\",\"2075\": \"04\",\"2080\": \"03\",\"2081\": \"01\",\"DMA\": \"803\",\"RECTYPE\": \"HD\",\"RECVCNT\": \"6\",\"STATE\": \"CA\",\"SVCPKGTIER\": \"5\"},\"origin\": null}],\"timestamp\": \"2020-06-02T00:02:09.257+00:00\",\"zone_target_area\": \"195\"}" | extract | eval map_s_keys="" 
| foreach targeting_data{}.attribute_values.*  [ eval map_s_keys=if(map_s_keys="","&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;",  map_s_keys.","."&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;") ] | table map_s_keys
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 05:41:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-change-field-names-extracted-field-name-to-field-values/m-p/469876#M192082</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-06-02T05:41:53Z</dc:date>
    </item>
  </channel>
</rss>

