Skip to main content
Collect logs from a self-hosted MySQL server — the error log and the slow query log — with the OpenTelemetry Collector. The same Collector can also forward traces and metrics from your apps — see Connect OpenTelemetry Collector to Bronto.

Prerequisites

Enable the slow query log in my.cnf to capture queries worth investigating:
my.cnf
[mysqld]
slow_query_log      = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time     = 1

Configure the Collector

Error and slow-query entries can span multiple lines. Use multiline keyed on the leading timestamp or the slow-log # Time: header:
/etc/otel/config.yaml
receivers:
  filelog/mysql:
    include:
      - /var/log/mysql/error.log
      - /var/log/mysql/mysql-slow.log
    multiline:
      line_start_pattern: '^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}|# Time:)'
    resource:
      service.name: mysql
      service.namespace: <YOUR_COLLECTION_NAME>

processors:
  batch:

exporters:
  otlphttp/brontologs:
    logs_endpoint: "https://ingestion.<REGION>.bronto.io/v1/logs"
    compression: gzip
    headers:
      x-bronto-api-key: <YOUR_API_KEY>

service:
  pipelines:
    logs:
      receivers: [filelog/mysql]
      processors: [batch]
      exporters: [otlphttp/brontologs]
Set <REGION> to eu or us.

What you will see in Bronto

Open Search and filter by service.name = mysql. The error log carries startup/shutdown, errors, and warnings (timestamp, thread ID, severity, subsystem); the slow query log carries each slow statement with Query_time, Lock_time, Rows_examined, and the SQL text. Bronto’s Custom Parser extracts these fields server-side.

Troubleshooting

  • Where are the logs? Run SHOW VARIABLES LIKE 'log_error'; and SHOW VARIABLES LIKE 'slow_query_log_file';. Adjust the include paths to match.
  • General query log: disabled by default and very verbose — enable (general_log = 1) only for short debugging sessions.
  • For general issues, see OTel Collector troubleshooting.

Alternative: Fluent Bit

If you already run Fluent Bit, tail the MySQL log files and forward them over HTTP:
fluent-bit.conf
[INPUT]
    name  tail
    path  /var/log/mysql/error.log,/var/log/mysql/mysql-slow.log
    tag   mysql

[OUTPUT]
    name        http
    match       mysql
    host        ingestion.<REGION>.bronto.io
    port        443
    tls         on
    format      json_lines
    compress    gzip
    header      x-bronto-api-key    <YOUR_API_KEY>
    header      x-bronto-dataset    mysql
    header      x-bronto-collection <YOUR_COLLECTION_NAME>
Set Format to json_lines, not json. For slow-query entries that span lines, add a multiline.parser keyed on the # Time: header. See Connect Fluent Bit to Bronto.