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

Track Entity Counts per Entity Type using a Platform Workflow

bsnurka
Dynatrace Advisor
Dynatrace Advisor

Use Case

Dynatrace users, especially those who rely on generic entity types from integrations/extensions, can sometimes run into the default limit for the number of entities per entity type. When this limit is hit, no new entities are created for that type until the monitored entity periodic junk cleanup worker clears out old entities, allowing for new entities to be created.

While `dsfm:server.monitored_entities.entity_count_per_entity_type` metric exists, it can be inconsistent or miss some generic entities in its count.

To workaround this, I've created a Platform Workflow that uses the Dynatrace API to:

  1. Get all possible types of entity from the Environment (Such as "HOST" or "OS:SERVICE").
  2. Get the count of entities, per type, filtering out all entities that have a 0 count.
  3. Submit the entity types + count of entities into the entity.types.count.gauge metric key.

This allows us to track the per-entity-type count of entities, and optionally setup metric events and/or Davis Anomaly Detectors which can alert when a given entity type is close to reaching the limit.

Set it up

Download the Workflow Template from Github > Import it into the Platform Workflows App.

Create a new Access Token with the following scopes: metrics.ingest, metrics.write, entities.read

Set this Access Token up within Credential Vault. Copy the Credential ID once created.

  • Credential Type: Token
  • Credential Name: Enter a friendly name
  • Credential scope: Check the "AppEngine" box
  • Dynatrace apps with access: Enable the "Allow access without app context" slider
  • Token: Enter the Access Token which was created previously

Edit the following lines within each JS Code Tile on the Workflow to point to the created Credential Vault Entry - Replace CREDENTIALS_VAULT-XXXX with your Credential ID:

  • count_entity_types: Line 55
  • post_metric_data: Line 14

Optionally, change the trigger be to a schedule, or leave it as an on-demand trigger. I would suggest executing this workflow at most once every hour, so as to not overload the Dynatrace API Endpoints with numerous GET requests when the numbers likely won't change super frequently on an hourly basis.

 

Once we've had a successful workflow execution, we should then be able to setup Metric Events/Davis Anomaly Detectors which will alert when a given entity is close to breaching the limit. We can also use Data Explorer/Dashboards to chart the entity counts per type over time.

2 REPLIES 2

bsnurka
Dynatrace Advisor
Dynatrace Advisor

Examples of the data we can view once we have successful Workflow execution

bsnurka_0-1752597046431.png

 

p_devulapalli
Leader

@bsnurka Thank you for sharing the workflow, this is very helpful and something I have been looking for 👍

One issue I noticed is the .apps and .live is being replace with just " . " and this seems to throwing up an error . It worked for me once I updated it to replace only .apps with .live

p_devulapalli_0-1752803564206.png

p_devulapalli_1-1752803784433.png

Also, is there a way we can have entity_limit_per_entity_type also extracted  , this would help with understand the upper limits for breach.

Phani Devulapalli

Featured Posts