We are using a Dynatrace Managed environment and would like to automatically raise a problem when license consumption (for example, DDUs) is close to being exhausted.
I checked the available metrics but couldn’t find anything like ddu.used or hostunits.used. I did see some metrics such as billing.ddu.log.total, but for DDUs there are also metrics and traces that need to be considered in the calculation, not just logs.
Is there a way to monitor the overall license consumption across all DDU categories?
Can we set up alerting or problem generation for approaching license limits in Dynatrace Managed?
If there are no direct metrics, what would be the recommended approach to achieve this?
Any advice or best practices would be greatly appreciated.
I do not know any way to alert automatically in Managed about that. I would say review before dashboard to checking trend, and compare to limit your license has.-
For these purposes we developed an Extension 2.0 which creates metrics per Dynatrace environment and you can then alert using Metric events. It scrapes the Cluster API and writes metrics.
If I understand correct you suggest to create a custom extension which calls API to collect the license information and the sent a custom event via v2/events/ingest?
I searched in the swagger but can’t find API to get licenses - I see only v1/config/clusterid and v1/clusterversion nothing more in v1, v2 and config APIs connected to cluster or license.
Mark’s answer is also valid if you need it for a single environment. We had a requirement to alert on DDU consumption for two environments together, which is not possible with metrics just from a single environment.
with requests.get(f"{DT_CLUSTER_URL}/api/cluster/v2/license/consumption", headers=headers, stream=True, verify=VERIFY_SSL) as response:
...
with inner_zip.open(json_filename) as json_file:
with io.TextIOWrapper(json_file, encoding="utf-8") as text_file:
data = json.load(text_file)
env_entries = data.get("environmentBillingEntries", [])
for env in env_entries:
# Sum DDUs
for pool in env.get("davisDataUnits", []):
total_ddus += safe_float(pool.get("total", 0))
# Count hosts
host_usages = env.get("hostUsages", [])
total_hostunits += len(host_usages)
# Count DEMs (based on agent usages per host)
for host in host_usages:
total_dems += len(host.get("agentUsages", []))
print("Aggregated License Consumption (from license start until now):")
print(f" Total DDUs used: {total_ddus:.2f}")
print(f" Total DEMs used: {total_dems}")
print(f" Total Host Units used: {total_hostunits}")
I saw that there are two environments in this Managed Dynatrace Cluster. The information on the /cmc shows aggregating result for the current consumed/available licenses and that’s why I’m also aggregating the results. The problem is that the results which I get completely differs from these shown in the /cmc:
Aggregated License Consumption (from license start until now):
Total DDUs used: 93747.71
Total DEMs used: 4428
Total Host Units used: 4424
In an upcoming release, we will also provide cluster billing metrics that allow you to define alerts in the self-monitoring environment when your license units are running low. Stay tuned!
We will also provide a dashboard for tracking the cluster license usage. See this preview: