Splunk Search

How to get count for different values in a field when dealing with datamodels?

samakshkhatri
Engager

I have a Data Model called Web_Events with a root object called Access. 

There is a field in Access called 'status_category' with values "client error", "server error", "okay" or "other".

I am trying to list the count of events which have 'status_catgory' as "client error" and "server error" hour by hour

So I want to generate a table of following format

_timeclient_error_countserver_error_count
2022-01-26:17:30:00<count of client error><count of server error>
2022-01-26:18:30:00<count of client error><count of server error>

 

Can anyone help me with this?

The closest I could achieve was as following: 

_timeAccess.status_categoryerror_count
2022-01-26:17:30:00server error2
2022-01-26:18:30:00client error6
2022-01-26:18:30:00server error7

 

with help of this query: (status_code is another field which contains values of HTTP status codes)

| tstats count(Access.status_code) as error_count from datamodel=Web_Events.Access where Access.status_code!=200 earliest="01/26/2022:00:00:00" latest="02/02/2022:23:59:59" BY Access.status_category _time span=1h | table _time, Access.status_category, error_count | sort _time

 

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try adding:

| xyseries _time, Access.status_category, error_count

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try adding:

| xyseries _time, Access.status_category, error_count
0 Karma

samakshkhatri
Engager

This worked! Thanks a lot

Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...