<?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 to select the value of a field where another field equals a specific value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-select-the-value-of-a-field-where-another-field-equals-a/m-p/643986#M223100</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;I have a search query problem that's wrecking my newbie brain.&lt;/P&gt;
&lt;P&gt;I have log events that look like this:&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;{
  "operationName": "Add app role assignment to group",
  "properties": {
    "targetResources": [
      {
        "administrativeUnits": [],
        "displayName": "MyAwesomeDisplayName",
        "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "modifiedProperties": [
          {
            "displayName": "AppRole.Id",
            "newValue": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "oldValue": null
          },
          {
            "displayName": "AppRole.Value",
            "newValue": null,
            "oldValue": null
          },
          {
            "displayName": "Group.ObjectID",
            "newValue": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "oldValue": null
          },
          {
            "displayName": "Group.DisplayName",
            "newValue": "myAwesomeGroupName",
            "oldValue": null
          },
          {
            "displayName": "Group.WellKnownObjectName",
            "newValue": null,
            "oldValue": null
          }
        ],
        "type": "ServicePrincipal"
      }
    ],
    "userAgent": null
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I'm trying to do is get the corresponding value for &lt;FONT face="courier new,courier"&gt;newValue&lt;/FONT&gt; where &lt;FONT face="courier new,courier"&gt;displayName&lt;/FONT&gt; is &lt;FONT face="courier new,courier"&gt;Group.DisplayName&lt;/FONT&gt;. i.e. when &lt;FONT face="courier new,courier"&gt;displayName=Group.DisplayName&lt;/FONT&gt;, the corresponding &lt;FONT face="courier new,courier"&gt;newValue&lt;/FONT&gt; for that would be (in this example) &lt;FONT face="courier new,courier"&gt;myAwesomeGroupName&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;Not every log event will have a &lt;FONT face="courier new,courier"&gt;displayName=Group.DisplayName&lt;/FONT&gt; event in it, so that's why I'm looking to capture when it's there.&lt;/P&gt;
&lt;P&gt;I hope that makes sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 22 May 2023 12:39:19 GMT</pubDate>
    <dc:creator>TravellingGuy</dc:creator>
    <dc:date>2023-05-22T12:39:19Z</dc:date>
    <item>
      <title>How to select the value of a field where another field equals a specific value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-select-the-value-of-a-field-where-another-field-equals-a/m-p/643986#M223100</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;I have a search query problem that's wrecking my newbie brain.&lt;/P&gt;
&lt;P&gt;I have log events that look like this:&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;{
  "operationName": "Add app role assignment to group",
  "properties": {
    "targetResources": [
      {
        "administrativeUnits": [],
        "displayName": "MyAwesomeDisplayName",
        "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "modifiedProperties": [
          {
            "displayName": "AppRole.Id",
            "newValue": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "oldValue": null
          },
          {
            "displayName": "AppRole.Value",
            "newValue": null,
            "oldValue": null
          },
          {
            "displayName": "Group.ObjectID",
            "newValue": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
            "oldValue": null
          },
          {
            "displayName": "Group.DisplayName",
            "newValue": "myAwesomeGroupName",
            "oldValue": null
          },
          {
            "displayName": "Group.WellKnownObjectName",
            "newValue": null,
            "oldValue": null
          }
        ],
        "type": "ServicePrincipal"
      }
    ],
    "userAgent": null
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I'm trying to do is get the corresponding value for &lt;FONT face="courier new,courier"&gt;newValue&lt;/FONT&gt; where &lt;FONT face="courier new,courier"&gt;displayName&lt;/FONT&gt; is &lt;FONT face="courier new,courier"&gt;Group.DisplayName&lt;/FONT&gt;. i.e. when &lt;FONT face="courier new,courier"&gt;displayName=Group.DisplayName&lt;/FONT&gt;, the corresponding &lt;FONT face="courier new,courier"&gt;newValue&lt;/FONT&gt; for that would be (in this example) &lt;FONT face="courier new,courier"&gt;myAwesomeGroupName&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;Not every log event will have a &lt;FONT face="courier new,courier"&gt;displayName=Group.DisplayName&lt;/FONT&gt; event in it, so that's why I'm looking to capture when it's there.&lt;/P&gt;
&lt;P&gt;I hope that makes sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 May 2023 12:39:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-select-the-value-of-a-field-where-another-field-equals-a/m-p/643986#M223100</guid>
      <dc:creator>TravellingGuy</dc:creator>
      <dc:date>2023-05-22T12:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to select the value of a field where another field equals a specific value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-select-the-value-of-a-field-where-another-field-equals-a/m-p/643992#M223101</link>
      <description>&lt;P&gt;Something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath path=properties.targetResources{} output=targetResources
| mvexpand targetResources
| fields - data
| spath input=targetResources
| rename displayName as displayName_orig
| spath input=targetResources path=modifiedProperties{}
| mvexpand modifiedProperties{}
| spath input=modifiedProperties{}
| rename displayName as displayName_mod
| where displayName_mod == displayName_orig&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 20 May 2023 02:39:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-select-the-value-of-a-field-where-another-field-equals-a/m-p/643992#M223101</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-05-20T02:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to select the value of a field where another field equals a specific value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-select-the-value-of-a-field-where-another-field-equals-a/m-p/644349#M223175</link>
      <description>&lt;P&gt;Hi yuanliu.&lt;/P&gt;&lt;P&gt;Thanks for trying, but I realize by question wasn't phrased very well and my example JSON wasn't a very good example.&lt;/P&gt;&lt;P&gt;I think I have a solution, but I'll try explaining it differently. Here's a sample JSON log.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "operationName": "Add app role assignment to group",
  "properties": {
    "targetResources": [
      {
        "administrativeUnits": [],
        "displayName": "MyAwesomeDisplayName",
        "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "modifiedProperties": [
          {
            "displayName": "Group.DisplayName",
            "newValue": "myAwesomeGroupName",
            "oldValue": null
          }
        ],
        "type": "ServicePrincipal"
      }
    ],
    "userAgent": null
  },
  "operationName": "Add app role assignment grant to user",
  "properties": {
    "targetResources": [
      {
        "administrativeUnits": [],
        "displayName": "MyAwesomeDisplayNameTwo",
        "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "modifiedProperties": [
          {
            "displayName": "User.UPN",
            "newValue": "myemail@onetrust.com",
            "oldValue": null
          }
        ],
        "type": "ServicePrincipal"
      }
    ],
    "userAgent": null
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;What I want to do is, if &lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;properties.targetResources.modifiedProperties.displayName = "Group.DisplayName"&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt; then I want to retrieve the corresponding value in &lt;FONT face="courier new,courier"&gt;properties.targetResources.modifiedProperties.newValue&lt;/FONT&gt; (in this case "&lt;FONT face="courier new,courier"&gt;myAwesomeGroupName&lt;/FONT&gt;") and put it into a new field.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Correspondingly, if &lt;FONT face="courier new,courier"&gt;properties.targetResources.modifiedProperties.displayName = "User.UPN"&lt;/FONT&gt; then I want to get the corresponding &lt;FONT face="courier new,courier"&gt;newValue&lt;/FONT&gt; for that as a separate field.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Although, as I pondered it over the weekend, I think it's better if I make two separate alerts with two separate queries where my search only includes records where &lt;FONT face="courier new,courier"&gt;operationName = "Add app role assignment to group"&lt;/FONT&gt;, then I know &lt;FONT face="courier new,courier"&gt;properties.targetResources.modifiedProperties.displayName = "Group.DisplayName"&lt;/FONT&gt; will always be there (and then a separate one for the &lt;FONT face="courier new,courier"&gt;User.UPN&lt;/FONT&gt; query/alert). I was trying to do it as a single query/alert, but there are two different things, really, so breaking them up makes more sense and should work for me.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2023 20:03:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-select-the-value-of-a-field-where-another-field-equals-a/m-p/644349#M223175</guid>
      <dc:creator>TravellingGuy</dc:creator>
      <dc:date>2023-05-23T20:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to select the value of a field where another field equals a specific value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-select-the-value-of-a-field-where-another-field-equals-a/m-p/644397#M223194</link>
      <description>&lt;P&gt;It sounds like you want to preserve all events but selectively populate a new field only when&amp;nbsp;properties.targetResources{}.modifiedProperties{}.displayName is in a select group. &amp;nbsp;Is this correct? &amp;nbsp;Something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath path=properties.targetResources{}
| mvexpand properties.targetResources{}
| spath input=properties.targetResources{} path=modifiedProperties{}
| mvexpand modifiedProperties{}
| spath input=modifiedProperties{}
| eval newField = if(displayName IN ("Group.DisplayName", "User.UPN"), newValue, null())&lt;/LI-CODE&gt;&lt;P&gt;But if this is concerning alerting, you would want to discard data outside that select group, like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath input=data path=properties.targetResources{}
| mvexpand properties.targetResources{}
| spath input=properties.targetResources{} path=modifiedProperties{}
| mvexpand modifiedProperties{}
| spath input=modifiedProperties{}
| where displayName IN ("Group.DisplayName", "User.UPN")
| rename newValue as newField&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 06:13:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-select-the-value-of-a-field-where-another-field-equals-a/m-p/644397#M223194</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-05-24T06:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to select the value of a field where another field equals a specific value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-select-the-value-of-a-field-where-another-field-equals-a/m-p/644558#M223227</link>
      <description>&lt;P&gt;Yes! That's it, exactly what I was looking to do. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 21:36:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-select-the-value-of-a-field-where-another-field-equals-a/m-p/644558#M223227</guid>
      <dc:creator>TravellingGuy</dc:creator>
      <dc:date>2023-05-24T21:36:47Z</dc:date>
    </item>
  </channel>
</rss>

