> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bronto.io/llms.txt
> Use this file to discover all available pages before exploring further.

# MySQL server logs with OpenTelemetry

> Collect self-hosted MySQL error logs, slow query logs, and general logs with the OpenTelemetry Collector and forward them to Bronto to debug queries and locking.

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](/agent-setup/open-telemetry).

## Prerequisites

* A Bronto account and API key ([how to create one](/Account-Management/API-Keys#create-a-new-api-key))
* MySQL writing logs to disk. The default error log on Debian/Ubuntu is `/var/log/mysql/error.log`
* An [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/installation/) (recommended) or [Fluent Bit](https://docs.fluentbit.io/manual/installation/getting-started-with-fluent-bit) installed on the same host

Enable the slow query log in `my.cnf` to capture queries worth investigating:

```ini my.cnf theme={"dark"}
[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:

```yaml /etc/otel/config.yaml theme={"dark"}
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](https://app.bronto.io/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](/core-features/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](https://opentelemetry.io/docs/collector/troubleshooting/).

## Alternative: Fluent Bit

If you already run Fluent Bit, tail the MySQL log files and forward them over HTTP:

```ini fluent-bit.conf theme={"dark"}
[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](/agent-setup/fluent-bit).
