<?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: extract field from json file in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684951#M233760</link>
    <description>&lt;P&gt;No, you can't (easily and efficiently) make such "dynamic" extraction.&lt;/P&gt;&lt;P&gt;Splunk is very good at dealing with key-value fields, but it doesn't have any notion of "structure" in data. It can parse out json or xml into flat key-value pairs in several ways (auto_kv, spath/xpath, indexed extractions) but all those methods have some drawbacks as the structure of the data is lost and is only partially retained in field naming.&lt;/P&gt;&lt;P&gt;So if you handle json/xml data it's often best idea (if you have the possibility of course) to influence the event-emiting side so that the events are easily parseable and can be processed in Splunk without much overhead.&lt;/P&gt;&lt;P&gt;Because your data (which you haven't posted a sample of - shame on you &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;) most probably contains something like&lt;/P&gt;&lt;PRE&gt;{&lt;BR /&gt;   [... some other part of json ...],&lt;BR /&gt;   "result": {&lt;BR /&gt;      "some_event_id": { [... event data... },&lt;BR /&gt;       "another_event_id": { [... event data ...] }&lt;BR /&gt;   } &lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;While it would be much better to have it as&lt;/P&gt;&lt;PRE&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; [...]&lt;BR /&gt;&amp;nbsp;&amp;nbsp; "result": {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "id": "first_id",&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [... result details ...]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "id": "another_id",&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [... result details ...]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;It would be much better because then you'd have a static easily accessible field called &lt;EM&gt;id&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Of course from Splunk's point of view if you managed to flatten the events even more (possibly splitting it into several separate ones) would be even better.&lt;/P&gt;&lt;P&gt;With this format you have, since it's not getting parsed as a multivalued field, since you don't have an array in your json but separate fields, it's gonna be tough. You might try some clever &lt;EM&gt;foreach&lt;/EM&gt; magic but I can't guarantee success here.&lt;/P&gt;&lt;P&gt;An example of such approach is here in the run-anywhere example:&lt;/P&gt;&lt;PRE&gt;| makeresults&lt;BR /&gt;| eval json="{\"result\":{\"1\":[{\"a\":\"n\"},{\"b\":\"m\"}],\"2\":[{\"a\":\"n\"},{\"b\":\"m\"}]}}"&lt;BR /&gt;| spath input=json&lt;BR /&gt;| foreach result.*{}.a&lt;BR /&gt;[ | eval results=mvappend(results,"&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;" . ":" . '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;') ]&lt;BR /&gt;| mvexpand results&lt;BR /&gt;| eval resultsexpanded=split(results,":")&lt;BR /&gt;| eval resultid=mvindex(resultsexpanded,0),resultvalue=mvindex(resultsexpanded,1)&lt;BR /&gt;| table resultid,resultvalue&lt;/PRE&gt;&lt;P&gt;But as you can see, it's nowhere pretty.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Apr 2024 07:47:58 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2024-04-22T07:47:58Z</dc:date>
    <item>
      <title>extract field from json file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684941#M233755</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;I have this query :&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="github_runners" sourcetype="testing" source="reports-tests"
| spath path=libraryPath output=library

| spath path=result.69991058{} output=testResult
| mvexpand testResult

| spath input=testResult path=fullName output=test_name
| spath input=testResult path=success output=test_outcome
| spath input=testResult path=skipped output=test_skipped
| spath input=testResult path=time output=test_time

| table library testResult test_name test_outcome test_skipped test_time

| eval status=if(test_outcome="true", "Passed", if(test_outcome="false", "Failed", if(test_skipped="true", "NotExecuted", "")))

| stats count sum(eval(if(status="Passed", 1, 0))) as passed_tests, sum(eval(if(status="Failed", 1, 0))) as failed_tests , sum(eval(if(status="NotExecuted", 1, 0))) as test_skipped by test_name library test_time
| eval total_tests = passed_tests + failed_tests
| eval success_ratio=round((passed_tests/total_tests)*100,2)
| table library, test_name, total_tests, passed_tests, failed_tests, test_skipped, success_ratio test_time
| sort + success_ratio&lt;/LI-CODE&gt;&lt;P&gt;And i'm trying to make its dynamic so i will see results for other numbers than '69991058'&lt;BR /&gt;How can i make it ?&lt;BR /&gt;i'm trying with regex but it looks like im doing something wrong since im getting 0 results while in the first query there are results&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="github_runners" sourcetype="testing" source="reports-tests"
| spath path=libraryPath output=library

| rex field=_raw "result\.(?&amp;lt;number&amp;gt;\d+)\{\}"

| spath path="result.number{}" output=testResult  
| mvexpand testResult

| spath input=testResult path=fullName output=test_name
| spath input=testResult path=success output=test_outcome
| spath input=testResult path=skipped output=test_skipped
| spath input=testResult path=time output=test_time

| table library testResult test_name test_outcome test_skipped test_time

| eval status=if(test_outcome="true", "Passed", if(test_outcome="false", "Failed", if(test_skipped="true", "NotExecuted", "")))

| stats count sum(eval(if(status="Passed", 1, 0))) as passed_tests, sum(eval(if(status="Failed", 1, 0))) as failed_tests , sum(eval(if(status="NotExecuted", 1, 0))) as test_skipped by test_name library test_time
| eval total_tests = passed_tests + failed_tests
| eval success_ratio=round((passed_tests/total_tests)*100,2)
| table library, test_name, total_tests, passed_tests, failed_tests, test_skipped, success_ratio test_time
| sort + success_ratio&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 22 Apr 2024 06:13:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684941#M233755</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2024-04-22T06:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from json file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684948#M233758</link>
      <description>&lt;P&gt;Can you guess what I am going to say?&lt;/P&gt;&lt;P&gt;Please share some anonymised representative sample events so we can see what you are dealing with, preferably in a code block &amp;lt;/&amp;gt; to prevent format information being lost&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 07:37:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684948#M233758</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-04-22T07:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from json file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684949#M233759</link>
      <description>&lt;LI-CODE lang="markup"&gt;   browsers: { [+]
   }
   coverageResult: { [+]
   }
   libraryPath: libs/funnels
   result: { [-]
     82348856: [ [+]
     ]
   }
   summary: { [+]
   }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 22 Apr 2024 07:39:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684949#M233759</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2024-04-22T07:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from json file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684951#M233760</link>
      <description>&lt;P&gt;No, you can't (easily and efficiently) make such "dynamic" extraction.&lt;/P&gt;&lt;P&gt;Splunk is very good at dealing with key-value fields, but it doesn't have any notion of "structure" in data. It can parse out json or xml into flat key-value pairs in several ways (auto_kv, spath/xpath, indexed extractions) but all those methods have some drawbacks as the structure of the data is lost and is only partially retained in field naming.&lt;/P&gt;&lt;P&gt;So if you handle json/xml data it's often best idea (if you have the possibility of course) to influence the event-emiting side so that the events are easily parseable and can be processed in Splunk without much overhead.&lt;/P&gt;&lt;P&gt;Because your data (which you haven't posted a sample of - shame on you &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;) most probably contains something like&lt;/P&gt;&lt;PRE&gt;{&lt;BR /&gt;   [... some other part of json ...],&lt;BR /&gt;   "result": {&lt;BR /&gt;      "some_event_id": { [... event data... },&lt;BR /&gt;       "another_event_id": { [... event data ...] }&lt;BR /&gt;   } &lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;While it would be much better to have it as&lt;/P&gt;&lt;PRE&gt;{&lt;BR /&gt;&amp;nbsp;&amp;nbsp; [...]&lt;BR /&gt;&amp;nbsp;&amp;nbsp; "result": {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "id": "first_id",&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [... result details ...]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "id": "another_id",&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [... result details ...]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;It would be much better because then you'd have a static easily accessible field called &lt;EM&gt;id&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Of course from Splunk's point of view if you managed to flatten the events even more (possibly splitting it into several separate ones) would be even better.&lt;/P&gt;&lt;P&gt;With this format you have, since it's not getting parsed as a multivalued field, since you don't have an array in your json but separate fields, it's gonna be tough. You might try some clever &lt;EM&gt;foreach&lt;/EM&gt; magic but I can't guarantee success here.&lt;/P&gt;&lt;P&gt;An example of such approach is here in the run-anywhere example:&lt;/P&gt;&lt;PRE&gt;| makeresults&lt;BR /&gt;| eval json="{\"result\":{\"1\":[{\"a\":\"n\"},{\"b\":\"m\"}],\"2\":[{\"a\":\"n\"},{\"b\":\"m\"}]}}"&lt;BR /&gt;| spath input=json&lt;BR /&gt;| foreach result.*{}.a&lt;BR /&gt;[ | eval results=mvappend(results,"&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;" . ":" . '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;') ]&lt;BR /&gt;| mvexpand results&lt;BR /&gt;| eval resultsexpanded=split(results,":")&lt;BR /&gt;| eval resultid=mvindex(resultsexpanded,0),resultvalue=mvindex(resultsexpanded,1)&lt;BR /&gt;| table resultid,resultvalue&lt;/PRE&gt;&lt;P&gt;But as you can see, it's nowhere pretty.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 07:47:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684951#M233760</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-04-22T07:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from json file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684954#M233761</link>
      <description>&lt;P&gt;this is the output of the query :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sarit_s_0-1713772345417.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/30519i8B72ADE6A064BF93/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sarit_s_0-1713772345417.png" alt="sarit_s_0-1713772345417.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;also, example of my event :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;   browsers: { [+]
   }
   coverageResult: { [+]
   }
   libraryPath: libs/funnels
   result: { [-]
     82348856: [ [+]
     ]
   }
   summary: { [+]
   }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 22 Apr 2024 07:52:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684954#M233761</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2024-04-22T07:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from json file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684957#M233762</link>
      <description>&lt;P&gt;This is not valid JSON, it is a formatted version of the JSON. Perhaps I wasn't specific enough.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please share some anonymised representative sample &lt;U&gt;&lt;STRONG&gt;raw&lt;/STRONG&gt;&lt;/U&gt; events so we can see what you are dealing with, preferably in a code block &amp;lt;/&amp;gt; to prevent format information being lost.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example, we would want to be able to use the events in a runanywhere / makeresults style search, much like&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;demonstrated&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 08:00:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684957#M233762</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-04-22T08:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from json file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684958#M233763</link>
      <description>&lt;P&gt;If you are 100% sure that you only have one result, and always will have just one result, you could try to brute-force it and:&lt;/P&gt;&lt;P&gt;1) spath the whole result field&lt;/P&gt;&lt;P&gt;2) Extract the result's ID with regex&lt;/P&gt;&lt;P&gt;3) cut the id part from the result field&lt;/P&gt;&lt;P&gt;4) spath the remaining array&lt;/P&gt;&lt;P&gt;Might work, might not (especially that if the rest of the data is similarily (dis)organized, you're gonna have more dynamically named fields deeper down), definitely won't be pretty as manipulating structured data with regexes is prone to errors.&lt;/P&gt;&lt;P&gt;BTW, I don't understand how you got so many results from my example.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 08:05:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/684958#M233763</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-04-22T08:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from json file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/685238#M233814</link>
      <description>&lt;P&gt;it's too long to paste it here &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 05:07:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/685238#M233814</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2024-04-24T05:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from json file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/685262#M233828</link>
      <description>&lt;P&gt;Try cutting it down so that it remains valid and representative and then paste it here.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Apr 2024 07:54:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/685262#M233828</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-04-24T07:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from json file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/685320#M233838</link>
      <description>&lt;P&gt;this is an example to make results :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=json data="[{\"browsers\":{\"0123456\":{\"id\":\"0123456\",\"fullName\":\"blahblah\",\"name\":\"blahblah\",\"state\":0,\"lastResult\":{\"success\":1,\"failed\":2,\"skipped\":3,\"total\":4,\"totalTime\":5,\"netTime\":6,\"error\":true,\"disconnected\":true},\"launchId\":7}},\"result\":{\"0123456\":[{\"id\":8,\"description\":\"blahblah\",\"suite\":[\"blahblah\",\"blahblah\"],\"fullName\":\"blahblah\",\"success\":true,\"skipped\":true,\"time\":9,\"log\":[\"blahblah\",\"blahblah\"]}]},\"summary\":{\"success\":10,\"failed\":11,\"error\":true,\"disconnected\":true,\"exitCode\":12}}]"&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 24 Apr 2024 13:22:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/685320#M233838</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2024-04-24T13:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: extract field from json file</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/685390#M233861</link>
      <description>&lt;P&gt;Thank you for posting mock data emulation. &amp;nbsp;Obviously the app developers do not implement self-evident semantics and should be cursed. (Not just for Splunk's sake, but for every other developer's sanity.) &amp;nbsp;If you have any influence on developers, demand that they change JSON structure to something like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
    "browser_id": "0123456",
    "browsers": {
            "fullName": "blahblah",
            "name": "blahblah",
            "state": 0,
            "lastResult": {
                "success": 1,
                "failed": 2,
                "skipped": 3,
                "total": 4,
                "totalTime": 5,
                "netTime": 6,
                "error": true,
                "disconnected": true
            },
            "launchId": 7
    },
    "result": [
            {
                "id": 8,
                "description": "blahblah",
                "suite": [
                    "blahblah",
                    "blahblah"
                ],
                "fullName": "blahblah",
                "success": true,
                "skipped": true,
                "time": 9,
                "log": [
                    "blahblah",
                    "blahblah"
                ]
            }
    ],
    "summary": {
        "success": 10,
        "failed": 11,
        "error": true,
        "disconnected": true,
        "exitCode": 12
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That is, isolate the browser_id field into a unique key for browser, results, and summary. &amp;nbsp;The structure you shared cannot express any more semantic browser_id than one. &amp;nbsp;But if for some bizarre reason the browser_id needs to be passed along in results because summary is not associated with browser_id in each event, expressly say so with JSON key, like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
    "browsers": {
            "id": "0123456",
            "fullName": "blahblah",
            "name": "blahblah",
            "state": 0,
            "lastResult": {
                "success": 1,
                "failed": 2,
                "skipped": 3,
                "total": 4,
                "totalTime": 5,
                "netTime": 6,
                "error": true,
                "disconnected": true
            },
            "launchId": 7
    },
    "result": {
        "id": "0123456",
        "output": [
            {
                "id": 8,
                "description": "blahblah",
                "suite": [
                    "blahblah",
                    "blahblah"
                ],
                "fullName": "blahblah",
                "success": true,
                "skipped": true,
                "time": 9,
                "log": [
                    "blahblah",
                    "blahblah"
                ]
            }
        ]
    },
    "summary": {
        "success": 10,
        "failed": 11,
        "error": true,
        "disconnected": true,
        "exitCode": 12
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Embedding data in JSON key is the worst use of JSON - or any structured data. (I mean, I recently lamented worse offenders, but imaging embedding data in column name in SQL! &amp;nbsp;The developer will be cursed by the entire world.)&lt;/P&gt;&lt;P&gt;This said, if your developer has a gun over your head, or they are from a third party that you have no control over, you can &lt;STRONG&gt;SAN&lt;/STRONG&gt;itize their data, i.e., making the structure saner using SPL. &amp;nbsp;But remember: A bad structure is bad not because a programming language has difficulty. &amp;nbsp;A bad structure is bad because downstream developers cannot determine the actual semantics without reading their original manual. &amp;nbsp;Do you have their manual to understand what each structure means? &amp;nbsp;If not, you are very likely to misrepresent their intention, therefore get the wrong result.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;STRONG&gt;Caveat&lt;/STRONG&gt;: As we are speaking semantics, I want to point out that your illustration uses the plural "browser&lt;U&gt;&lt;STRONG&gt;s&lt;/STRONG&gt;&lt;/U&gt;" as key name as well as singular "result" as another key name, yet the value of (plural) "browsers" is not an array, while the value of (singular) "result" &lt;STRONG&gt;is&lt;/STRONG&gt; an array. &amp;nbsp;If this is not the true structure, you have changed semantics your developers intended. &amp;nbsp;The following may lead to wrong output.&lt;/P&gt;&lt;P&gt;Secondly, your illustrated data has level 1 key of "0123456" in browsers, an identical level 1 key of "0123456" in result, a matching level 2 id in browsers "0123456", a different level 2 id in result "8". &amp;nbsp;I assume that all matching numbers are semantically identical and non-matching numbers are semantically different&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Here, I will give you SPL to interpret their intention as my first illustration, i.e., a single browser_id applies to the entire event. &amp;nbsp;I will assume that you have Splunk 9 or above so &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Fromjson" target="_blank" rel="noopener"&gt;fromjson&lt;/A&gt; works. (This can be solved using spath with a slightly more cumbersome quotation manipulation.)&lt;/P&gt;&lt;P&gt;Here is the code to detangle the semantic madness. &amp;nbsp;This code does not &lt;EM&gt;require&lt;/EM&gt; the first line, &lt;FONT face="courier new,courier"&gt;fields _raw&lt;/FONT&gt;. &amp;nbsp;But doing so can help eliminate distractions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fields _raw ``` to eliminate unusable fields from bad structure ```
| fromjson _raw
| eval browser_id = json_keys(browsers), result_id = json_keys(result)
| eval EVERYTHING_BAD = if(browser_id != result_id OR mvcount(browser_id) &amp;gt; 1, "baaaaad", null())
| foreach browser_id mode=json_array
    [eval browsers = json_delete(json_extract(browsers, &amp;lt;&amp;lt;ITEM&amp;gt;&amp;gt;), "id"),
    result = json_extract(result, &amp;lt;&amp;lt;ITEM&amp;gt;&amp;gt;)]
| spath input=browsers
| spath input=result path={} output=result
| mvexpand result
| spath input=result
| spath input=summary
| fields - -* result_id browsers result summary&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is &amp;nbsp;the output based on your mock data; to illustrate result[] array, I added one more mock element.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;browser_id&lt;/TD&gt;&lt;TD&gt;description&lt;/TD&gt;&lt;TD&gt;disconnected&lt;/TD&gt;&lt;TD&gt;error&lt;/TD&gt;&lt;TD&gt;exitCode&lt;/TD&gt;&lt;TD&gt;failed&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;fullName&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;lastResult.disconnected&lt;/TD&gt;&lt;TD&gt;lastResult.error&lt;/TD&gt;&lt;TD&gt;lastResult.failed&lt;/TD&gt;&lt;TD&gt;lastResult.netTime&lt;/TD&gt;&lt;TD&gt;lastResult.skipped&lt;/TD&gt;&lt;TD&gt;lastResult.success&lt;/TD&gt;&lt;TD&gt;lastResult.total&lt;/TD&gt;&lt;TD&gt;lastResult.totalTime&lt;/TD&gt;&lt;TD&gt;launchId&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;log{}&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;name&lt;/TD&gt;&lt;TD&gt;skipped&lt;/TD&gt;&lt;TD&gt;stats&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;success&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;suite{}&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;time&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;["0123456"]&lt;/TD&gt;&lt;TD&gt;blahblah&lt;/TD&gt;&lt;TD&gt;true&lt;/TD&gt;&lt;TD&gt;true&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;blahblah&lt;/DIV&gt;&lt;DIV class=""&gt;blahblah&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;true&lt;/TD&gt;&lt;TD&gt;true&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;blahblah&lt;/DIV&gt;&lt;DIV class=""&gt;blahblah&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;blahblah&lt;/TD&gt;&lt;TD&gt;true&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;true&lt;/DIV&gt;&lt;DIV class=""&gt;10&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;blahblah&lt;/DIV&gt;&lt;DIV class=""&gt;blahblah&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;["0123456"]&lt;/TD&gt;&lt;TD&gt;blahblah 9&lt;/TD&gt;&lt;TD&gt;true&lt;/TD&gt;&lt;TD&gt;true&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;blahblah&lt;/DIV&gt;&lt;DIV class=""&gt;blahblah9&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;true&lt;/TD&gt;&lt;TD&gt;true&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;blahblah 9a&lt;/DIV&gt;&lt;DIV class=""&gt;blahblah 9b&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;blahblah&lt;/TD&gt;&lt;TD&gt;true&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;true&lt;/DIV&gt;&lt;DIV class=""&gt;10&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;blahblah9a&lt;/DIV&gt;&lt;DIV class=""&gt;blahblah9b&lt;/DIV&gt;&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;In the table, "id" is from results[].&lt;/P&gt;&lt;P&gt;This is the emulation of expanded mock data. &amp;nbsp;Here, I decided to not use format=json because this will preserve the pretty print format, also because Splunk will not show fromjson-style fields automatically. (With real data, fromjson-style fields are not used in 9.x.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw ="
{
    \"browsers\": {
        \"0123456\": {
            \"id\": \"0123456\",
            \"fullName\": \"blahblah\",
            \"name\": \"blahblah\",
            \"state\": 0,
            \"lastResult\": {
                \"success\": 1,
                \"failed\": 2,
                \"skipped\": 3,
                \"total\": 4,
                \"totalTime\": 5,
                \"netTime\": 6,
                \"error\": true,
                \"disconnected\": true
            },
            \"launchId\": 7
        }
    },
    \"result\": {
        \"0123456\": [
            {
                \"id\": 8,
                \"description\": \"blahblah\",
                \"suite\": [
                    \"blahblah\",
                    \"blahblah\"
                ],
                \"fullName\": \"blahblah\",
                \"success\": true,
                \"skipped\": true,
                \"time\": 9,
                \"log\": [
                    \"blahblah\",
                    \"blahblah\"
                ]
            },
            {
                \"id\": 9,
                \"description\": \"blahblah 9\",
                \"suite\": [
                    \"blahblah9a\",
                    \"blahblah9b\"
                ],
                \"fullName\": \"blahblah9\",
                \"success\": true,
                \"skipped\": true,
                \"time\": 11,
                \"log\": [
                    \"blahblah 9a\",
                    \"blahblah 9b\"
                ]
            }

        ]
    },
    \"summary\": {
        \"success\": 10,
        \"failed\": 11,
        \"error\": true,
        \"disconnected\": true,
        \"exitCode\": 12
    }
}
"
| spath
``` the above partially emulates
index="github_runners" sourcetype="testing" source="reports-tests"
```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2024 06:01:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-field-from-json-file/m-p/685390#M233861</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-04-25T06:01:29Z</dc:date>
    </item>
  </channel>
</rss>

