For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/opentelemetry/integrations/mysql_metrics.md. A documentation index is available at /llms.txt.

Overview

OpenTelemetry MySQL metrics in a MySQL dashboard

The MySQL receiver allows for collection of MySQL metrics and access to the MySQL Overview dashboard. Configure the receiver according to the specifications of the latest version of the mysqlreceiver.

For more information, see the OpenTelemetry project documentation for the MySQL receiver.

Setup

To collect MySQL metrics with OpenTelemetry for use with Datadog:

  1. Configure the MySQL receiver in your OpenTelemetry Collector configuration.
  2. Optionally, configure the host metrics receiver if your OpenTelemetry Collector is running on the same server as your MySQL database.
  3. Optionally, configure the file log receiver if your OpenTelemetry Collector is running on the same server as your MySQL database.
  4. Configure service pipelines.
  5. Ensure the OpenTelemetry Collector is configured to export to Datadog.

MySQL receiver

receivers:
  mysql/mysql-host-1:
    endpoint: "<HOST>:<PORT>"
    username: "<USERNAME>"
    password: "<PASSWORD>"
    collection_interval: 10s
    metrics:
      mysql.connection.count:
        enabled: true
      mysql.connection.errors:
        enabled: true
      mysql.commands:
        enabled: true
      mysql.query.slow.count:
        enabled: true
      mysql.max_used_connections:
        enabled: true

processors:
  resource/mysql-host-1:
    attributes:
      - action: insert
        key: datadog.host.name
        value: <HOST>
  transform/mysql-host-1:
    metric_statements:
      - convert_sum_to_gauge() where metric.name == "mysql.locks"
  cumulativetodelta: {}
  deltatorate:
    metrics:
      - mysql.connection.count
      - mysql.commands
      - mysql.operations
      - mysql.query.slow.count
      - mysql.connection.errors
      - mysql.log_operations
      - system.network.io

See the MySQL receiver documentation for detailed configuration options and requirements.

Host metrics receiver

receivers:
  hostmetrics:
    scrapers:
      load:
      cpu:
        metrics:
         system.cpu.utilization:
           enabled: true
      memory:
      network:

File log receiver

receivers:
  filelog:
    include:
      - <PATH_TO_YOUR_MYSQL_ERROR_LOG>
      - <PATH_TO_YOUR_MYSQL_LOG_FILE>
    operators:
      - type: json_parser
        parse_from: body
        timestamp:
          parse_from: attributes.timestamp
          layout: "%Y-%m-%dT%H:%M:%SZ"

processors:
  transform/logs:
    log_statements:
      - context: resource
        statements:
          - set(attributes["datadog.host.name"], "<HOST>")
          - set(attributes["datadog.log.source"], "mysql")

  batch: {}

Service pipelines

service:
  pipelines:
    metrics/mysql-host-1:
      receivers: [mysql/mysql-host-1]
      exporters: [datadog/exporter]
      processors: [resource/mysql-host-1,cumulativetodelta,deltatorate,transform/mysql-host-1]

Add hostmetrics and filelog receiver if you configured them, for example:

      receivers: [mysql/mysql-host-1,hostmetrics,filelog]

Data collected

OTELDESCRIPTIONFILTER
mysql.buffer_pool.data_pagesThe number of data pages in the InnoDB buffer pool.status: dirty
mysql.buffer_pool.operationsThe number of operations on the InnoDB buffer pool.operation: read_ahead
mysql.buffer_pool.operationsThe number of operations on the InnoDB buffer pool.operation: read_ahead_evicted
mysql.buffer_pool.operationsThe number of operations on the InnoDB buffer pool.operation: read_ahead_rnd
mysql.buffer_pool.operationsThe number of operations on the InnoDB buffer pool.operation: read_requests
mysql.buffer_pool.operationsThe number of operations on the InnoDB buffer pool.operation: reads
mysql.buffer_pool.operationsThe number of operations on the InnoDB buffer pool.operation: wait_free
mysql.buffer_pool.operationsThe number of operations on the InnoDB buffer pool.operation: write_requests
mysql.buffer_pool.page_flushesThe number of requests to flush pages from the InnoDB buffer pool.
mysql.buffer_pool.pagesThe number of pages in the InnoDB buffer pool.kind: data
mysql.buffer_pool.pagesThe number of pages in the InnoDB buffer pool.kind: free
mysql.buffer_pool.usageThe number of bytes in the InnoDB buffer pool.
mysql.buffer_pool.usageThe number of bytes in the InnoDB buffer pool.status: dirty
mysql.client.network.ioThe number of transmitted bytes between server and clients.kind: received
mysql.client.network.ioThe number of transmitted bytes between server and clients.kind: sent
mysql.commandsThe number of times each type of command has been executed.command: select
mysql.commandsThe number of times each type of command has been executed.command: update
mysql.commandsThe number of times each type of command has been executed.command: delete
mysql.commandsThe number of times each type of command has been executed.command: insert
mysql.connection.countThe number of connection attempts (successful or not) to the MySQL server.
mysql.connection.errorsErrors that occur during the client connection process.error: aborted
mysql.double_writesThe number of writes to the InnoDB doublewrite buffer.kind: pages_written
mysql.double_writesThe number of writes to the InnoDB doublewrite buffer.kind: writes
mysql.handlersThe number of requests to various MySQL handlers.kind: write
mysql.handlersThe number of requests to various MySQL handlers.kind: update
mysql.handlersThe number of requests to various MySQL handlers.kind: rollback
mysql.handlersThe number of requests to various MySQL handlers.kind: read_rnd_next
mysql.handlersThe number of requests to various MySQL handlers.kind: read_rnd
mysql.handlersThe number of requests to various MySQL handlers.kind: read_prev
mysql.handlersThe number of requests to various MySQL handlers.kind: read_first
mysql.handlersThe number of requests to various MySQL handlers.kind: read_key
mysql.handlersThe number of requests to various MySQL handlers.kind: prepare
mysql.handlersThe number of requests to various MySQL handlers.kind: delete
mysql.handlersThe number of requests to various MySQL handlers.kind: commit
mysql.handlersThe number of requests to various MySQL handlers.kind: read_next
mysql.joinsThe number of joins that perform table scans.kind: scan
mysql.joinsThe number of joins that perform table scans.kind: range_check
mysql.joinsThe number of joins that perform table scans.kind: full_range
mysql.joinsThe number of joins that perform table scans.kind: range
mysql.joinsThe number of joins that perform table scans.kind: full
mysql.locksThe number of MySQL locks.kind: immediate
mysql.locksThe number of MySQL locks.kind: waited
mysql.log_operationsThe number of InnoDB log operations.operation: waits
mysql.log_operationsThe number of InnoDB log operations.operation: write_requests
mysql.log_operationsThe number of InnoDB log operations.operation: writes
mysql.log_operationsThe number of InnoDB log operations.operation: fsyncs
mysql.max_used_connectionsMaximum number of connections used simultaneously since the server started.
mysql.operationsThe number of InnoDB operations.operation: fsyncs
mysql.operationsThe number of InnoDB operations.operation: writes
mysql.operationsThe number of InnoDB operations.operation: reads
mysql.page_operationsThe number of InnoDB page operations.operation: created
mysql.page_operationsThe number of InnoDB page operations.operation: read
mysql.page_operationsThe number of InnoDB page operations.operation: written
mysql.query.slow.countThe number of slow queries.
mysql.replica.time_behind_sourceThis field is an indication of how “late” the replica is.
mysql.row_locksThe number of InnoDB row locks.kind: waits
mysql.row_locksThe number of InnoDB row locks.
mysql.row_operationsThe number of InnoDB row operations.operation: deleted
mysql.row_operationsThe number of InnoDB row operations.operation: inserted
mysql.row_operationsThe number of InnoDB row operations.operation: read
mysql.row_operationsThe number of InnoDB row operations.operation: updated
mysql.sortsThe number of MySQL sorts.kind: merge_passes
mysql.sortsThe number of MySQL sorts.kind: range
mysql.sortsThe number of MySQL sorts.kind: rows
mysql.sortsThe number of MySQL sorts.kind: scan
mysql.table_open_cacheThe number of hits, misses or overflows for open tables cache lookups.status: hit
mysql.table_open_cacheThe number of hits, misses or overflows for open tables cache lookups.status: miss
mysql.threadsThe state of MySQL threads.kind: cached
mysql.threadsThe state of MySQL threads.kind: connected
mysql.threadsThe state of MySQL threads.kind: created
mysql.threadsThe state of MySQL threads.kind: running
mysql.tmp_resourcesThe number of created temporary resources.resource: files
mysql.tmp_resourcesThe number of created temporary resources.resource: disk_tables
mysql.tmp_resourcesThe number of created temporary resources.resource: tables

For the full mapping between OpenTelemetry and Datadog metric names, see OpenTelemetry Metrics Mapping.

Further reading

Additional helpful documentation, links, and articles: