Splunk Search

How to create the Splunk query Search?

uagraw01
Motivator

Hello Splunkers!!

I have mentioned below query and from the below query I want a results as shown below in the excel. Please help me achieve that result.

index=ABC sourcetype=ABC
| eval date_year=strftime('_time',"%Y"), date_month=strftime('_time',"%B"), day_week=strftime('_time',"%A"), date_mday=strftime('_time',"%d"), date_hour=strftime('_time',"%H"), date_minute=strftime('_time',"%M") | stats count count(eval(ShuttleId)) as total by sourcetype
| table sourcetype total
| join max=0 type=outer sourcetype
[| search index=ABC sourcetype=ABC
| eval date_year=strftime('_time',"%Y"), date_month=strftime('_time',"%B"), day_week=strftime('_time',"%A"), date_mday=strftime('_time',"%d"), date_hour=strftime('_time',"%H"), date_minute=strftime('_time',"%M") | stats count by ShuttleId sourcetype _time]
| table ShuttleId count total
| eval condition =if(round((count/total),2) <=0, "GREEN", "RED")
| eval Status =round((count/total),2)
| eval Shuttle_percentage = round(((count/total)*100),2)
| table ShuttleId Shuttle_percentage

 

_time ShuttleId Total_Orders Errors
2022-08-03T00:00:00.000+0000 Shuttle_001 69341 117
2022-08-04T00:00:00.000+0000 Shuttle_002 85640 51
2022-08-05T00:00:00.000+0000 Shuttle_003 72260 43
2022-08-06T00:00:00.000+0000 Shuttle_004 60291 22
2022-08-07T00:00:00.000+0000 Shuttle_005 0 0

 

Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| stats count by _time shuttleId
| eventstats sum(count) as total by shuttleId

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

You have present a seemingly random set of SPL which bear little resemblance to your expected output, with meaningless evaluations which are often not used.

What is it you are actually trying to do, and what have you actually tried so far?

0 Karma

uagraw01
Motivator

@ITWhisperer  | eval command for condition we can ignore. 

I need a result like :

column 1 : time

column 2 : shuttle name

column 3 : total number of shuttle

column 4 : number of count of each shuttle.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What it the difference between column 3 and 4?

0 Karma

uagraw01
Motivator

@ITWhisperer  Column 3 : total count of all the shuttle.  & column 4 : (count of each shuttle/ total count of all the shuttle)

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| stats count by _time shuttleId
| eventstats sum(count) as total by shuttleId

uagraw01
Motivator

@ITWhisperer  I think I am getting below results. Please correct me for the below SPL

 

uagraw01_0-1679314570849.png

=========================================================

index=ora_adam sourcetype=OtShuttleError
| eval date_year=strftime('_time',"%Y"), date_month=strftime('_time',"%B"), day_week=strftime('_time',"%A"), date_mday=strftime('_time',"%d"), date_hour=strftime('_time',"%H"), date_minute=strftime('_time',"%M") | stats count count(eval(ShuttleId)) as total by sourcetype _time
| table sourcetype total _time
| join max=0 type=outer sourcetype
[| search index=ora_adam sourcetype=OtShuttleError
| eval date_year=strftime('_time',"%Y"), date_month=strftime('_time',"%B"), day_week=strftime('_time',"%A"), date_mday=strftime('_time',"%d"), date_hour=strftime('_time',"%H"), date_minute=strftime('_time',"%M") | stats count by ShuttleId sourcetype _time]
| eventstats sum(count) as total by shuttleId

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You might want to consider using the bin command to group your counts by hours or days, but it depends on what your requirement actually is.

0 Karma

uagraw01
Motivator

@ITWhisperer Let me check and try

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Event Series: Telemetry Pipeline Management

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...