Docs » Configure application receivers » Configure application receivers for databases » MySQL

MySQL 🔗

Description 🔗

The Splunk Distribution of OpenTelemetry Collector provides this integration as the MySQL monitor via the Smart Agent Receiver.

This monitor connects to a MySQL instance and reports on the values returned by a SHOW STATUS command, which include the following:

  • Number of commands processed

  • Table and row operations (handlers)

  • State of the query cache

  • Status of MySQL threads

  • Network traffic

Installation 🔗

This monitor is available in the SignalFx Smart Agent Receiver, which is part of the Splunk Distribution of OpenTelemetry Collector.

To install this integration:

  1. Deploy the Splunk Distribution of OpenTelemetry Collector to your host or container platform.

  2. Configure the monitor, as described in the next section.

Creating a MySQL user for this monitor 🔗

To create a MySQL user for this monitor:

 CREATE USER '<username>'@'localhost' IDENTIFIED BY '<password>';
 -- Give appropriate permissions
 -- ("GRANT USAGE" is synonymous to "no privileges")
 GRANT USAGE ON *.* TO '<username>'@'localhost';
 -- Permissions for the stats options
 GRANT REPLICATION CLIENT ON *.* TO '<username>'@'localhost';

The new user will only have privileges to connect to the database. Additional privileges are not required.

Note on localhost 🔗

On Unix, MySQL programs treat the host name localhost specially, in a way that is likely different from what is expected compared to other network-based programs. For connections to localhost, MySQL programs attempt to connect to the local server by using a Unix socket file. To ensure that the client makes a TCP/IP connection to the local server specify a host name value of 127.0.0.1, or the IP address or name of the local server.

Databases 🔗

You have to specify each database you want to monitor individually under the databases configuration option. If you have a common authentication to all databases being monitored, you can specify that in the top-level username/password options, otherwise they can be specified at the database level.

InnoDB metrics 🔗

If you want to enable InnoDB metrics (innodbStats to true), be sure that you granted the PROCESS privilege to your user.

Configuration 🔗

The Splunk Distribution of OpenTelemetry Collector allows embedding a Smart Agent monitor configuration in an associated Smart Agent Receiver instance.

Note: Providing a MySQL monitor entry in your Smart Agent or Collector configuration is required for its use. Use the appropriate form for your agent type.

Smart Agent 🔗

To activate this monitor in the Smart Agent, add the following to your agent configuration:

monitors:  # All monitor config goes under this key
 - type: collectd/mysql
   ...  # Additional config

See Smart Agent example configuration for an autogenerated example of a YAML configuration file, with default values where applicable.

Splunk Distribution of OpenTelemetry Collector 🔗

To activate this monitor in the Splunk Distribution of OpenTelemetry Collector, add the following to your agent configuration:

receivers:
  smartagent/mysql:
    type: collectd/mysql
    ...  # Additional config

To complete the monitor activation, you must also include the smartagent/mysql receiver item in a metrics pipeline. To do this, add the receiver item to the service > pipelines > metrics > receivers section of your configuration file.

See configuration examples for specific use cases that show how the collector can integrate and complement existing environments.

The following is a sample YAML configuration that shows how to connect multiple MySQL databases:

monitors:
 - type: collectd/mysql
   host: 127.0.0.1
   port: 3306
   databases:
     - name: dbname
     - name: securedb
       username: admin
       password: s3cr3t
   username: dbuser
   password: passwd

The following is a sample YAML configuration that shows how to connect a single MySQL database:

monitors:
 - type: collectd/mysql
    host: 127.0.0.1
    port: 3306
    databases:
      - name:
    username: YOURUSERNAMEHERE
    password: YOURPASSWORDHERE

Configuration settings 🔗

The following table shows the configuration options for the MySQL monitor:

Option Required Type Description
host yes string
port yes integer
name no string
databases yes list of objects (see below) A list of databases along with optional authentication credentials.
username no string These credentials serve as defaults for all databases if not overridden
password no string
reportHost no bool A SignalFx extension to the plugin that allows us to disable the normal behavior of the MySQL plugin where the host dimension is set to the hostname of the MySQL database server. When false (the recommended and default setting), the globally configured hostname configuration is used instead. (default: false)
innodbStats no bool (default: false)

The nested databases configuration object has the following fields:

Option Required Type Description
name yes string
username no string
password no string

Metrics 🔗

These are the metrics available for this integration.