<?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 splunk query with substring not working in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/splunk-query-with-substring-not-working/m-p/695685#M236525</link>
    <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;I have written the splunk query to remove last 2 character from the string:&lt;/P&gt;&lt;P&gt;processingDuration = &lt;STRONG&gt;102ms&lt;/STRONG&gt;&amp;nbsp; as &lt;STRONG&gt;102&lt;/STRONG&gt; for the following log:&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;{
	"timestamp": "2029-02-29 07:32:54.734",
	"level": "INFO",
	"thread": "54dd544ff",
	"logger": "my.logger",
	"message": {
		"logTimeStamp": "2029-02-29T07:32:54.734494726Z",
		"logType": "RESP",
		"statusCode": 200,
		"processingDuration": "102ms",
		"headers": {
			"Content-Type": [
				"application/json"
			]
		},
		"tracers": {
			"correlation-id": [
				"hfkjhwkj98342"
			],
			"request-id": [
				"53456345"
			],
			"service-trace-id": [
				"34234623456"
			]
		}
	},
	"context": "hello-service"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my splunk query:&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;index=my_index    
| spath logger | search logger="my.logger" 
| spath "message.logType" | search "message.logType"=RESP 
| spath "message.tracers.correlation-id{}" | search "message.tracers.correlation-id{}"="hfkjhwkj98342" 
| eval myprocessTime = substr("message.processingDuration", 1, len("message.processingDuration")-2)
| table "message.tracers.correlation-id{}" myprocessTime&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the above query considers &lt;STRONG&gt;"message.processingDuration"&lt;/STRONG&gt; as string itself and removes last 2 characters out of it.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="super_edition_1-1723117654225.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/32110iB6DC2F52AD1035BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="super_edition_1-1723117654225.png" alt="super_edition_1-1723117654225.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I tried without double quotes also, it returned empty:&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;substr(message.processingDuration, 1, len(message.processingDuration)-2)&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;Appreciate your help on this.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Aug 2024 11:55:54 GMT</pubDate>
    <dc:creator>super_edition</dc:creator>
    <dc:date>2024-08-08T11:55:54Z</dc:date>
    <item>
      <title>splunk query with substring not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/splunk-query-with-substring-not-working/m-p/695685#M236525</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;I have written the splunk query to remove last 2 character from the string:&lt;/P&gt;&lt;P&gt;processingDuration = &lt;STRONG&gt;102ms&lt;/STRONG&gt;&amp;nbsp; as &lt;STRONG&gt;102&lt;/STRONG&gt; for the following log:&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;{
	"timestamp": "2029-02-29 07:32:54.734",
	"level": "INFO",
	"thread": "54dd544ff",
	"logger": "my.logger",
	"message": {
		"logTimeStamp": "2029-02-29T07:32:54.734494726Z",
		"logType": "RESP",
		"statusCode": 200,
		"processingDuration": "102ms",
		"headers": {
			"Content-Type": [
				"application/json"
			]
		},
		"tracers": {
			"correlation-id": [
				"hfkjhwkj98342"
			],
			"request-id": [
				"53456345"
			],
			"service-trace-id": [
				"34234623456"
			]
		}
	},
	"context": "hello-service"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my splunk query:&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;index=my_index    
| spath logger | search logger="my.logger" 
| spath "message.logType" | search "message.logType"=RESP 
| spath "message.tracers.correlation-id{}" | search "message.tracers.correlation-id{}"="hfkjhwkj98342" 
| eval myprocessTime = substr("message.processingDuration", 1, len("message.processingDuration")-2)
| table "message.tracers.correlation-id{}" myprocessTime&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the above query considers &lt;STRONG&gt;"message.processingDuration"&lt;/STRONG&gt; as string itself and removes last 2 characters out of it.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="super_edition_1-1723117654225.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/32110iB6DC2F52AD1035BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="super_edition_1-1723117654225.png" alt="super_edition_1-1723117654225.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I tried without double quotes also, it returned empty:&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;substr(message.processingDuration, 1, len(message.processingDuration)-2)&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;Appreciate your help on this.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2024 11:55:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/splunk-query-with-substring-not-working/m-p/695685#M236525</guid>
      <dc:creator>super_edition</dc:creator>
      <dc:date>2024-08-08T11:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: splunk query with substring not working</title>
      <link>https://community.splunk.com/t5/Splunk-Search/splunk-query-with-substring-not-working/m-p/695693#M236527</link>
      <description>&lt;P&gt;A string in single quotes is treated by Splunk as a field name.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;substr('message.processingDuration', 1, len('message.processingDuration')-2)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 08 Aug 2024 12:27:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/splunk-query-with-substring-not-working/m-p/695693#M236527</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-08-08T12:27:59Z</dc:date>
    </item>
  </channel>
</rss>

