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:
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.
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.
IMPORTANT: If the metric expression is displayed as a single value (Single value, table, etc) , please include :fold aggregation directly in the expression. This is needed due to the way Dynatrace queries metrics for single value charts. (infinite resolution).
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.
You can use this approach also in Data Explorer, for Metric event definitions or elsewhere you can utilize metric expressions!
Extension for generating business hours metric
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 define your business hours using a shared calendar and the extension will generate the metric accordingly.
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.
Using calendar, you can freely define your business hours and exceptions. For example, define 8x5 as a recurring event in your calendar and just delete the occurrences, for example, for holidays.
Changelogv0.0.16
- Improved logging
v0.0.15
- Added support for generating negative levels
- Extension Dashboard with simple how-to and generated business hours metrics
v0.0.12
- Initial public version



