<?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: Splunk stats count &amp;amp; group by on key value using a single field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/701087#M237854</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;Thank you for your response and patience.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 05 Oct 2024 19:47:27 GMT</pubDate>
    <dc:creator>hthwal</dc:creator>
    <dc:date>2024-10-05T19:47:27Z</dc:date>
    <item>
      <title>Splunk stats count &amp; group by on key value using a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700833#M237766</link>
      <description>&lt;P&gt;How do I generate reports and run stats on key=value from just&amp;nbsp;&lt;STRONG&gt;message&amp;nbsp;&lt;/STRONG&gt;field . Ignoring rest of the fields.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{"cluster_id":"cluster", "message":"Excel someType=MY_TYPE totalItems=1 errors=ABC, XYZ status=success","source":"some_data"}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;Gone through multiple examples but could not find something concrete that will help me group by on&amp;nbsp; key&amp;nbsp;&lt;STRONG&gt;someType,&amp;nbsp;&lt;/STRONG&gt;compute stats on &lt;STRONG&gt;totalItems, &lt;/STRONG&gt;list&lt;STRONG&gt; top errors ABC, XYZ&lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;These don't have to be in the same query. I assume top errors grouping would be a separate query.&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 03:00:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700833#M237766</guid>
      <dc:creator>hthwal</dc:creator>
      <dc:date>2024-10-03T03:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count &amp; group by on key value using a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700840#M237767</link>
      <description>&lt;P&gt;You need to better explain the desired results by illustrating them in table or elaborate on what "compute stats on totalItems" will do. &amp;nbsp;Do not force volunteers to read your mind.&lt;/P&gt;&lt;P&gt;If I must try mind reading, I speculate that you want a sum of totalItems. &amp;nbsp;This can be achieved with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rename message as _raw
| kv
| stats sum(totalItems) as totalItems by someType&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an expansion of your mock data to make total meaningful&lt;/P&gt;&lt;TABLE width="785px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;_raw&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="784px"&gt;{"cluster_id":"cluster","message":"Excel someType=MY_TYPE totalItems=1 errors=\"ABC, XYZ\" status=success","source":"some_data"}&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN&gt;{"cluster_id":"cluster","message":"Excel someType=YOUR_TYPE totalItems=2 errors=\"ABC, XYZ\" status=failure","source":"some_data"}&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="784px"&gt;{"cluster_id":"cluster","message":"Excel someType=MY_TYPE totalItems=3 errors=\"AAA, XYZ\" status=questionable","source":"some_data"}&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Running the above search gives&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;someType&lt;/TD&gt;&lt;TD&gt;totalItems&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;MY_TYPE&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;YOUR_TYPE&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Is this table about right?&lt;/P&gt;&lt;P&gt;You are correct to call out total errors needing to be a separate search. (I mean, you can have them combined if you want to group top error by someType, too.) &amp;nbsp;To do this, however, I have to assume that your developers are nice to you and placed quotes around values of errors. (See the difference between my mock data and yours.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rename message as _raw
| kv
| stats count by errors
| sort count
| tail 1
| rename errors as topErrors&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The same expanded, "nicified" mock data would give&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;topErrors&lt;/TD&gt;&lt;TD&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC, XYZ&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;This is the emulation to produce the mock data that you can play with and compare with real data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults format=json data="[
{\"cluster_id\":\"cluster\", \"message\":\"Excel someType=MY_TYPE totalItems=1 errors=\\\"ABC, XYZ\\\" status=success\",\"source\":\"some_data\"},
{\"cluster_id\":\"cluster\", \"message\":\"Excel someType=YOUR_TYPE totalItems=2 errors=\\\"ABC, XYZ\\\" status=failure\",\"source\":\"some_data\"},
{\"cluster_id\":\"cluster\", \"message\":\"Excel someType=MY_TYPE totalItems=3 errors=\\\"AAA, XYZ\\\" status=questionable\",\"source\":\"some_data\"}
]"
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 06:01:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700840#M237767</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-10-03T06:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count &amp; group by on key value using a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700851#M237770</link>
      <description>&lt;P&gt;Splunk will do aggregations on the fields you tell it to as long as you have those fields extracted. Until then, they are not fields, they are just some parts of the raw data. You must define proper ways to extract the fields you want to either aggregate or split your aggregations on.&lt;/P&gt;&lt;P&gt;One way is what &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt; has already shown. Another way is to define extractions at sourcetype level.&lt;/P&gt;&lt;P&gt;Anyway, your data seems a bit "ugly" - it seems to be a json structure with a string field containing some partly-structured data. It would be much better if the data was actually provided in a consistent format so that you don't have to stand on your head in a bucket full of piranhas to get the values you need.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 07:02:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700851#M237770</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-10-03T07:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count &amp; group by on key value using a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700884#M237781</link>
      <description>&lt;P&gt;This is the query I have figured out from awesome Splunk community&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my-index "kubernetes.namespace_name"="namus" "cluster_id":"*stage*" "Env":"stg" "loggerName":"com.x.x.x.SomeClass" "My simple query for key=" "log.level"=INFO 
| spath output=x log.message
| rex max_match=0 field=x "(?&amp;lt;key&amp;gt;\w+)=(?&amp;lt;value&amp;gt;\w+)"
| eval z=mvzip(key, value, "~") 
| mvexpand z 
| rex field=z "(?&amp;lt;key&amp;gt;[^~]+)~(?&amp;lt;value&amp;gt;.*)"
| table key value
| eval dummy="" 
| xyseries dummy key value 
| fields - dummy&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;Which results in this output. I am missing lot of data. Can someone show how to list all the rows found. What is that I am missing here?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-10-03 at 6.30.14 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/32920iCBA1D29B2E898458/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2024-10-03 at 6.30.14 AM.png" alt="Screenshot 2024-10-03 at 6.30.14 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 13:34:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700884#M237781</guid>
      <dc:creator>hthwal</dc:creator>
      <dc:date>2024-10-03T13:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count &amp; group by on key value using a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700937#M237796</link>
      <description>&lt;P&gt;1. We still have no idea what your raw data looks like. For example - how are we supposed to know whether the log.message path is the right one? I suppose it is because you're getting _some_ result but we have no way to know it.&lt;/P&gt;&lt;P&gt;2. Your initial search is very ineffective. Wildcards in the middle of search terms can give strange and inconsistent results and generally wildcards in a place other than the end of a search term slow your search.&lt;/P&gt;&lt;P&gt;3. You're getting some result but you're not showing us anything. How are we supposed to even understand what you're getting?&lt;/P&gt;&lt;P&gt;4. Don't get involved in this "177 events" number. It's just all events that have been matched by your initial search.&lt;/P&gt;&lt;P&gt;5. There are two main techniques of debugging searches - either you start from the start and add commands one by one until the results stop making sense or you start with the whole search and remove commands one by one until the results start making sense.&lt;/P&gt;&lt;P&gt;6. Honestly, I have no idea what you're trying to achieve with this mvzip/mvexpand/regex magic.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 18:52:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700937#M237796</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-10-03T18:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count &amp; group by on key value using a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700940#M237797</link>
      <description>&lt;P&gt;Here is the sample log.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{"cluster_id":"cluster","kubernetes":{"host":"host","labels":{"app":"app","version":"v1"},"namespace_name":"namespace","pod_name":"pod},"log":{"App":"app_name","Env":"stg","LogType":"Application","contextMap":{},"endOfBatch":false,"level":"INFO","loggerFqcn":"org.apache.logging.log4j.spi.AbstractLogger","loggerName":"com.x.x.x.X","message":"Json path=/path feed=NAME sku=SKU_NAME status=failed errorCount=3 errors=ERROR_1, ERROR_2, MORE_ERROR_3 fields=Field 1, Field 2, More Fields Here","source":{"class":"com.x.x.x.X","file":"X.java","line":1,"method":"s"},"thread":"http-apr-8080-exec-4","threadId":1377,"threadPriority":5,"timeMillis":1727978156925},"time":"2024-10-03T17:55:56.925335046Z"}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Expected output from field &lt;STRONG&gt;message&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="12.5%" height="25px"&gt;path&lt;/TD&gt;&lt;TD width="12.5%" height="25px"&gt;feed&lt;/TD&gt;&lt;TD width="12.5%" height="25px"&gt;sku&lt;/TD&gt;&lt;TD width="12.5%" height="25px"&gt;status&lt;/TD&gt;&lt;TD width="12.5%" height="25px"&gt;errorCount&lt;/TD&gt;&lt;TD width="12.5%" height="25px"&gt;errors&lt;/TD&gt;&lt;TD width="12.5%" height="25px"&gt;fields&lt;/TD&gt;&lt;TD width="12.5%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;/path&lt;/TD&gt;&lt;TD height="25px"&gt;Name&lt;/TD&gt;&lt;TD height="25px"&gt;SKU_NAME&lt;/TD&gt;&lt;TD height="25px"&gt;failed&lt;/TD&gt;&lt;TD height="25px"&gt;3&lt;/TD&gt;&lt;TD height="25px"&gt;ERROR_1, ERROR_2, MORE_ERROR_3&lt;/TD&gt;&lt;TD height="25px"&gt;Field 1,Field 2,More Fields Here&lt;/TD&gt;&lt;TD height="25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If data within &lt;STRONG&gt;message &lt;/STRONG&gt;field is ugly, I am willing to modify. But I assume, it will be treated as raw data and will not be treated as field&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;---&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This seems to work when&amp;nbsp; these regex are removed&amp;nbsp;&lt;STRONG&gt;errors=(?P&amp;lt;errors&amp;gt;[^,]+) fields=(?P&amp;lt;fields&amp;gt;[^,]+)&amp;nbsp;&lt;/STRONG&gt;How do I fix errors and fields.&lt;BR /&gt;&lt;BR /&gt;Whereas when tested on&amp;nbsp;&amp;nbsp;&lt;A title="Working regex" href="https://pythex.org/?regex=Json%20path%3D(%3FP%3Cpath%3E%5C%2F%5Cw%2B)%20feedType%3D(%3FP%3CfeedType%3E%5Cw%2B)%20sku%3D(%3FP%3Csku%3E%5Cw%2B)%20status%3D(%3FP%3Cstatus%3E%5Cw%2B)%20errorCount%3D(%3FP%3CerrorCount%3E%5Cw%2B)%20errors%3D(%3FP%3Cerrors%3E%5B%5E%2C%5D%2B)%20fields%3D(%3FP%3Cfields%3E%5B%5E%2C%5D%2B)&amp;amp;test_string=Json%20path%3D%2Fvalidate%20feedType%3DOMNI_DSV_ITEM%20sku%3D9780521598958%20status%3Dfailed%20errorCount%3D1%20errors%3DIB_PROPERTIES_NOT_ALLOWED%20fields%3DOrderable&amp;amp;ignorecase=0&amp;amp;multiline=0&amp;amp;dotall=0&amp;amp;verbose=0" target="_blank" rel="noopener"&gt;https://pythex.org/&lt;/A&gt;&amp;nbsp; it works&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=item-interface "kubernetes.namespace_name"="namespace" "cluster_id":"*stage*" "Env":"stg" "loggerName":"com.x.x.x.X" "Json path=/validate feedType=" "log.level"=INFO
| rename log.message as _raw
| rex field=_raw "Json path=(?P&amp;lt;path&amp;gt;\/\w+) feedType=(?P&amp;lt;feedType&amp;gt;\w+) sku=(?P&amp;lt;sku&amp;gt;\w+) status=(?P&amp;lt;status&amp;gt;\w+) errorCount=(?P&amp;lt;errorCount&amp;gt;\w+) errors=(?P&amp;lt;errors&amp;gt;[^,]+) fields=(?P&amp;lt;fields&amp;gt;[^,]+)"
| table path, feedType, sku, status, errorCount, errors, fields&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2024 22:12:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700940#M237797</guid>
      <dc:creator>hthwal</dc:creator>
      <dc:date>2024-10-03T22:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count &amp; group by on key value using a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700962#M237808</link>
      <description>&lt;P&gt;Data illustration could have saved everybody a ton of time reading your mind. &amp;nbsp;The solution is the same as I suggested earlier: kv aka &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Extract" target="_blank" rel="noopener"&gt;extract&lt;/A&gt; is your friend. &amp;nbsp;But first, let me correct JSON error in your mock data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{"cluster_id":"cluster","kubernetes":{"host":"host","labels":{"app":"app","version":"v1"},"namespace_name":"namespace","pod_name":"pod"},"log":{"App":"app_name","Env":"stg","LogType":"Application","contextMap":{},"endOfBatch":false,"level":"INFO","loggerFqcn":"org.apache.logging.log4j.spi.AbstractLogger","loggerName":"com.x.x.x.X","message":"Json path=/path feed=NAME sku=SKU_NAME status=failed errorCount=3 errors=ERROR_1, ERROR_2, MORE_ERROR_3 fields=Field 1, Field 2, More Fields Here"}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now this is a compliant JSON. &amp;nbsp;Second, are you saying that your developers are so inconsiderate as to not properly quote key value pairs? &amp;nbsp;Like I said earlier, in this case, you need to deal with them first. &amp;nbsp;The best route is to implore them to improve log hygiene. &amp;nbsp;Failing that, you can deal with them in a limited way using SPL. &amp;nbsp;The following depends on the order of errors and fields.&lt;/P&gt;&lt;P&gt;The field message is actually named log.message in Splunk. (Many other languages flatten JSON this way, too.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rename log.message as _raw
| rex mode=sed "s/errors=(.+) fields=(.+)/errors=\"\1\" fields=\"\2\"/"
| kv
| table path	feed	sku	status	errorCount	errors	fields&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output is&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;path&lt;/TD&gt;&lt;TD&gt;feed&lt;/TD&gt;&lt;TD&gt;sku&lt;/TD&gt;&lt;TD&gt;status&lt;/TD&gt;&lt;TD&gt;errorCount&lt;/TD&gt;&lt;TD&gt;errors&lt;/TD&gt;&lt;TD&gt;fields&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;/path&lt;/TD&gt;&lt;TD&gt;NAME&lt;/TD&gt;&lt;TD&gt;SKU_NAME&lt;/TD&gt;&lt;TD&gt;failed&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;ERROR_1, ERROR_2, MORE_ERROR_3&lt;/TD&gt;&lt;TD&gt;Field 1, Field 2, More Fields Here&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Here is full emulation of your mock data. &amp;nbsp;Play with it and compare with real data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw ="{\"cluster_id\":\"cluster\",\"kubernetes\":{\"host\":\"host\",\"labels\":{\"app\":\"app\",\"version\":\"v1\"},\"namespace_name\":\"namespace\",\"pod_name\":\"pod\"},\"log\":{\"App\":\"app_name\",\"Env\":\"stg\",\"LogType\":\"Application\",\"contextMap\":{},\"endOfBatch\":false,\"level\":\"INFO\",\"loggerFqcn\":\"org.apache.logging.log4j.spi.AbstractLogger\",\"loggerName\":\"com.x.x.x.X\",\"message\":\"Json path=/path feed=NAME sku=SKU_NAME status=failed errorCount=3 errors=ERROR_1, ERROR_2, MORE_ERROR_3 fields=Field 1, Field 2, More Fields Here\"}}"
| spath
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 01:40:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700962#M237808</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-10-04T01:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count &amp; group by on key value using a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700988#M237818</link>
      <description>&lt;P&gt;OK. We're getting somewhere &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Assuming you had a typo and that's indeed a valid json you can extract values from the log.message field.&lt;/P&gt;&lt;P&gt;The issue I still have with your data is that it's "half-pregnant" - it seems to have some structure to it but it's not kept strictly (I have the same problem with CEF for example). You have some header, then some key=value pairs. There are several issues with those key=value pairs.. What if the value contains the equal sign? What if the value contains a space? It seems that comma-space is a multivalued field separator but is it?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 12:50:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/700988#M237818</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-10-04T12:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count &amp; group by on key value using a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/701046#M237834</link>
      <description>&lt;UL&gt;&lt;LI&gt;I have not seen value with equal sign. I am open for suggestions to pick a better delimiter.&lt;/LI&gt;&lt;LI&gt;There are some values with space. Would this be a problem? I can certainly improve the structure.&lt;/LI&gt;&lt;LI&gt;comma-space is a multivalued field. There are two such fields. Of which, I would need to compute high frequency value at a later stage.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;BR /&gt;I can modify&amp;nbsp;multivalued field [list of data] to something like this&amp;nbsp;&lt;BR /&gt;&lt;A href="https://www.splunk.com/en_us/blog/tips-and-tricks/delimiter-base-kv-extraction-advanced.html?locale=en_us" target="_self"&gt;https://www.splunk.com/en_us/blog/tips-and-tricks/delimiter-base-kv-extraction-advanced.html?locale=en_us&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;FIELDS= "time", "client-ip", "cs-method", "sc-status"&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;Let me know the if there are any changes to be make to&amp;nbsp;&lt;STRONG&gt;log.message&amp;nbsp;&lt;/STRONG&gt;to make it "full-preg" so that Splunk can deliver &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 18:42:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/701046#M237834</guid>
      <dc:creator>hthwal</dc:creator>
      <dc:date>2024-10-04T18:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count &amp; group by on key value using a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/701053#M237838</link>
      <description>&lt;P&gt;Well, the more stronger assumptions you can make about the data the easier it gets. If you have to care about exceptions it's getting complicated quickly.&lt;/P&gt;&lt;P&gt;Take a typical example of&lt;/P&gt;&lt;PRE&gt;key="string value"&lt;/PRE&gt;&lt;P&gt;or&lt;/P&gt;&lt;PRE&gt;key=number_value&lt;/PRE&gt;&lt;P&gt;The latter form is obviously pretty easy to parse&lt;/P&gt;&lt;PRE&gt;(?&amp;lt;key&amp;gt;\S+)=(?&amp;lt;value&amp;gt;\d+)&lt;/PRE&gt;&lt;P&gt;The former is way more complicated to do well. If you simply do&lt;/P&gt;&lt;PRE&gt;(?&amp;lt;key&amp;gt;\S+)="(?&amp;lt;value&amp;gt;.*)"&lt;/PRE&gt;&lt;P&gt;You'll capture way over the boundary of the k-v pair if you have many of them.&lt;/P&gt;&lt;P&gt;If you go lazy&lt;/P&gt;&lt;PRE&gt;(?&amp;lt;key&amp;gt;\S+)="(?&amp;lt;value&amp;gt;.*?)"&lt;/PRE&gt;&lt;P&gt;you'll stop matching in the middle if you have an escaped quote within your value.&lt;/P&gt;&lt;P&gt;(The same happens if instead of matching for .* lazily you match for [^"]* because of course you encounter the same quote).&lt;/P&gt;&lt;P&gt;Ok. So how about we match for everything not being a quote or a quote preceeded by a backslash.&lt;/P&gt;&lt;PRE&gt;(?&amp;lt;key&amp;gt;\S+)="(?&amp;lt;value&amp;gt;([^"]|\\")*)"&lt;/PRE&gt;&lt;P&gt;Ok. Nice idea but what if your value ends with a backslash (expressed as double backslash due to escaping)? You'll miss it because it has the \" sequence and go way past the end of the value.&lt;/P&gt;&lt;P&gt;So maybe we should try making a negative lookback so that a backslash preceeding a quote cannot be prepended by another backslash? But how about three, four and so on backslashes ended with a quote? It's getting messier and messier.&lt;/P&gt;&lt;P&gt;If you can either know for sure that your data will never look like those border cases or can conciously decide that you don't care about those cases and can live with the fact that they will be extracted wrongly it's way easier.&lt;/P&gt;&lt;P&gt;In your case that would be, for example a message containing&lt;/P&gt;&lt;PRE&gt;comment=This is actually an example of a key=value pair. Another_field=Another value&lt;/PRE&gt;&lt;P&gt;or&lt;/P&gt;&lt;PRE&gt;groceries=Let's buy bread, strawberries, butter and pork loin.&lt;/PRE&gt;&lt;P&gt;As you can see without additional assumptions about the data the extractions will be wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 20:11:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/701053#M237838</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-10-04T20:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count &amp; group by on key value using a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/701086#M237853</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Had to modify a little to make it work&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rename log.message as _raw
| rex mode=sed "s/errors=(.+) fields=(.+)/errors=\"\1\" fields=\"\2\"/"
| rex field=_raw "path=(?P&amp;lt;path&amp;gt;.*) feedType=(?P&amp;lt;feedType&amp;gt;.*) sku=(?P&amp;lt;sku&amp;gt;.*) status=(?P&amp;lt;status&amp;gt;.*) errorCount=(?P&amp;lt;errorCount&amp;gt;.*) errors=(?P&amp;lt;errors&amp;gt;.*) fields=(?P&amp;lt;fields&amp;gt;.*)"
| table path, feedType, sku, status, errorCount, errors, fields&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 05 Oct 2024 19:45:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/701086#M237853</guid>
      <dc:creator>hthwal</dc:creator>
      <dc:date>2024-10-05T19:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk stats count &amp; group by on key value using a single field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/701087#M237854</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;Thank you for your response and patience.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Oct 2024 19:47:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Splunk-stats-count-amp-group-by-on-key-value-using-a-single/m-p/701087#M237854</guid>
      <dc:creator>hthwal</dc:creator>
      <dc:date>2024-10-05T19:47:27Z</dc:date>
    </item>
  </channel>
</rss>

