Reporting

Counting the implementation days of an event based on Start and End date

Paul_Dixon
Explorer

Hi all, hoping someone can help me with this query.

i have a data set that looks at a process and how long it takes to implement. for example, each event will be populated with a start date and an end date. i want to create a calendar view that shows the schedule of the processes in implementation, for example:

process 1 start date 12/08/2024, end date 16/08/2024 (5 days implementation)
process 2 start date 12/08/2024, end date 12/08/2024 (1 day implementation)
process 3 start date 13/08/2024, end date 15/08/2024 (3 days implementation)
process 4 start date 14/08/2024, end date 16/08/2024 (2 days implementation)

I want to be able to produce a graph or a calendar view that will show how many process' we have in implementation, counting each day of their implementation period (based on start and end date)

so for the above example it would look like:

Date                        count of Process' in implementation
12/08/2024       2 (process 1 and 2)

13/08/2024       2 (process 1 and 3)

14/08/2024       3 (process 1, 3 and 4)

15/08/2024       3 (process 1, 3 and 4)

16/08/2024       2 ((process 1 and 4)

any help greatly appreciated 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

You could do something like this

| rex "process (?<process>\d+) start date (?<start>\S+), end date (?<end>\S+)"
| eval startdate=strptime(start,"%d/%m/%Y")
| eval enddate=relative_time(strptime(end,"%d/%m/%Y"), "+1d")
| eval days=mvappend(startdate, enddate)
| eval row=mvrange(0,2) 
| mvexpand row
| eval _time=mvindex(days, row)
| eval count=1-(row*2)
| stats sum(count) as change by _time
| streamstats sum(change) as total
| makecontinuous _time
| filldown total
| fillnull value=0 change

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

You could do something like this

| rex "process (?<process>\d+) start date (?<start>\S+), end date (?<end>\S+)"
| eval startdate=strptime(start,"%d/%m/%Y")
| eval enddate=relative_time(strptime(end,"%d/%m/%Y"), "+1d")
| eval days=mvappend(startdate, enddate)
| eval row=mvrange(0,2) 
| mvexpand row
| eval _time=mvindex(days, row)
| eval count=1-(row*2)
| stats sum(count) as change by _time
| streamstats sum(change) as total
| makecontinuous _time
| filldown total
| fillnull value=0 change

Paul_Dixon
Explorer

Thanks for this. i was able to utilise your solution to build a working process for what i need!

0 Karma
Get Updates on the Splunk Community!

Splunk Enterprise Security 8.0.2 Availability: On cloud and On-premise!

A few months ago, we released Splunk Enterprise Security 8.0 for our cloud customers. Today, we are excited to ...

Logs to Metrics

Logs and Metrics Logs are generally unstructured text or structured events emitted by applications and written ...

Developer Spotlight with Paul Stout

Welcome to our very first developer spotlight release series where we'll feature some awesome Splunk ...