You can configure the NRDOT Collector to monitor multiple MySQL instances from one collector. This is useful if you have multiple MySQL databases running on different hosts or ports and want to collect metrics from all of them using a single NRDOT Collector instance.
Prerequisites
- NRDOT is installed and configured for your MySQL instances:
Add multi-receiver configuration
The following example shows how to configure the NRDOT Collector to monitor two MySQL instances using a multi-receiver configuration. The first instance carries the complete nrmysql configuration and acts as the anchor; the second instance inherits every shared setting through the YAML merge key and overrides only its own connection details. You can add more receivers as needed for additional MySQL instances.
receivers: # First MySQL instance (anchor - full config, instance2 inherits shared settings via merge key) nrmysql/instance1: &nrmysql-common endpoint: "<INSTANCE_1_HOST>:<INSTANCE_1_PORT>" transport: tcp username: "<INSTANCE_1_USERNAME>" password: "<INSTANCE_1_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
# Second MySQL instance (inherits every shared setting above, overrides only connection details) nrmysql/instance2: <<: *nrmysql-common endpoint: "<INSTANCE_2_HOST>:<INSTANCE_2_PORT>" username: "<INSTANCE_2_USERNAME>" password: "<INSTANCE_2_PASSWORD>"
processors: batch:
exporters: otlp/newrelic: endpoint: "<YOUR_NEWRELIC_OTLP_ENDPOINT>" headers: api-key: "<YOUR_NEWRELIC_LICENSE_KEY>" compression: gzip sending_queue: enabled: true sizer: bytes queue_size: 100_000_000 num_consumers: 10 batch: sizer: bytes max_size: 1_000_000 min_size: 0 flush_timeout: 5s retry_on_failure: enabled: true initial_interval: 5s max_interval: 30s max_elapsed_time: 300s
service: pipelines: metrics/mysql-instance1: receivers: [nrmysql/instance1, nrmysql/instance2] processors: [batch] exporters: [otlp/newrelic] logs/mysql-instance1: receivers: [nrmysql/instance1, nrmysql/instance2] processors: [batch] exporters: [otlp/newrelic]Dica
This configuration omits the optional database and tls fields. By default, each receiver monitors every database its user can access, and connects without TLS. To monitor a specific database per instance, or to enable TLS, see Enable detailed insights.
Restart NRDOT Collector
Restart the NRDOT Collector service for configuration changes to take effect. The collector loads configuration parameters once at startup and doesn't support hot-reloading. Any changes made to the configuration while the collector is running remain inactive until the process restarts.
$sudo systemctl restart nrdot-collector