Dashboards & Visualizations

how to create the below mentioned table?

abhi04
Communicator

how to create the below mentioned table? I want Duration in minute and duration in seconds.

Job_Name StartTime EndTime Duration_Min Duration_Sec
gc01iwcft 2018/05/31 22:45:00 2018/05/31 22:45:02
2018/05/31 23:00:01 2018/05/31 23:00:03
2018/05/31 23:15:00 2018/05/31 23:15:01

Tags (1)
0 Karma

Shan
Builder

@abhi04

Try below query.

 |makeresults 
| eval timeDiffsec=strptime("2018/05/31 23:45:02","%Y/%m/%d %H:%M:%S")-strptime("2018/05/31 22:45:00", "%Y/%m/%d %H:%M:%S")
| eval Timediff_Mins=round((timeDiffsec/60),1)  
| eval Timediff_Hours=round((timeDiffsec/60/60),1)  
| table timeDiffsec Timediff_Mins Timediff_Hours

I have used sample date and time value instead of it you can use your field. Eg

| eval timeDiffsec=strptime(EndTime ,"%Y/%m/%d %H:%M:%S")-strptime(StartTime, "%Y/%m/%d %H:%M:%S")
0 Karma

abhi04
Communicator

Can anyone help me on this?

0 Karma

abhi04
Communicator

Well the above one is not working with the query I have used. below is the query I am using.

index=auto_prod_iw* "/afiw/batch/scripts/gc01*.ksh" "Job gc01iwcft -" "started - time=" | dedup _raw |rex "\w+\/\w+\/\w+\/(?\w+).ksh"
| eval StartTime=strftime(_time,"%Y/%m/%d %H:%M:%S") | append [| search index=auto_prod_iw* "/afiw/batch/scripts/gc01*.ksh" "Job gc01iwcft -" ("ended - time=" OR "ENDED - time")
| dedup _raw |rex "\w+\/\w+\/\w+\/(?\w+).ksh" | eval EndTime=strftime(_time,"%Y/%m/%d %H:%M:%S")] | transaction Job_Name |dedup Job_Name |eval time_diff=strptime(EndTime,"%Y/%m/%d %H:%M:%S") -strptime(StartTime,"%Y/%m/%d %H:%M:%S") | table Job_Name StartTime EndTime time_diff

0 Karma

abhi04
Communicator

Job_Name StartTime EndTime Duration_Min Duration_Sec
gc01iwcft 2018/05/31 22:45:00 2018/05/31 22:45:02
2018/05/31 23:00:01 2018/05/31 23:00:03
2018/05/31 23:15:00 2018/05/31 23:15:01

0 Karma

Shan
Builder

@ abhi04 - Are you trying to calculate difference between StartTime EndTime in Duration_Min Duration_Sec

0 Karma

abhi04
Communicator

Yes shankarananth

0 Karma

Shan
Builder

@abhi04 - I have tested below sample query for the scenario what you have mentioned. you can try from your end and let know..

0 Karma

niketn
Legend

@abhi04 you have only one Job_name. Are the remaining columns Multi Valued? Or did you just missed to copy the Job Names for each row?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

abhi04
Communicator

Only one job name with Other columns multi valued because this job ran multiple times and I want difference of each.

0 Karma

niketn
Legend

Can you give existing query?

If you need the difference of start time and end time for each occurrence of the Job run, you would need to have them as separate row(possibly just sort by Job Name and Start Time).

If the data is having multivalued fields, then we have to come up with commands to spearate rows. If they are single value in raw events and they have become multivalue due to transforming command then it is better to correct the transforming command upfront.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

abhi04
Communicator

existing Query:

index=auto_prod_iw* "/afiw/batch/scripts/gc01*.ksh" "Job gc01iwcft -" "started - time=" | dedup _raw |rex "\w+\/\w+\/\w+\/(?\w+).ksh"
| eval StartTime=strftime(_time,"%Y/%m/%d %H:%M:%S") | append [| search index=auto_prod_iw* "/afiw/batch/scripts/gc01*.ksh" "Job gc01iwcft -" ("ended - time=" OR "ENDED - time")
| dedup _raw |rex "\w+\/\w+\/\w+\/(?\w+).ksh" | eval EndTime=strftime(_time,"%Y/%m/%d %H:%M:%S")] | transaction Job_Name |dedup Job_Name
| table Job_Name StartTime EndTime duration |eval Duration_Min= round((duration/60),2) | rename duration AS Duration_Sec

0 Karma
Get Updates on the Splunk Community!

Registration for Splunk University is Now Open!

Are you ready for an adventure in learning?   Brace yourselves because Splunk University is back, and it's ...

Splunkbase | Splunk Dashboard Examples App for SimpleXML End of Life

The Splunk Dashboard Examples App for SimpleXML will reach end of support on Dec 19, 2024, after which no new ...

Understanding Generative AI Techniques and Their Application in Cybersecurity

Watch On-Demand Artificial intelligence is the talk of the town nowadays, with industries of all kinds ...