<?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: spath in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/spath/m-p/689012#M234840</link>
    <description>&lt;P&gt;Base on my complete solution is there a way to remove duplicates based on two values (workOrderId and Status) before aggregating ? from "| spath input=content path=workOrderId"&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index="wcnp_acc-omni" "*acc-omni-service-prod*"
| spath path=log.content output=content
| eval content=json_array_to_mv(content)
| mvexpand content
| spath input=content path=status
| spath input=content path=serviceCart.serviceItems{}.serviceType output=serviceType
| eval created=if(serviceType="OIL_AND_LUBE" AND status="CREATED", 1, 0)
| eval completed=if(serviceType="OIL_AND_LUBE" AND status="SERVICE_COMPLETE", 1, 0)
| where completed &amp;gt; 0 OR created &amp;gt; 0
| stats sum(created) as createdTotal, sum(completed) as completedTotal
| eval total = (completedTotal/createdTotal) * 100
| table total, createdTotal, completedTotal
| rename total as "Total Completion Rate Oil/Lube" createdTotal as "Total Created" completedTotal as "Total Completed"&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 29 May 2024 16:53:44 GMT</pubDate>
    <dc:creator>jrowland1230</dc:creator>
    <dc:date>2024-05-29T16:53:44Z</dc:date>
    <item>
      <title>spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688216#M234660</link>
      <description>&lt;P&gt;I want to do some analysis on "status" below but having a hard time getting to "status". I start with:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| spath path=log.content
| table log.content&lt;/LI-CODE&gt;
&lt;P&gt;but that only gives me the json array from content. I've tried "spath path=log.content{}" and "spath path=log.content{}.status but it ends up empty. I want to be able to do a ternary operation on "status" like the sample below:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| mvexpand log.content{}.status

| eval Service=if('log.content{}.status'="CANCELLED", "Cancelled", if('log.content{}.status'="BAY", "Bay", NULL))

| where isnotnull(Service)
| stats count by Service&lt;/LI-CODE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jrowland1230_0-1716323311529.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/30898iD37AE876D4557262/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jrowland1230_0-1716323311529.png" alt="jrowland1230_0-1716323311529.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 21:07:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688216#M234660</guid>
      <dc:creator>jrowland1230</dc:creator>
      <dc:date>2024-05-21T21:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688218#M234661</link>
      <description>&lt;P&gt;Rather than sharing a picture of the event (which is not a lot of use), please could you share the raw event in a code block &amp;lt;/&amp;gt; (anonymised of course)&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 21:19:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688218#M234661</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-05-21T21:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688225#M234662</link>
      <description>&lt;LI-CODE lang="markup"&gt;{"cluster_id":"uscentral","kubernetes":{"host":"worker-uscentral","labels":{"app":"service","version":"v1"},"namespace_name":"om","pod_name":"service-"},"log":{"config":{"headers":{"Accept":"application/json","Accept-Encoding":"gzip, deflate","Content-Type":"application/json","WM_CONSUMER.ID":"222222-d1bf-4141-a275-2232323232","WM_SVC.ENV":"prod","WM_SVC.NAME":"SERVICEHISTORY","cookie":"a36e-5b4c7c82f05b","wm_qos.correlation_id":"d40031a5271c463d-00","x-o-correlation-id":"00-c0","x-user":"OMN"},"searchParams":{"keyWag":"846","storeNumber":"xx"}},"content":"[{\"status\":\"SERVICE_COMPLETE\",\"OId\":\"eb6fc890-526cb1b\",\"vehicle\":{\"vehicleId\":\"54c4b31\",\"vin\":\"2c3cdxbg8jh255808\",\"year\":\"2018\",\"make\":\"DODGE\",\"model\":\"CHARGER\",\"licensePlate\":\"777\",\"licensePlateState\":\"texas\",\"documentType\":\"vehicle\",\"sourceUpdateRequired\":false,\"isDually\":false},\"customer\":{\"id\":null,\"wmtProfileId\":\"-a0b4-447f-bd99-\",\"communicationConsent\":null,\"firstName\":\"xxx\",\"lastName\":\"xxx\",\"phoneNumber\":\"1111111\",\"countryCode\":1,\"email\":null,\"address\":{\"address1\":\"222 Lane\",\"address2\":null,\"city\":\"long\",\"state\":\"Texas\",\"zip\":\"77535\",\"country\":\"United States\"},\"createdBy\":null,\"dateCreated\":null,\"updatedBy\":null,\"dateUpdated\":null,\"cId\":\"-923a-4c076501f8b0b\",\"documentType\":\"customer\",\"ccpaOptOut\":false,\"legacyIds\":null,\"blockingKey\":null,\"similarRecords\":null,\"createForced\":false,\"linkSource\":null,\"recordSource\":null},\"odometer\":{\"value\":5,\"unit\":\"MILE\"},\"keyTag\":\"777\",\"serviceCart\":{\"serviceItems\":[{\"id\":\"5a92-97304651e9fe\",\"iteId\":\"370122\",\"name\":\"High mileage featured\",\"upc\":\"999\",\"quantity\":0,\"serviceType\":\"OIL_AND_LUBE\",\"components\":[{\"componentType\":\"OIL\",\"product\":{\"itId\":\"99\",\"upc\":\"00071611012225\",\"name\":\"Pennzoil High Mileage 5W20 Motor Oil Ecobox, 1 Quart -\",\"quantity\":5.900,\"retailPrice\":20.72,\"cusredit\":0,\"includedQuantity\":5,\"attributes\":[{\"key\":\"brand\",\"value\":\"Pennzoil\"}]},\"configurations\":[]},{\"componentType\":\"OIL_FILTER\",\"product\":{\"itemId\":\"100992364\",\"upc\":\"00060223\",\"name\":\"FRAM Core 11665 Oil Filter - Offer Valid for In-store Oil Change Only Fits select: 2014-2018 JEEP, 2015-2019 JEEP UNLIMITED\",\"quantity\":1,\"retailPrice\":1.52,\"customerCredit\":0,\"includedQuantity\":1,\"attributes\":[{\"key\":\"brand\",\"value\":\"FRAM\"}]},\"configurations\":[]}],\"retailPrice\":44.88,\"laborCost\":29.76,\"ifNeeded\":false,\"serviceIfNecessary\":false}],\"total\":47.33},\"storeNumber\":\"744\",\"creationDate\":\"2023-05-21T22:53:49.915774Z\",\"documentType\":\"wr\",\"amountPaid\":0,\"markDowns\":[],\"isNewOrder\":true,\"isCarryInOrder\":false,\"isCarryOutOrder\":false,\"isFulfillmentInNextGenBay\":true,\"isVehicleDamageCapturedInSW\":false}]","context":{"duration":"-","level":1,"parentTxId":"00-cb4ec2ec5795a1a7a11-d40031a5271c463d-00","sessionId":"a08f812f-012-18f9d848c23b26","topTxId":"a08f812f-8f9d848c238d4","txId":"a09d848c23775"},"event":"UPSTREAM RESPONSE - GET_ACTIVE_SERVICE_DETAILS","level":30,"msg":"","name":"stdout","oo_env":"prod","reqId":"00-cb4ec2d7e2f031a5271c463d-00","resolverInfo":{},"tags":["info"],"tenant":"US-B2C-undefined","time":1716334661094,"timings":{"dns":2,"download":0,"firstByte":417,"request":0,"tcp":0,"tls":15,"total":434,"wait":0},"type":"INFO","url":"https://localhost/active"},"time":"2024-05-21T23:37:41.094957544Z"}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 22 May 2024 00:08:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688225#M234662</guid>
      <dc:creator>jrowland1230</dc:creator>
      <dc:date>2024-05-22T00:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688248#M234665</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/268172"&gt;@jrowland1230&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I tried ingesting the sample data in my environment and the following SPL works.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;source="community_question.txt" host="my_host" sourcetype="jrowland_json"
| spath path=log output=log
| spath input=log path=content output=content
| rex field=content "status\":\"(?&amp;lt;status_extract&amp;gt;\w+)\""
| table status_extract
| eval Service=case(status_extract="CANCELLED","Cancelled",status_extract="BAY","BAY",true(),"NULL")&lt;/LI-CODE&gt;&lt;P&gt;Please refer to the following screenshot as well:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tej57_0-1716360001802.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/30901i361E8DACED2895EF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tej57_0-1716360001802.png" alt="tej57_0-1716360001802.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Tejas.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;If the above solution helps, an upvote is appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 06:40:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688248#M234665</guid>
      <dc:creator>tej57</dc:creator>
      <dc:date>2024-05-22T06:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688260#M234669</link>
      <description>&lt;P&gt;The best way to do this is probably by using the json functions in combination with spath. Try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath path=log.content output=content
| eval content=json_array_to_mv(content)
| mvexpand content
| spath input=content path=status
| eval Service=if(status="CANCELLED", "Cancelled", if(status="BAY", "Bay", null()))
| where isnotnull(Service)
| stats count by Service&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 22 May 2024 08:26:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688260#M234669</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-05-22T08:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688314#M234676</link>
      <description>&lt;P&gt;Thank you for the swift response. It looks to be working as expected.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 12:33:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688314#M234676</guid>
      <dc:creator>jrowland1230</dc:creator>
      <dc:date>2024-05-22T12:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688374#M234688</link>
      <description>&lt;P&gt;Within the json under the node"content" there is another array where I need to access a value &lt;STRONG&gt;serviceCart.serviceItems{}. serviceType&lt;/STRONG&gt;&amp;nbsp; "serviceType" as shown here:&lt;/P&gt;
&lt;PRE&gt;\"serviceCart\":{\"serviceItems\":[{\"id\":\"5a92-97304651e9fe\",\"iteId\":\"370122\",\"name\":\"High mileage featured\",\"upc\":\"999\",\"quantity\":0,\"serviceType\":\"OIL_AND_LUBE\",\"components\":[{\"componentType\":\"OIL\",\"product\":{\"itId\":\"99\",\"upc\":\"00071611012225\",\"name\":\"Pennzoil High Mileage 5W20 Motor Oil Ecobox, 1 Quart -\",\"quantity\":5.900,\"retailPrice\":20.72,\"cusredit\":0,\"includedQuantity\":5,\"attributes\":[{\"key\":\"brand\",\"value\":\"Pennzoil\"}]},\"configurations\":[]},{\"componentType\":\"OIL_FILTER\",\"product\":{\"itemId\":\"100992364\",\"upc\":\"00060223\",\"name\":\"FRAM Core 11665 Oil Filter - Offer Valid for In-store Oil Change Only Fits select: 2014-2018 JEEP, 2015-2019 JEEP UNLIMITED\",\"quantity\":1,\"retailPrice\":1.52,\"customerCredit\":0,\"includedQuantity\":1,\"attributes\":[{\"key\":\"brand\",\"value\":\"FRAM\"}]}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Using the same technique above I am not able to obtain the value. Here's what I tried.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| spath path=log.content output=content
| eval content=json_array_to_mv(content)
| mvexpand content
| spath input=content path=status
| spath input=content path=serviceCart.serviceItems{}.serviceType

| eval Service=if((serviceCart.serviceItems{}.serviceType="OIL" OR serviceCart.serviceItems{}.serviceType="TIRE") AND status="CANCELLED", "Cancelled", if((serviceCart.serviceItems{}.serviceType="OIL" OR serviceCart.serviceItems{}.serviceType="TIRE") AND status="BAY", "Bay", null()))

| where isnotnull(Service)

| stats count by Service&lt;/LI-CODE&gt;
&lt;P class=""&gt;But "serviceType" is empty in the ternary check. However when I check it in "table&amp;nbsp;serviceCart.serviceItems{}.serviceType" I see the value. I tried using mvexpand on the array "&lt;SPAN class=""&gt;serviceCart.serviceItems" (not shown above)&lt;/SPAN&gt;&amp;nbsp;as well but still empty&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 16:53:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688374#M234688</guid>
      <dc:creator>jrowland1230</dc:creator>
      <dc:date>2024-05-22T16:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688376#M234690</link>
      <description>&lt;P&gt;Try like this (or put the fields in the if function in single quotes)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath path=log.content output=content
| eval content=json_array_to_mv(content)
| mvexpand content
| spath input=content path=status
| spath input=content path=serviceCart.serviceItems{}.serviceType output=serviceType

| eval Service=if((serviceType="OIL" OR serviceType="TIRE") AND status="CANCELLED", "Cancelled", if((serviceType="OIL" OR serviceType="TIRE") AND status="BAY", "Bay", null()))&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 22 May 2024 17:13:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688376#M234690</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-05-22T17:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688381#M234693</link>
      <description>&lt;P&gt;Thank you for the quick turnaround. I just missed the OUPUT.&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 18:25:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/spath/m-p/688381#M234693</guid>
      <dc:creator>jrowland1230</dc:creator>
      <dc:date>2024-05-22T18:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/spath/m-p/689012#M234840</link>
      <description>&lt;P&gt;Base on my complete solution is there a way to remove duplicates based on two values (workOrderId and Status) before aggregating ? from "| spath input=content path=workOrderId"&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index="wcnp_acc-omni" "*acc-omni-service-prod*"
| spath path=log.content output=content
| eval content=json_array_to_mv(content)
| mvexpand content
| spath input=content path=status
| spath input=content path=serviceCart.serviceItems{}.serviceType output=serviceType
| eval created=if(serviceType="OIL_AND_LUBE" AND status="CREATED", 1, 0)
| eval completed=if(serviceType="OIL_AND_LUBE" AND status="SERVICE_COMPLETE", 1, 0)
| where completed &amp;gt; 0 OR created &amp;gt; 0
| stats sum(created) as createdTotal, sum(completed) as completedTotal
| eval total = (completedTotal/createdTotal) * 100
| table total, createdTotal, completedTotal
| rename total as "Total Completion Rate Oil/Lube" createdTotal as "Total Created" completedTotal as "Total Completed"&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 29 May 2024 16:53:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/spath/m-p/689012#M234840</guid>
      <dc:creator>jrowland1230</dc:creator>
      <dc:date>2024-05-29T16:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: spath</title>
      <link>https://community.splunk.com/t5/Splunk-Search/spath/m-p/689013#M234841</link>
      <description>&lt;LI-CODE lang="markup"&gt;| dedup workOrderId Status&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 29 May 2024 16:29:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/spath/m-p/689013#M234841</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-05-29T16:29:49Z</dc:date>
    </item>
  </channel>
</rss>

