MySQL Server Metrics

Ship your MySQL Server Metrics via Telegraf to your Logit.io Stack

Configure Telegraf to ship MySQL Server metrics to your Logit.io stacks via Logstash.

Install Integration

Please click on the Install Integration button to configure your stack for this source.

Install Telegraf

This integration allows you to configure a Telegraf agent to send your metrics, in multiple formats, to Logit.io.

Choose the installation method for your operating system:

When you paste the command below into Powershell it will download the Telegraf zip file. Once that is complete, press Enter again and the zip file will be extracted into C:\Program Files\InfluxData\telegraf\telegraf-1.31.2.

wget https://dl.influxdata.com/telegraf/releases/telegraf-1.31.2_windows_amd64.zip -UseBasicParsing -OutFile telegraf-1.31.2_windows_amd64.zip 
Expand-Archive .\telegraf-1.31.2_windows_amd64.zip -DestinationPath 'C:\Program Files\InfluxData\telegraf'

Configure the Telegraf input plugin

The configuration file below is pre-configured to scrape the system metrics from your hosts, add the following code to the configuration file /etc/telegraf/telegraf.conf from the previous step.

# Read metrics from one or many mysql servers
[[inputs.mysql]]
  ## specify servers via a url matching:
  ##  [username[:password]@][protocol[(address)]]/[?tls=[true|false|skip-verify|custom]]
  ##  see https://github.com/go-sql-driver/mysql#dsn-data-source-name
  ##  e.g.
  ##    servers = ["user:passwd@tcp(127.0.0.1:3306)/?tls=false"]
  ##    servers = ["user@tcp(127.0.0.1:3306)/?tls=false"]
  #
  ## If no servers are specified, then localhost is used as the host.
  servers = ["tcp(127.0.0.1:3306)/"]
 
  ## Selects the metric output format.
  ##
  ## This option exists to maintain backwards compatibility, if you have
  ## existing metrics do not set or change this value until you are ready to
  ## migrate to the new format.
  ##
  ## If you do not have existing metrics from this plugin set to the latest
  ## version.
  ##
  ## Telegraf >=1.6: metric_version = 2
  ##           <1.6: metric_version = 1 (or unset)
  metric_version = 2
 
  ## if the list is empty, then metrics are gathered from all database tables
  # table_schema_databases = []
 
  ## gather metrics from INFORMATION_SCHEMA.TABLES for databases provided
  ## in the list above
    gather_table_schema = true
 
  ## gather thread state counts from INFORMATION_SCHEMA.PROCESSLIST
    gather_process_list = true
 
  ## gather user statistics from INFORMATION_SCHEMA.USER_STATISTICS
    gather_user_statistics = true
 
  ## gather auto_increment columns and max values from information schema
    gather_info_schema_auto_inc = true
 
  ## gather metrics from INFORMATION_SCHEMA.INNODB_METRICS
    gather_innodb_metrics = true
 
  ## gather metrics from all channels from SHOW SLAVE STATUS command output
  # gather_all_slave_channels = false
 
  ## gather metrics from SHOW SLAVE STATUS command output
    gather_slave_status = true
 
  ## use SHOW ALL SLAVES STATUS command output for MariaDB
  # mariadb_dialect = false
 
  ## gather metrics from SHOW BINARY LOGS command output
    gather_binary_logs = true
 
  ## gather metrics from SHOW GLOBAL VARIABLES command output
    gather_global_variables = true
 
  ## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE
    gather_table_io_waits = true
 
  ## gather metrics from PERFORMANCE_SCHEMA.TABLE_LOCK_WAITS
    gather_table_lock_waits = true
 
  ## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_INDEX_USAGE
    gather_index_io_waits = true
 
  ## gather metrics from PERFORMANCE_SCHEMA.EVENT_WAITS
    gather_event_waits = true
 
  ## gather metrics from PERFORMANCE_SCHEMA.FILE_SUMMARY_BY_EVENT_NAME
    gather_file_events_stats = true
 
  ## gather metrics from PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_DIGEST
  # gather_perf_events_statements = false
  #
  ## gather metrics from PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_ACCOUNT_BY_EVENT_NAME
    gather_perf_sum_per_acc_per_event = true
  #
  ## list of events to be gathered for gather_perf_sum_per_acc_per_event
  ## in case of empty list all events will be gathered
  # perf_summary_events = []
 
  ## the limits for metrics form perf_events_statements
  # perf_events_statements_digest_text_limit = 120
  # perf_events_statements_limit = 250
  # perf_events_statements_time_limit = 86400
 
  ## Some queries we may want to run less often (such as SHOW GLOBAL VARIABLES)
  ##   example: interval_slow = "30m"
  # interval_slow = ""
 
  ## Optional TLS Config (used if tls=custom parameter specified in server uri)
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"
  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false

Read more about how to configure data scraping and configuration options for MySQL (opens in a new tab)

Configure the output plugin

Once you have generated the configuration file, you need to set up the output plug-in to allow Telegraf to transmit your data to Logit.io in Prometheus format. This can be accomplished by incorporating the following code into your configuration file:

[[outputs.http]]
  url = "https://@metricsUsername:@metricsPassword@@metrics_id-vm.logit.io:@vmAgentPort/api/v1/write"
  data_format = "prometheusremotewrite"
 
  [outputs.http.headers]
    Content-Type = "application/x-protobuf"
    Content-Encoding = "snappy"

Start Telegraf

From the location where Telegraf was installed (C:\Program Files\InfluxData\telegraf\telegraf-1.31.2) run the program providing the chosen configuration file as a parameter:

.\telegraf.exe --config telegraf-demo.conf

Once Telegraf is running you should see output similar to the following, which confirms the inputs, output and basic configuration the application has been started with: Powershell Telegraf information

View your metrics

Data should now have been sent to your Stack.

View My Data

If you don't see take a look at How to diagnose no data in Stack below for how to diagnose common issues.

How to diagnose no data in Stack

If you don't see data appearing in your stack after following this integration, take a look at the troubleshooting guide for steps to diagnose and resolve the problem or contact our support team and we'll be happy to assist.

Telegraf MySQL Overview

To effectively monitor and analyze MySQL metrics in a distributed system, businesses need a trustworthy and proficient solution for managing metrics. Telegraf, an open-source server agent for collecting metrics, can amass MySQL metrics from a variety of sources, including live MySQL instances, databases, and other software applications.

With an extensive assortment of input plugins, Telegraf allows users to gather metrics from various resources, such as CPU usage, memory consumption, network traffic, and more. To store and scrutinize the collected metrics, businesses can employ Prometheus, an open-source monitoring and alerting tool that provides a flexible querying language and visual data representation capabilities.

By setting up Telegraf to output metrics in the Prometheus format and utilizing Prometheus to extract the metrics from the Telegraf server, companies can transfer MySQL metrics from Telegraf to Prometheus. This process involves configuring Telegraf to accumulate MySQL metrics, rendering them in the Prometheus format, arranging Prometheus to scrape the metrics from the Telegraf server, and visually interpreting the data using Prometheus's dynamic querying and data visualization features.

Using Telegraf to send MySQL metrics to Prometheus is a reliable and effective solution for managing metrics in distributed systems. It empowers organizations to gain insights into MySQL performance, enhance the efficiency of their distributed MySQL instances, and troubleshoot any potential issues swiftly.

If you need any further assistance with shipping your log data to Logit.io we're here to help you get started. Feel free to get in contact with our support team by sending us a message via live chat & we'll be happy to assist.