# Retrieve license consumption for a longer period of time

**URL:** <https://community.dynatrace.com/t/retrieve-license-consumption-for-a-longer-period-of-time/37095>\
**Category:** Dynatrace API\
**Tags:** licensing, dynatrace-api\
**Created:** [November 1, 2022, 7:50pm UTC](https://community.dynatrace.com/t/retrieve-license-consumption-for-a-longer-period-of-time/37095 "2022-11-01T19:50:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulito](https://avatars.discourse-cdn.com/v4/letter/p/e19adc/32.png) [@paulito](https://community.dynatrace.com/u/paulito)\
**Post date:** [November 1, 2022, 7:50pm UTC](https://community.dynatrace.com/t/retrieve-license-consumption-for-a-longer-period-of-time/37095/1 "2022-11-01T19:50:53Z")

</div>

I’ve read the&nbsp;[documentation](https://www.dynatrace.com/support/help/setup-and-configuration/dynatrace-managed/cluster-api/cluster-api-v2/license/get-retrieve-license-consumption)&nbsp;for retrieving license consumption via API but the endpoint “/api/cluster/v2/license/consumption/hour” only retrieves the latest hour.

Is there a way to edit the URL to retrieve data for the last say week/month/year?

In the example provided in the documentation, you can specify a starting timestamp. Are there other parameters you can filter for?

I know I can export the data but that’s in a zip file and I prefer to have updated data.

PS: I’m a beginner at this stuff any help is appreciated

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [November 1, 2022, 7:58pm UTC](https://community.dynatrace.com/t/retrieve-license-consumption-for-a-longer-period-of-time/37095/2 "2022-11-01T19:58:18Z")

</div>

What is your scope? are you looking for overall consumption? Hosts/entities individually?

---

<div class="post-metadata">

**Author:** ![paulito](https://avatars.discourse-cdn.com/v4/letter/p/e19adc/32.png) [@paulito](https://community.dynatrace.com/u/paulito)\
**Post date:** [November 1, 2022, 8:00pm UTC](https://community.dynatrace.com/t/retrieve-license-consumption-for-a-longer-period-of-time/37095/3 "2022-11-01T20:00:36Z")

</div>

Individual entity consumption

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [November 1, 2022, 8:58pm UTC](https://community.dynatrace.com/t/retrieve-license-consumption-for-a-longer-period-of-time/37095/4 "2022-11-01T20:58:29Z")

</div>

If you are on managed - the most precise method is to use the data in the zip file.

For individual environment or saas I use this&nbsp;[script](https://github.com/Alanata-a-s/Dynatrace-License-Reporting-Scripts)&nbsp;to push license metric bound to individual hosts. It uses the /api/v1/oneagents API to pull consumption and then push the metric value back to the environment. Then you have the license metric in your environment and you can report consumption simply using Data Explorer by filtering on hosts or management zones as you prefer.

Also, the recent version notifies you if some of your hosts are disabled due to overconsumption.

---

<div class="post-metadata">

**Author:** ![STiAT](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@STiAT](https://community.dynatrace.com/u/STiAT)\
**Post date:** [November 3, 2022, 1:30am UTC](https://community.dynatrace.com/t/retrieve-license-consumption-for-a-longer-period-of-time/37095/5 "2022-11-03T01:30:18Z")

</div>

The consumption data in the zip file is actually not correct. It often outputs wrong hostunit / consumption values, or at least it used to. That’s one of the reasons we couldn’t use it. In a support case I was told I am not to rely on that data - so I would not.

Same with the consumedHostUnits value in the API, this often does not reflect the real value. That was an issue since we have to get the costs of individual hosts for our actual accounting.

That may be fixed by now, it was a year ago, but that was an issue for us internally.

We ended up writing a script taking the paasMemoryLimit / zosTotalPhysicalMemory and applying the calculations ourselves depending on the mode the hosts (infrastructure, fullstack).

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [November 3, 2022, 7:16am UTC](https://community.dynatrace.com/t/retrieve-license-consumption-for-a-longer-period-of-time/37095/6 "2022-11-03T07:16:00Z")

</div>

We never had issues with either the zip file or the API (OneAgent API). Both are reporting correct host units. I’d stay away from calculating that on your own unless you know the details such as memory tolerance. (Yes there is some tolerance).

---

<div class="post-metadata">

**Author:** ![Ishwar\_Jadhav](https://avatars.discourse-cdn.com/v4/letter/i/278dde/32.png) [@Ishwar\_Jadhav](https://community.dynatrace.com/u/Ishwar_Jadhav)\
**Post date:** [December 27, 2022, 9:46am UTC](https://community.dynatrace.com/t/retrieve-license-consumption-for-a-longer-period-of-time/37095/7 "2022-12-27T09:46:29Z")

</div>

I am looking for Hosts/entities individually in the SAAS environment.

---

<div class="post-metadata">

**Author:** ![STiAT](https://avatars.discourse-cdn.com/v4/letter/s/bc8723/32.png) [@STiAT](https://community.dynatrace.com/u/STiAT)\
**Post date:** [January 28, 2023, 12:40am UTC](https://community.dynatrace.com/t/retrieve-license-consumption-for-a-longer-period-of-time/37095/8 "2023-01-28T00:40:39Z")

</div>

We didn’t, and I even have a support call which confirms that, even with a statement made we are not to rely on that data. I’d have to re-check that though if that situation changed. We actually implemented the calculation ourselves because of that.
