[TP] Lab - Creating and using Entity Selectors


In this lab, we will learn how to create entity selectors, test them via the API, and then use them to precisely define the scope of a Management Zone.

What you will learn in this TP :
  • Validate access to the Dynatrace cluster
  • Generate an API Token with the correct rights
  • Understand the overall structure of an Entity Selector
  • Master basic selection criteria
  • Write a complex Entity Selector
  • Know how to target specific entities with tags
  • Test an Entity Selector query via the REST API v2
  • Dynamically validate the result returned by Dynatrace
  • Create a Management Zone in the Dynatrace console
  • Apply an Entity Selector type rule to a management zone

Prerequisites


What you will learn in this section :
  • Validate access to the Dynatrace cluster
  • Generate an API Token with the correct rights

You must have a Dynatrace cluster (SaaS or Managed) with agents deployed, as well as an Access Token (API Token) with entity read rights (`entities.read`).

Review of Syntax and Key Operators


What you will learn in this section :
  • Understand the overall structure of an Entity Selector
  • Master basic selection criteria

An Entity Selector is a string used to filter Dynatrace entities. It consists of selection criteria separated by commas (which act as a logical AND operator).
Tip: You can use the NOT operator to exclude entities, for example type("HOST"),not(tag("ENV:DEV")).
  1. Main criteria
    Here are the most used operators to target your entities:
    • type(): Filter by entity type (e.g., HOST, SERVICE, APPLICATION).
    • tag(): Filter by tag. Accepts the key:value format (e.g., tag("ENV:PROD")).
    • entityName(): Filter by entity name, very useful with wildcards like *.

Creating an Entity Selector


What you will learn in this section :
  • Write a complex Entity Selector
  • Know how to target specific entities with tags

The goal is to isolate a subset of your infrastructure. You must write an 'entity selector' to target only machines (HOST) that have the tag 'ENV=PROD'.
Golden rule of design (Scaling): For each selection rule, you must imperatively define either an Entity ID (unique identifier of the entity) or an Entity type.

Best practice: The use of fixed Entity IDs is to be avoided in production as it is too specific and rigid. To ensure large-scale management compatible with the dynamic lifecycle of your infrastructures, exclusively use the Entity type combined with dynamic attributes or tags.
  1. Selector syntax
    Write the query to select these entities.

Validation via API


What you will learn in this section :
  • Test an Entity Selector query via the REST API v2
  • Dynamically validate the result returned by Dynatrace

Before applying a rule in a Management Zone, it is highly recommended to test it. You must use the Dynatrace API (v2) to check which entities are returned by your selector.
Tip: URL encoding of your Entity Selector is essential in your cURL requests. For example, quotes " become %22.
  1. API Request
    Find the cURL command to query the '/api/v2/entities' endpoint with your 'entity selector'.

Creating the Management Zone


What you will learn in this section :
  • Create a Management Zone in the Dynatrace console
  • Apply an Entity Selector type rule to a management zone

Now that your 'entity selector' is validated, you must use it to create a new management zone named 'PROD_ZONE'.
  1. Configuration in the console
    Indicate the steps to create the Management Zone based on this selector in the Dynatrace interface.

Difficulty level: (3/5)

Recommended Articles

License consumption types

Understand the evolution of billing in Dynatrace: the difference between the ...

Grafana Alloy: The importance of Self-Monitoring

Discover why and how to configure Grafana Alloy so that it monitors itself, c...

Grafana Alloy: Understanding and exploiting the User Interface (UI)

Discover how to enable, secure, and use Grafana Alloy's built-in web interfac...

Grafana Alloy: Introduction and Architecture

Discover the fundamental concepts of Grafana Alloy, the transition from the s...

Grafana Alloy: Syntax and Configuration (Alloy Language: River)

As part of a Grafana training or observability training, master the declarati...

Grafana Alloy: Metrics Collection (Prometheus & Ecosystem)

Learn how to configure Grafana Alloy to collect, transform, and forward metri...

Grafana Alloy: Log Management with Loki

Discover how to configure Grafana Alloy to read log files, journald, or netwo...

Grafana Alloy: Trace Management with Tempo

Dive into distributed trace processing. Learn how to ingest OTLP, Jaeger, or ...

Grafana Alloy: Continuous Profiling with Pyroscope

Discover how to configure continuous profiling in your environments using Gra...

Grafana Alloy: Advanced Deployment and Clustering

Learn how to manage large-scale Grafana Alloy deployments. Configure Clusteri...

Grafana Assistant: AI at the service of observability

Discover Grafana Assistant, the artificial intelligence integrated into Grafa...

Grafana Alloy vs Dynatrace ActiveGate: Which to choose?

Comparison between Grafana Alloy and Dynatrace ActiveGate. Understand the fun...

Course Glossary

AIOps (Artificial Intelligence for IT Operations)

The use of artificial intelligence and machine learning to automate and improve IT operations (e.g., anomaly detection, reducing alert noise).

OpenTelemetry

An open source framework providing standards, APIs, and SDKs to collect and export observability data (traces, metrics, logs) in an agnostic way.