Database Monitoring

Database Monitoring (DBM) surfaces slow and resource-intensive queries from your databases. The Datadog Agent collects query samples and execution metrics, and Moneat displays them in a single view so you can quickly identify performance bottlenecks.

Availability

Database Monitoring is included on standard plans. For self-hosted builds that use module licensing, enable the datadog module to expose the database monitoring dashboard.

Prerequisites

  • A supported database (PostgreSQL, MySQL, SQL Server, or Oracle)
  • The Datadog Agent deployed on a host with network access to the database (see Agent Setup)
  • For self-hosted module-licensed builds, the datadog module enabled

Enable database monitoring

PostgreSQL

Create a configuration file for the PostgreSQL integration:

YAML
# /etc/datadog-agent/conf.d/postgres.d/conf.yaml
init_config:

instances:
 - host: localhost
    port: 5432
    username: datadog
    password: "<PASSWORD>"
    dbm: true
    collect_activity: true

Create a dedicated monitoring user in your database:

SQL
CREATE USER datadog WITH PASSWORD '<PASSWORD>';
GRANT pg_monitor TO datadog;
GRANT SELECT ON pg_stat_activity TO datadog;

MySQL

YAML
# /etc/datadog-agent/conf.d/mysql.d/conf.yaml
init_config:

instances:
 - host: localhost
    port: 3306
    username: datadog
    password: "<PASSWORD>"
    dbm: true

After adding the configuration, restart the agent:

Shell
docker restart dd-agent

Dashboard view

Navigate to Monitoring → Databases to see your collected query data. The dashboard shows:

ColumnDescription
QueryThe SQL statement (normalized to remove literal values)
HostThe database host the query was executed on
DatabaseThe specific database name
DurationQuery execution time in milliseconds
TimestampWhen the query was sampled

Queries are sorted by duration so the slowest queries appear first, making it easy to spot performance issues.

Use cases

  • Identify slow queries - Find queries taking the longest to execute and optimize them with indexes or query rewrites
  • Track query patterns - See which queries run most frequently and consume the most resources
  • Correlate with errors - Cross-reference slow database queries with application errors in Moneat's error tracking
Set dbm: true in the agent configuration to enable deep query monitoring. Without this flag, only basic connection metrics are collected.