Dashboards & Visualizations

how to create the below mentioned table?

abhi04
Path Finder

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
Path Finder

Can anyone help me on this?

0 Karma

abhi04
Path Finder

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
Path Finder

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
Path Finder

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
Path Finder

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
Path Finder

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!

Enterprise Security Content Update (ESCU) | New Releases

In the last month, the Splunk Threat Research Team (STRT) has had 2 releases of new security content via the ...

Announcing the 1st Round Champion’s Tribute Winners of the Great Resilience Quest

We are happy to announce the 20 lucky questers who are selected to be the first round of Champion's Tribute ...

We’ve Got Education Validation!

Are you feeling it? All the career-boosting benefits of up-skilling with Splunk? It’s not just a feeling, it's ...