Splunk Search

How to plot time as the y-axis in a timechart?

smhsplunk
Communicator

I am trying to calculate transaction time and plot it on start date.

Finding the difference between two dates and then plotting the difference on the y-axis as time
with x-axis being date(timechart).

I want the Y-axis to show as days, not seconds.

Search is as follows:

source=transaction sourcetype=TRANSACTION_DATA
| eval close_date=strptime(closing_day, "%Y-%m-%d") 
| eval start_date=strptime(starting_day, "%Y-%m-%d")
| eval difference = close_date - start_date 
| eval time_difference = tostring(difference, "duration")
| eval _time=start_date
| timechart values(time_difference) by transaction_type
0 Karma
1 Solution

sundareshr
Legend

Try this

source=transaction sourcetype=TRANSACTION_DATA
 | eval close_date=strptime(closing_day, "%Y-%m-%d") 
 | eval start_date=strptime(starting_day, "%Y-%m-%d")
 | eval difference = round((close_date - start_date)/86400, 2)
 | eval _time=start_date
 | timechart values(time_difference) by transaction_type

View solution in original post

woodcock
Esteemed Legend

Like this:

source=transaction sourcetype=TRANSACTION_DATA
| eval close_date=strptime(closing_day, "%Y-%m-%d") 
| eval start_date=strptime(starting_day, "%Y-%m-%d")
| eval difference = close_date - start_date 
| eval time_difference = tostring(difference, "duration")
| eval _time=start_date
| timechart avg(time_difference) BY transaction_type

sundareshr
Legend

Try this

source=transaction sourcetype=TRANSACTION_DATA
 | eval close_date=strptime(closing_day, "%Y-%m-%d") 
 | eval start_date=strptime(starting_day, "%Y-%m-%d")
 | eval difference = round((close_date - start_date)/86400, 2)
 | eval _time=start_date
 | timechart values(time_difference) by transaction_type
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...