cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PRO TIP - Business hours in Dynatrace for SLOs or metric events

Julius_Loman
DynaMight Legend
DynaMight Legend

It's quite common you don't provide your services 24x7, but you will run them also during non-business hours. Until business hours or business calendar features land into the Dynatrace product natively, it's possible to have a simple solution.

My approach below works for both Dynatrace Managed and SaaS.

For this feature, we will introduce a new metric - in this example business_hours which will provide just static values:

  • 1 during business hours
  • no value outside of business hours
  • value between 0 and 1 to decrease priorities during "low business hours" (if applicable to your case)

Of course, in your environment you probably have different business hours for different services, thus you will likely need to have a dimension for it, such as level (24x7, 10x5, etc... ). See example below:

Julius_Loman_0-1715850578739.png

 

For example, values for an 8x5 service level will look like this - a value of 1 between 9:00 and 17:00 for each day and no value outside these times.

Julius_Loman_2-1715850967716.png

 


Then in the SLO definition, you will simply use metric expression and multiply your desired metric with the business hours metric with the desired dimension representing your business hours, for example - for SLO on key requests:

 

(
    builtin:service.keyRequest.successes.server.rate:splitBy():auto
    * 
    business_hours:filter(and(or(eq(level,"8x5")))):splitBy():auto
):setUnit(Percent)

 

You may also commit the :setUnit transformation if you wish.

So in the example - during business hours, your original metric will be unaffected (multiplied by 1) and outside of business hours, you will have no value. In this example I've chosen a service level of 8x5, so the result will look like this - notice there are no values during the weekend of 16th and 17th March, and during Monday - Friday we have values only between 8:00 to 16:00 - representing 8x5.

 

Julius_Loman_1-1715850880208.pngYou can use this approach also in Data Explorer, for Metric event definitions or elsewhere you can utilize metric expressions!

If anyone is interested in an configurable EF2 extension providing such metric, reach out to me in the comments.

I've decided to publish the extension which allows you to create this business_hours metric based on cron-like schedules or also from a real calendar! (defined in Office 365, Google Calendar or any remote calendar available in ical format).  So you can actually define your business hours using a shared calendar and the extension will generate the metric accordingly.

Until this becomes available in the Dynatrace HUB, you can download the extension from here. You will need to import the CA certificate into your Dynatrace environment and upload the extension. See the README.md for details and links on how to share calendars from Office 365 or Google Calendar.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner
17 REPLIES 17

henk_stobbe
DynaMight Champion
DynaMight Champion

Hi  Julius,

 

(you have fans (-;) 

 

I am very interested in your Extension, can you share?

 

KR Henk

jiri_stefanek
Contributor

Hi Julius,

I am very interested.🙂

Hi @jiri_stefanek ,
can you please reach out to me directly at julius.loman (at) alanata.sk ?

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Hi Julius,

I just send you email.

Sent an email to you and looking forward for your reply mate. Thanks

hy
Observer

Hi Julius,

I just sent you an email directly as well. Hope to hear from you soon. Thank you!

hy
Observer

How did you create the custom metric that defines the different business hours for different services, thus you will likely need to have a dimension for it, such as level (24x7, 10x5, etc) in data explorer?

Julius_Loman
DynaMight Legend
DynaMight Legend

@hy  exactly. I've just replied to your email.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

elodie_lam
Dynatrace Organizer
Dynatrace Organizer

Hi Julius, this is great! I would also be interested in your extension please 🙂

Thank you!

AurelienGravier
DynaMight Champion
DynaMight Champion

Hi  @Julius_Loman ,

You are so inspiring ! I have created my own python extension to create the custom metric but I use declarative endpoints with a specific format :

AurelienGravier_1-1716285184703.png

 

However, I'm encountering a limitation when I define a new business opening hours, I have to wait 1 month before use it in my SLO definition otherwise my SLO is null before the custom metric dimension creation.

Did you experiment the same behaviour with your extension ?

 

Thank you.
Regards Aurelien.

Observability consultant - Dynatrace Associate/Pro/Services certified

I'm not sure if I got your question. The only issue I ever encountered is that you cannot post metrics back in time. So if you define a service level you can only use it for the calculating SLO from current time.so plan accordingly and define your service levels in advance. 

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

That's exactly the limitation I'm encountering : you cannot post metrics back in time.

Thank you for your confirmation.

Observability consultant - Dynatrace Associate/Pro/Services certified

Yes, that's impossible as metrics can be ingested only one hour back in time. This will likely change soon with Grail, but not for Managed.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

rgarzon1
Mentor

This could be one of the most clever tricks i seen, thank you for share it @Julius_Loman 

fuelled by coffee and curiosity.

Hi Julius,

Thanks a lot for your great post.
I also just sent you and email and like "hy" user I’m interested to know how to create the custom metric that defines the different business hours for different services.

Thanks again.
Regards,
Elena

germanriezu
Dynatrace Enthusiast
Dynatrace Enthusiast

Hi Julius, any ETA for this extension to be in the hub?

Thanks

@germanriezu unfortunately it was not accepted. Only Dynatrace signed extensions can be in the HUB as of today, no 3rd party extensions. So at least for upcoming months this will stay as it is. You can download it from the provided link including the certificate and use it as a 3rd party extension. In case of any issues, reach out back here in this thread.

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Featured Posts