Splunk Search

Compare resp code count of two dates for each servername

indeed_2000
Motivator

Hi 

I have query that return count of different resp codes of servers for 2 days

now need to find different between these two days.

current output:

Respcodes    Srv1      Srv2       Srv3       Srv4  ….

200                    80           10          100       42

400                    12           55            11         0

500                     11           34             2          8

expected output:

Date.                  Respcodes    Srv1      Srv2       Srv3       Srv4  ….

2024/02/23  200                    80           10          100       42

2024/02/24  200                    70           19            11        11

2024/02/23  400                    12           55            11         0

2024/02/24  400                    44           14            46         89

2024/02/23   500                    11           34             2          8

2024/02/24   500                     11           34             2          9              

 

 

 

if there is delta that calculate count of each server for two dates will be great!

any idea?

thanks

Labels (3)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

You can only use three fields for xyseries, the x-axis, the y-axis and the series (names) - hence the name of the command! It is similar in that respect to the chart command. Try something like this

index="myindex" 
| rex field=source "\/.*\/log\.(?<servername>\w+)."
| rex "R(?<Respcode>\[\d+\]\[\d+\])" | bin _time span=1d

| stats count as Respcode_count by Respcode,servername,_time

| eval {servername} = Respcode_count
| fields - servername Respcode_count
| stats values(*) as * by _time Respcode
| fillnull value=0

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Your current output doesn't have any dates, so where are these going to come from?

Please provide some sample events?

Also, please provide your current search, so we can see how you are currently processing the events?

0 Karma

indeed_2000
Motivator

@ITWhisperer Here is the current query, and when i add _time in xyseries it will show resp ode as columns instead row::

index="myindex" 
| rex field=source "\/.*\/log\.(?<servername>\w+)."
| rex "R(?<Respcode>\[\d+\]\[\d+\])" | bin _time span=1d

| stats count as Respcode_count by Respcode,servername,_time

| xyseries Respcode ,servername,Respcode_count

 

Current output:

Respcodes    Srv1      Srv2       Srv3       Srv4  ….

200                    80           10          100       42

400                    12           55            11         0

500                     11           34             2          8

 

expected output:

Date.                  Respcodes    Srv1      Srv2       Srv3       Srv4  ….

2024/02/23  200                    80           10          100       42

2024/02/24  200                    70           19            11        11

2024/02/23  400                    12           55            11         0

2024/02/24  400                    44           14            46         89

2024/02/23   500                    11           34             2          8

2024/02/24   500                     11           34             2          9              


any idea?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You can only use three fields for xyseries, the x-axis, the y-axis and the series (names) - hence the name of the command! It is similar in that respect to the chart command. Try something like this

index="myindex" 
| rex field=source "\/.*\/log\.(?<servername>\w+)."
| rex "R(?<Respcode>\[\d+\]\[\d+\])" | bin _time span=1d

| stats count as Respcode_count by Respcode,servername,_time

| eval {servername} = Respcode_count
| fields - servername Respcode_count
| stats values(*) as * by _time Respcode
| fillnull value=0

indeed_2000
Motivator

@ITWhisperer thanks work perfectly.

is there any way to show resp count numbers like this: 10,1K, 2M, …?

0 Karma
Get Updates on the Splunk Community!

Get ready to show some Splunk Certification swagger at .conf24!

Dive into the deep end of data by earning a Splunk Certification at .conf24. We're enticing you again this ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Now On-Demand Join us to learn more about how you can leverage Service Level Objectives (SLOs) and the new ...

Database Performance Sidebar Panel Now on APM Database Query Performance & Service ...

We’ve streamlined the troubleshooting experience for database-related service issues by adding a database ...