Splunk Search

How to produce a table that can display 5xx status code counts per host over a timeframe?

ccntech
Explorer

I am trying to produce a table that can display 5xx status code counts per host over a timeframe (this will eventually be month, but for the purpose of this example will be by day).

I downloaded the tutorial data  with apache logs and can see the data spans 8 days:

source="access.log" host="www*" sourcetype="access_combined_wcookie" status=500
|timechart span=1d count by host

I want to take this and analyze web server log files at work and increase span to 1 month. Is there a way for me to pivot /transform this data to get a breakdown that would provide the following table:

Daily 500 status code dashboard

host 02-25-22 02-26-22 02-27-22 etc 03-03-22
www1 13 39 35 etc 28
www2 24 31 45 etc 35
www3 18 51 34 etc 36

 

As stated above, I would like this by MONTH: Jan, Feb Mar etc so teams can glance at this table and see which hosts are improving/degrading or meeting SLOs etc. I do not want to create a bar chart, but rather keep the above format.

 

Labels (2)
0 Karma

yuanliu
SplunkTrust
SplunkTrust

The command you are looking for is transpose. (I recently did the same.)  Instead of timechart, start with chart. The following uses 1 week as example, and anchors at beginning of week. (C.f., How to specify relative time modifiers.)

source="access.log" host="www*" sourcetype="access_combined_wcookie" status=500
| bin span=1w@w _time
| chart count over _time by host
| eval _time=strftime(_time, "%m-%d-%y")
| transpose 0 header_field=_time column_name=host

 

Tags (2)

ccntech
Explorer

This is perfect! Thank you for such a quick reply! 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try this:

| timechart span=1mon count by host
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...