---
title: Configure MySQL Database monitoring with OpenTelemetry Collector (CNCF)
source: https://docs.newrelic.com/docs/opentelemetry/db360/mysql/cncf
---

You can use the OpenTelemetry Collector Contrib for MySQL to monitor your instance. The OpenTelemetry Collector Contrib is a community-supported project that collects telemetry data from MySQL and sends it to New Relic.

By default, the OpenTelemetry Collector Contrib collects limited metrics from MySQL. To send query performance, wait-event, session, and client metrics, you'll need to configure the OpenTelemetry Collector Contrib. This guide shows you how to configure it to collect advanced metrics from MySQL and send them to New Relic.

> #### 💡 NOTE
>
> This page covers the community `mysqlreceiver` shipped in the standard `otelcol-contrib` binary. If you're using New Relic's distribution (NRDOT), see [Self-hosted MySQL](https://docs.newrelic.com/docs/opentelemetry/db360/mysql/introduction) instead.

## Prerequisites [#prerequisites]

-   OpenTelemetry Collector Contrib (`otelcol-contrib`) installed and configured on your system. You can download the latest release from the [OpenTelemetry Collector releases](https://github.com/open-telemetry/opentelemetry-collector-releases/releases) page.
-   `performance_schema` enabled on the monitored MySQL/MariaDB instance (on by default since MySQL 5.6.6).

## Enable UI metrics [#enable]

You can enrich your New Relic platform experience by adding and enabling metrics in your `otelcol-contrib` configuration file. Using the configuration provided in this section, you can populate data for the following pages in the New Relic platform:

-   Overview
-   Query performance
-   Wait events
-   Sessions
-   Clients

**Enable Overview page metrics**

The Overview page displays a high-level view of your MySQL instance, including key metrics such as connections, buffer pool health, I/O, locking, table size, and slow-query rate. `mysql.commands` and `mysql.innodb.data_file.io` additionally power APM-DB linking, cross-navigation between an APM service's trace and its MySQL query activity.

To populate data for the Overview page in the New Relic platform, add the following configuration to your `otelcol-contrib` configuration file:

```yaml
receivers:
  mysql:
    metrics:
      mysql.query.count:
        enabled: true
      mysql.query.slow.count:
        enabled: true
      mysql.table.size:
        enabled: true
      mysql.commands:
        enabled: true
      mysql.innodb.data_file.io:
        enabled: true
```

**Enable Query performance, session, wait, and client metrics**

To populate data for the Query performance, Wait events, Sessions, and Clients pages:

-   Query performance: displays detailed information about the queries running on your MySQL instance in the following tabs:
    -   Normalized queries: displays execution count and average duration per query.
    -   Query samples: displays individual query executions including duration, wait type, database, DB user, and client host.
-   Wait events: displays wait type and wait time for statements that were waiting when sampled.
-   Sessions: displays information about the sessions connected to your MySQL instance, including session counts, session status, and individual session details.
-   Clients: displays information about the clients connected to your MySQL instance, including connected DB users and client host details.

Add the following configuration to your `otelcol-contrib` configuration file:

```yaml
receivers:
  mysql:
    events:
      db.server.query_sample:
        enabled: true
      db.server.top_query:
        enabled: true
      db.server.query_plan:
        enabled: true
    top_query_collection:
      lookback_time: 60
      max_query_sample_count: 1000
      top_query_count: 250
      collection_interval: 60s
    query_sample_collection:
      max_rows_per_query: 100
```

> #### ⚠️ IMPORTANT
>
> `db.server.query_plan` requires at least one of `db.server.top_query` or `db.server.query_sample` to also be enabled. Enabling it alone is a config validation error.

> #### 💡 NOTE
>
> The community MySQL receiver doesn't support stored-procedure collection or blocked-session detection. Sessions and Clients populate, but a blocked session's blocker isn't shown.

## Restart the OpenTelemetry Collector [#restart]

Restart the OpenTelemetry Collector to apply the configuration changes by running the following command:

```bash
sudo systemctl restart otelcol-contrib
```

## Related documentation [#related]

[Introduction to MySQL monitoring with NRDOT](https://docs.newrelic.com/docs/opentelemetry/db360/mysql/introduction)

Learn about all the available installation methods for MySQL monitoring with New Relic.
