<?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 fields from JSON response in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-JSON-response/m-p/661074#M228243</link>
    <description>&lt;P&gt;you are correct, some of the fields are automatically extracted as part of the &lt;STRONG&gt;Event&lt;/STRONG&gt; heading, but none of the fields I am interested in are available, such as:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;tracePoint&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;content&lt;/STRONG&gt;.&lt;STRONG&gt;attributes&lt;/STRONG&gt;[]&amp;nbsp; //not interested in the&amp;nbsp;&lt;STRONG&gt;headers&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;applicationName&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;applicationVersion&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;environmen&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;By the way, I tried what you suggested:&lt;/P&gt;&lt;PRE&gt;| spath input=data&lt;/PRE&gt;&lt;P&gt;but I see no change in my search results.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Oct 2023 17:42:45 GMT</pubDate>
    <dc:creator>Naji</dc:creator>
    <dc:date>2023-10-17T17:42:45Z</dc:date>
    <item>
      <title>Extract fields from JSON response</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-JSON-response/m-p/661055#M228234</link>
      <description>&lt;P&gt;I am new to &lt;STRONG&gt;Splunk&lt;/STRONG&gt; and I have the following message which I would like to parse into a table of columns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{dt.trace_id=837045e132ad49311fde0e1ac6a6c18b, dt.span_id=169aa205dab448fc, dt.trace_sampled=true}
{
	"correlationId": "3-f0d89f31-6c3c-11ee-8502-123c53e78683",
	"message": "API Request",
	"tracePoint": "START",
	"priority": "INFO",
	"category": "com.cfl.api.service",
	"elapsed": 0,
	"timestamp": "2023-10-16T15:59:09.051Z",
	"content": {
		"clientId": "",
		"attributes": {
			"headers": {
				"accept-encoding": "gzip,deflate",
				"content-type": "application/json",
				"content-length": "92",
				"host": "hr-fin.svr.com",
				"connection": "Keep-Alive",
				"user-agent": "Apache-HttpClient/4.5.5 (Java/16.0.2)"
			},
			"clientCertificate": null,
			"method": "POST",
			"scheme": "https",
			"queryParams": {},
			"requestUri": "/cfl-service-api/api/process",
			"queryString": "",
			"version": "HTTP/1.1",
			"maskedRequestPath": "/api/queue/send",
			"listenerPath": "/cfl-service-api/api/*",
			"localAddress": "/localhost:8082",
			"relativePath": "/cfl-service-api/api/process",
			"uriParams": {},
			"rawRequestUri": "/cfl-service-api/api/process",
			"rawRequestPath": "/cfl-service-api/api/process",
			"remoteAddress": "/123.123.123.123:123",
			"requestPath": "/cfl-service-api/api/process"
		}
	},
	"applicationName": "cfl-service-api",
	"applicationVersion": "6132",
	"environment": "dev",
	"threadName": "[cfl-service-api].proxy.BLOCKING @78f55ba"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 17:18:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-JSON-response/m-p/661055#M228234</guid>
      <dc:creator>Naji</dc:creator>
      <dc:date>2023-10-17T17:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from JSON response</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-JSON-response/m-p/661066#M228238</link>
      <description>&lt;P&gt;Have you tried "| table *"? &amp;nbsp;In other words, is that message the raw events? &amp;nbsp;Because if it is, Splunk would have already given you all the fields like correlationId, message, content.clientId, content.attributes.reasonPhrase, and so on.&lt;/P&gt;&lt;P&gt;If the message is in a field named "data", you can use &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath" target="_blank" rel="noopener"&gt;spath&lt;/A&gt; to extract it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath input=data&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Either way, your sample would give these fields and values&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;fieldname&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;fieldvalue&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;applicationName&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;cfl-service-integration-proxy&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;applicationVersion&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;61808&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;category&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;com.cfl.api.service-integration&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;content.attributes.reasonPhrase&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;OK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;content.attributes.statusCode&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;content.clientId&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;1234567&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;correlationId&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;3-f86043c0-6c3c-11ee-8502-123c53e78683&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;elapsed&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;435&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;environment&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;dev&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;message&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;API Response&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;priority&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;INFO&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;threadName&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;[cfl-service-integration-proxy].proxy.BLOCKING @78f55ba&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;timestamp&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;2023-9-16T15:59:22.083Z&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="243.890625px" height="25px"&gt;tracePoint&lt;/TD&gt;&lt;TD width="432.6875px" height="25px"&gt;END&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 17:18:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-JSON-response/m-p/661066#M228238</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-10-17T17:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from JSON response</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-JSON-response/m-p/661074#M228243</link>
      <description>&lt;P&gt;you are correct, some of the fields are automatically extracted as part of the &lt;STRONG&gt;Event&lt;/STRONG&gt; heading, but none of the fields I am interested in are available, such as:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;tracePoint&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;content&lt;/STRONG&gt;.&lt;STRONG&gt;attributes&lt;/STRONG&gt;[]&amp;nbsp; //not interested in the&amp;nbsp;&lt;STRONG&gt;headers&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;applicationName&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;applicationVersion&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;environmen&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;By the way, I tried what you suggested:&lt;/P&gt;&lt;PRE&gt;| spath input=data&lt;/PRE&gt;&lt;P&gt;but I see no change in my search results.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 17:42:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-JSON-response/m-p/661074#M228243</guid>
      <dc:creator>Naji</dc:creator>
      <dc:date>2023-10-17T17:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from JSON response</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-JSON-response/m-p/661125#M228252</link>
      <description>&lt;P&gt;Do you mean to say that a string like "{dt.trace_id=837045e132ad49311fde0e1ac6a6c18b, dt.span_id=169aa205dab448fc, dt.trace_sampled=true}" is at the beginning of raw event? &amp;nbsp;If so, you will need to first extract the part with compliant JSON. (It is also a very bad log pattern from your developer.)&lt;/P&gt;&lt;P&gt;You can do so with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval json = replace(_raw, "^{.+}", "")&lt;/LI-CODE&gt;&lt;P&gt;(Actual method will depend on how raw logs are structure, how stable such a structure is, etc.) &amp;nbsp;Then, apply spath.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval json = replace(_raw, "^{.+}", "")​
| spath input=json&lt;/LI-CODE&gt;&lt;P&gt;Alternatively, get rid of the spurious part from _raw then spath.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex mode=sed "s/^{.+}//"
| spath&lt;/LI-CODE&gt;&lt;P&gt;Here is an emulation you can play with and compare with real data&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval _raw = "{dt.trace_id=837045e132ad49311fde0e1ac6a6c18b, dt.span_id=169aa205dab448fc, dt.trace_sampled=true}
{
	\"correlationId\": \"3-f0d89f31-6c3c-11ee-8502-123c53e78683\",
	\"message\": \"API Request\",
	\"tracePoint\": \"START\",
	\"priority\": \"INFO\",
	\"category\": \"com.cfl.api.service\",
	\"elapsed\": 0,
	\"timestamp\": \"2023-10-16T15:59:09.051Z\",
	\"content\": {
		\"clientId\": \"\",
		\"attributes\": {
			\"headers\": {
				\"accept-encoding\": \"gzip,deflate\",
				\"content-type\": \"application/json\",
				\"content-length\": \"92\",
				\"host\": \"hr-fin.svr.com\",
				\"connection\": \"Keep-Alive\",
				\"user-agent\": \"Apache-HttpClient/4.5.5 (Java/16.0.2)\"
			},
			\"clientCertificate\": null,
			\"method\": \"POST\",
			\"scheme\": \"https\",
			\"queryParams\": {},
			\"requestUri\": \"/cfl-service-api/api/process\",
			\"queryString\": \"\",
			\"version\": \"HTTP/1.1\",
			\"maskedRequestPath\": \"/api/queue/send\",
			\"listenerPath\": \"/cfl-service-api/api/*\",
			\"localAddress\": \"/localhost:8082\",
			\"relativePath\": \"/cfl-service-api/api/process\",
			\"uriParams\": {},
			\"rawRequestUri\": \"/cfl-service-api/api/process\",
			\"rawRequestPath\": \"/cfl-service-api/api/process\",
			\"remoteAddress\": \"/123.123.123.123:123\",
			\"requestPath\": \"/cfl-service-api/api/process\"
		}
	},
	\"applicationName\": \"cfl-service-api\",
	\"applicationVersion\": \"6132\",
	\"environment\": \"dev\",
	\"threadName\": \"[cfl-service-api].proxy.BLOCKING @78f55ba\"
}"
``` data emulation above ```&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 18 Oct 2023 01:18:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-JSON-response/m-p/661125#M228252</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-10-18T01:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: Extract fields from JSON response</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-JSON-response/m-p/665795#M228437</link>
      <description>&lt;P&gt;I tried what you suggested, but I was unable to get the results I expected. To resolve the issue, I had to disable Java log enrichment feature in Dynatrace OneAgent to stop OneAgent from injecting&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{dt.trace_id=837045e132ad49311fde0e1ac6a6c18b, dt.span_id=169aa205dab448fc, dt.trace_sampled=true}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;into my logs. Now things are back to normal.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Oct 2023 03:30:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-fields-from-JSON-response/m-p/665795#M228437</guid>
      <dc:creator>Naji</dc:creator>
      <dc:date>2023-10-23T03:30:29Z</dc:date>
    </item>
  </channel>
</rss>

