Dynatrace captures every database call your services make as a span and surfaces the aggregated data in
Services. This tutorial shows you how to go beyond the built-in views: use Dynatrace Query Language (DQL) to analyze query performance, track call volume, and identify unmonitored databases, as well as navigate database dependencies directly in
Services.
For an explanation of how database calls are captured, see Database query monitoring in Services.
This tutorial is designed for developers, SREs, and platform engineers who need to investigate database performance issues, understand which databases their services depend on, build database-centric dashboards, or identify gaps in database monitoring coverage.
By the end of this tutorial, you'll know which databases your services depend on, how to surface slow or failing queries, and which databases aren't yet covered by monitoring.
In this tutorial, you'll learn how to:
Services.
Services with the minimal set of permissions
Notebooks or
Dashboards to run DQL queriesBasic familiarity with DQL is helpful but not required, as DQL examples are provided throughout the documentation.
ServicesAccess the Database queries view and Service Map in
Services to investigate database dependencies, analyze query performance, and discover databases that aren't yet monitored.
To get a list of all queries executed by a particular service
Services > Explorer.The database queries of this service are listed, along with insights into query count per minute, query duration, and error rate.
To get a list of all queries executed across all your services
Go to
Services > Explorer.
In the sidebar panel on the left, select Database queries.
Optional In the Type to filter field on top of the service list, use the db.system and db.namespace attributes to filter for the relevant database.
For example, enter db.system = mysql AND db.namespace = memberships to view the list of queries made by the MySQL database named memberships.
The Database queries view provides a cross-service perspective.
Databases for a monitored databaseWhen a database is monitored and linked to a Dynatrace entity, you can navigate directly from the Database queries view in
Services to its full details in
Databases.
To open the database details in
Databases
Go to
Services > Explorer (Early Access).
In the sidebar panel on the left, select Database queries.
Select (Action menu) >
View in Databases in the row (the last column where you see icons).
The corresponding database instance is opened in
Databases.
You can also go to the database-related apps from the Service Map in
Services. For details, see Drill down to traces, logs, and more.
To identify unmonitored databases using the Service Map in
Services
Services > Explorer (Early Access).
Add database instance and follow the guided hints to activate a database extension or cloud monitoring.You can also find unmonitored databases using the DQL query based on the dt.service.database.query.count metric. For details, see Discover unmonitored databases using query count metric.
Run the provided DQL queries in
Notebooks or create database-centric dashboards in
Dashboards to analyze database query performance, track call volume by database entity, and discover unmonitored databases.
Use the following DQL query to show the slowest or most error-prone queries across a service or your entire environment.
fetch spans| filter span.kind == "client" and isNotNull(db.system)| summarize totalCalls = count(),avgDuration = avg(duration),errorRate = countIf(status.code == "ERROR") / count() * 100,by: { dt.smartscape.service, db.system, db.namespace, db.query.text, db.operation.name }| sort avgDuration desc
Run the following DQL query to see database entities a service communicates with, including the call volume over time. The db_entity field shows either the ID of a monitored AWS RDS or MySQL database or states if the database is unmonitored.
timeseries calls = sum(dt.service.database.query.count),by: { dt.smartscape.service, db.system, db.namespace,dt.smartscape.aws_rds_dbinstance,dt.smartscape.db_instance_mysql}| fieldsAdd db_entity = coalesce(dt.smartscape.aws_rds_dbinstance, dt.smartscape.db_instance_mysql, "Unmonitored database")| fieldsRemove dt.smartscape.aws_rds_dbinstance, dt.smartscape.db_instance_mysql
As the dt.service.database.query.count metric is emitted for every database a service calls (regardless of whether it's monitored or not), you can use it to identify coverage gaps in database monitoring.
Use the following DQL query to retrieve databases referenced in traces but not backed by a monitored entity, ranked by the number of services calling them.
timeseries calls = sum(dt.service.database.query.count),by: { dt.smartscape.service, db.system, db.namespace,dt.smartscape.aws_rds_dbinstance,dt.smartscape.db_instance_mysql}| fieldsAdd db_entity = coalesce(dt.smartscape.aws_rds_dbinstance, dt.smartscape.db_instance_mysql)| filter isNull(db_entity)| summarize callingServices = count(), by: { db.system, db.namespace }| sort callingServices desc
You can rely on this DQL query to prioritize which databases to onboard first: the databases called by the most services represent the highest-impact monitoring gaps. For such databases, activate a matching database extension or cloud monitoring integration to create the entity and link it into the topology.
You can also uncover unmonitored databases using the Service Map in
Services. For details, see Discover and onboard unmonitored databases with Service Map.
You've completed this tutorial. You now know how to investigate database dependencies and performance using DQL and
Services. You can:
Services, from a per-service view to a cross-service perspective.
Databases for deeper analysis.As your environment evolves, revisit the DQL queries in this tutorial to adapt them to new database technologies or broader coverage requirements. To learn more about the underlying data model, see Database query monitoring in Services.
Services