• /
  • EnglishEspañolFrançais日本語한국어Português
  • EntrarComeçar agora

Install & configure NRDOT for MySQL monitoring with Self-hosted

|View as Markdown (English)

Set up MySQL monitoring using the NRDOT Collector on self-hosted environments including physical servers, virtual machines, and standalone installations.

Prerequisites

Before you install, make sure you have:

For supported MySQL versions, required grants, and performance_schema requirements, see Compatibility and prerequisites.

Set up NRDOT Collector

Install the NRDOT Collector on your system:

Configure database user

Create a monitoring user with the necessary privileges for your MySQL database instance.

  • To create a monitoring user, run the following command in your MySQL database:

    CREATE USER '<YOUR_DB_USERNAME>'@'%' IDENTIFIED BY '<YOUR_DB_PASSWORD>';
  • To collect query samples and top queries, grant the following privileges to the monitoring user:

    GRANT SELECT ON performance_schema.* TO '<YOUR_DB_USERNAME>'@'%';
    GRANT SELECT ON *.* TO '<YOUR_DB_USERNAME>'@'%';
    GRANT REPLICATION CLIENT ON *.* TO '<YOUR_DB_USERNAME>'@'%';
    GRANT PROCESS ON *.* TO '<YOUR_DB_USERNAME>'@'%';
  • (Optional) To view the wait-time data in New Relic platform, grant the following privileges to the monitoring user:

    GRANT UPDATE ON performance_schema.setup_consumers TO '<YOUR_DB_USERNAME>'@'%';
  • (Optional) To verify the connection and grants, run:

    bash
    $
    mysql -h <YOUR_DB_HOST> -P <YOUR_DB_PORT> -u <YOUR_DB_USERNAME> -p -e "SELECT 1;"

    If the command completes without an error, the monitoring user, host, and port are all correct.

Configure NRDOT Collector

Configure the NRDOT Collector with your MySQL-specific settings.

This configuration focuses on essential MySQL monitoring with the nrmysql receiver only.

full configuration

This baseline configuration captures essential metrics. To see the complete metric catalog, refer to the configuration reference.

  1. Create a configuration file named mysql-config.yaml:

    bash
    $
    sudo nano /etc/nrdot-collector/mysql-config.yaml
  2. Add the following configuration to the mysql-config.yaml file you created in the previous step.

receivers:
nrmysql:
endpoint: "<YOUR_DB_HOST>:<YOUR_DB_PORT>"
transport: tcp
username: "<YOUR_DB_USERNAME>"
password: "<YOUR_DB_PASSWORD>"
allow_native_passwords: true
collection_interval: 15s
initial_delay: 1s
explain_mode: procedure
statement_events:
digest_text_limit: 4096
time_limit: 24h
limit: 500
query_sample_collection:
max_rows_per_query: 100
allowed_comment_keys: [nr_service_guid]
top_query_collection:
lookback_time: 60
max_query_sample_count: 5000
top_query_count: 200
collection_interval: 60s
query_plan_cache_size: 1000
query_plan_cache_ttl: 1h
allowed_comment_keys: [nr_service_guid]
events:
db.server.query_sample:
enabled: true
db.server.top_query:
enabled: true
db.server.query_plan:
enabled: true
resource_attributes:
db.system.version:
enabled: true
metrics:
mysql.query.count:
enabled: true
mysql.query.slow.count:
enabled: true
mysql.commands:
enabled: true
mysql.innodb.data_file.io:
enabled: true
processors:
batch:
exporters:
otlp/newrelic:
endpoint: "<YOUR_NEWRELIC_OTLP_ENDPOINT>"
headers:
api-key: "<YOUR_NEWRELIC_LICENSE_KEY>"
compression: gzip
retry_on_failure:
enabled: true
initial_interval: 5s
max_interval: 30s
max_elapsed_time: 300s
service:
pipelines:
metrics:
receivers: [nrmysql]
processors: [batch]
exporters: [otlp/newrelic]
logs:
receivers: [nrmysql]
processors: [batch]
exporters: [otlp/newrelic]

Dica

This configuration omits the optional database and tls fields. By default, the receiver monitors every database the monitoring user can access, and connects without TLS. To monitor a specific database, or to enable TLS (required for most Amazon RDS/Aurora instances), see Enable detailed insights.

Configuration parameters

The following table describes the key configuration parameters for the nrmysql receiver:

ParameterDescription
<YOUR_DB_HOST>Enter your MySQL host name or IP address.
<YOUR_DB_PORT>Enter your MySQL port number. The default value is 3306.
<YOUR_DB_USERNAME>Enter the username of the monitoring user you created in Configure database user.
<YOUR_DB_PASSWORD>Enter the password of the monitoring user you created in Configure database user.
<YOUR_NEWRELIC_OTLP_ENDPOINT>Enter the New Relic OTLP endpoint. For more information, see New Relic OTLP endpoints.
<YOUR_NEWRELIC_LICENSE_KEY>Enter your New Relic license key.
transportDefault value is set to tcp to connect over the network. If your NRDOT Collector runs on the same host as MySQL, use unix to connect through a Unix domain socket instead.
collection_intervalEnter the interval between metric scrapes. Default: 15s.
explain_modeDefault value is set to inline. Set the value to procedure to collect query plans for write statements without granting DML privileges to the monitoring user. See Query plans for write statements.

Validate NRDOT Collector configuration

  1. Update the config path to point to your new mysql-config.yaml file:

    bash
    $
    sudo sed -i 's|OTELCOL_OPTIONS="--config=/etc/nrdot-collector/config.yaml"|OTELCOL_OPTIONS="--config=/etc/nrdot-collector/mysql-config.yaml"|' /etc/nrdot-collector/nrdot-collector.conf
  2. Validate the NRDOT Collector configuration to ensure it's correctly formatted and will work properly:

    bash
    $
    sudo /usr/bin/nrdot-collector validate --config=/etc/nrdot-collector/mysql-config.yaml

Dica

You can also:

  • Configure multiple receivers: To monitor multiple MySQL instances from one collector.
  • Link your MySQL database with APM: To correlate your application performance with database operations. This allows you to see exactly which applications are generating specific database workloads.
  • Set up secret management: To securely manage sensitive information, such as database credentials. This helps to enhance the security of your monitoring setup by avoiding hardcoding sensitive data in configuration files.

Restart NRDOT Collector

After updating your configuration, restart the NRDOT Collector service:

bash
$
sudo systemctl restart nrdot-collector

Dica

Always restart the NRDOT Collector service after making configuration changes to ensure the new settings take effect.

To verify that the collector is running properly, check the service status:

bash
$
sudo systemctl status nrdot-collector

Find and use your data

Once your data is being collected, you can access comprehensive MySQL database monitoring through the New Relic UI.

To find your MySQL database entity in New Relic:

  1. Go to https://one.newrelic.com > All Capabilities > Databases.

  2. From the Entity type dropdown, select MySQL instance, then click Apply.

  3. Select your MySQL database from the list of entities.

    After setting up MySQL database monitoring with NRDOT:

Troubleshooting guide

Learn how to troubleshoot common issues with MySQL monitoring.

Metrics reference

Learn about the available metrics collected by the NRDOT Collector.

Instrumentation in RDS environments

Learn how to set up MySQL monitoring in RDS environments with New Relic.

Copyright © 2026 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.