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

# prometheus_exporter extension for MySQL

> The prometheus_exporter community extension serves a Prometheus /metrics endpoint from inside MySQL, covering status variables, InnoDB metrics, and replication.

Scraping MySQL for Prometheus usually means running a separate exporter process
that logs in and polls. `prometheus_exporter` serves the `/metrics` endpoint
from inside the server instead, so there is one fewer process to deploy,
authenticate, and keep alive.

| | |
| - | - |
| **Maintainer** | [ProxySQL](https://github.com/ProxySQL) |
| **Source and documentation** | [ProxySQL/vsql-prometheus-exporter](https://github.com/ProxySQL/vsql-prometheus-exporter) |
| **License** | GPL-2.0 |

> [!NOTE]
>
> A third party writes and maintains this extension. VillageSQL does not build,
> test, or ship it, and the description below follows the maintainer's own
> documentation. Read that documentation before you rely on it.

## Install

> [!WARNING]
>
> The code on the repository's default branch does not build against the current
> SDK: it calls `make_sys_var_bool` and `make_status_var_int`, which left the SDK
> in May 2026. The ported code is on the open pull request
> [#4](https://github.com/ProxySQL/vsql-prometheus-exporter/pull/4), which
> declares preview capabilities, so the server that loads it must be started with
> `--vsql_allow_preview_extensions=ON`.

Build it from that branch against a VillageSQL build tree (`VillageSQL_BUILD_DIR`), copy the `.veb` file into the server's `veb_dir`, then install it:

```sql theme={null}
INSTALL EXTENSION prometheus_exporter;
```

## What it adds

It adds an HTTP listener and three settings, and no SQL functions.

| Setting | Default | What it controls |
| - | - | - |
| `prometheus_exporter.enabled` | `OFF` | Whether the listener runs |
| `prometheus_exporter.port` | `9104` | The port it listens on |
| `prometheus_exporter.bind_address` | `127.0.0.1` | The address it binds |

Five families of metric are exported, each named after where it came from.

| Prefix | Source |
| - | - |
| `mysql_global_status_` | `SHOW GLOBAL STATUS` |
| `mysql_global_variables_` | The numeric server variables |
| `mysql_innodb_metrics_` | `information_schema.innodb_metrics` |
| `mysql_replica_` | The `performance_schema` replication tables, on a replica |
| `mysql_binlog_` | `SHOW BINARY LOGS` |

The exporter also reports on itself through `requests_total`,
`scrape_duration_us`, and `errors_total`.

## Example

The maintainer's quick start turns it on and picks a port:

```sql theme={null}
INSTALL EXTENSION prometheus_exporter;
SET GLOBAL prometheus_exporter.port = 9104;
SET GLOBAL prometheus_exporter.enabled = ON;
```

Prometheus then scrapes `http://127.0.0.1:9104/metrics`. If another process, such as a standalone `mysqld_exporter`, already holds port 9104, `enabled` still reads `ON` and nothing answers, so check the endpoint with `curl`.

> [!WARNING]
>
> The listener binds to localhost unless you change it, which is the safe
> choice. Metrics describe your traffic and configuration, so put the port
> behind something that authenticates before you move it off the loopback
> address.

## See also

* [Available extensions](https://villagesql.com/docs/mysql-8.4/0.0.6/extensions.md) — the full catalog
* [ProxySQL/vsql-prometheus-exporter](https://github.com/ProxySQL/vsql-prometheus-exporter) — source, the metric list, and the test suite


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.