<?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: unable to manipulate string from JSON (AWS CloudTrail) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/unable-to-manipulate-string-from-JSON-AWS-CloudTrail/m-p/511978#M143574</link>
    <description>&lt;P&gt;&lt;STRONG&gt;try enclosing the field name&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;requestParameters.Host With single quote like below in if statement:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;‘requestParameters.Host’&lt;/P&gt;</description>
    <pubDate>Fri, 31 Jul 2020 19:21:06 GMT</pubDate>
    <dc:creator>thambisetty</dc:creator>
    <dc:date>2020-07-31T19:21:06Z</dc:date>
    <item>
      <title>unable to manipulate string from JSON (AWS CloudTrail)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-manipulate-string-from-JSON-AWS-CloudTrail/m-p/511959#M143564</link>
      <description>&lt;P&gt;I am trying to write a report of 'AccessDenied' messages in our AWS CloudTrail logs. These are in JSON format and the notable fields change depending on which service reports the error. So I am trying to simplify my results by comparing 2 fields:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;errorMessage&lt;/LI&gt;&lt;LI&gt;requestParameters.Host&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;and keeping whichever one is populated, e.g.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype=aws:cloudtrail errorCode="AccessDenied"
| eval error = if( isnull(requestParameters.Host), errorMessage, requestParameters.Host)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it doesn't work? I've traced it back to something weird with the "requestParameters.Host" field -- which is 'nested' inside the JSON. The other field, "errorMessage" works as expected and that's probably because it's a 'first-level' field in the JSON (not a secondary/nested field)&lt;/P&gt;&lt;P&gt;It's like the "requestParameters.Host" field isn't a string, e.g. the following search also fails&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype=aws:cloudtrail errorCode="AccessDenied"
| eval test = requestParameters.Host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g. "test" is blank&lt;/P&gt;&lt;P&gt;------------------&lt;/P&gt;&lt;P&gt;I have also tried adding an "spath" command but I'm not sure how to use it. If I use the search UI's built-in "Add to search" it inserts:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype=aws:cloudtrail errorCode="AccessDenied" 
| spath "requestParameters.Host"
| eval error = if( isnull(requestParameters.Host), errorMessage, requestParameters.Host)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but that has no effect, i.e., "requestParameters.Host" is still a 'ghost' field which I cannot use in an 'eval' statement&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 16:57:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-manipulate-string-from-JSON-AWS-CloudTrail/m-p/511959#M143564</guid>
      <dc:creator>ttovarzoll</dc:creator>
      <dc:date>2020-07-31T16:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: unable to manipulate string from JSON (AWS CloudTrail)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-manipulate-string-from-JSON-AWS-CloudTrail/m-p/511978#M143574</link>
      <description>&lt;P&gt;&lt;STRONG&gt;try enclosing the field name&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;requestParameters.Host With single quote like below in if statement:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;‘requestParameters.Host’&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 19:21:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-manipulate-string-from-JSON-AWS-CloudTrail/m-p/511978#M143574</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-07-31T19:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: unable to manipulate string from JSON (AWS CloudTrail)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-manipulate-string-from-JSON-AWS-CloudTrail/m-p/511992#M143583</link>
      <description>&lt;P&gt;Bah! It was as simple as that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I would have thought the single-quotes would be treating it as a string value, rather than the long-name of a variable.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 23:12:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-manipulate-string-from-JSON-AWS-CloudTrail/m-p/511992#M143583</guid>
      <dc:creator>ttovarzoll</dc:creator>
      <dc:date>2020-07-31T23:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: unable to manipulate string from JSON (AWS CloudTrail)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/unable-to-manipulate-string-from-JSON-AWS-CloudTrail/m-p/512324#M143693</link>
      <description>&lt;P&gt;double quotes for string. single quotes are used in eval command to identify field names if names contain space or any other special characters.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2020 09:49:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/unable-to-manipulate-string-from-JSON-AWS-CloudTrail/m-p/512324#M143693</guid>
      <dc:creator>thambisetty</dc:creator>
      <dc:date>2020-08-04T09:49:19Z</dc:date>
    </item>
  </channel>
</rss>

