# How to Set Up Prometheus Monitoring with frp: Enabling the Metrics Endpoint

> Learn how to set up Prometheus monitoring with frp. Enable the metrics endpoint in frps.toml and scrape frp server stats for powerful insights.

- Repository: [fatedier/frp](https://github.com/fatedier/frp)
- Tags: how-to-guide
- Published: 2026-02-26

---

**Enable Prometheus monitoring in frp by setting `enablePrometheus = true` in [`frps.toml`](https://github.com/fatedier/frp/blob/main/frps.toml) alongside a configured `webServer` port, then scrape the `/metrics` endpoint exposed on the dashboard address.**

fatedier/frp (Fast Reverse Proxy) exposes internal statistics—including connection counts, traffic volume, and proxy states—through a Prometheus-compatible metrics endpoint. Activating this feature requires enabling the web dashboard and setting a configuration flag in the server configuration file.

## Configuration Prerequisites

The **frps** (server) component serves metrics through its embedded HTTP server. Consequently, you must enable the **web dashboard** before the `/metrics` endpoint becomes available. Without an active `webServer` configuration, the route registration logic in [`server/service.go`](https://github.com/fatedier/frp/blob/main/server/service.go) never mounts the Prometheus handler.

## Enabling the Metrics Endpoint in frps.toml

Set `enablePrometheus = true` within your server configuration file. This boolean flag resides in the `ServerConfig` struct defined in [`pkg/config/v1/server.go`](https://github.com/fatedier/frp/blob/main/pkg/config/v1/server.go) (lines 73–76), triggering the registration of the `/metrics` handler during service initialization.

```toml

# frps.toml

[webServer]
port = 7400
user = "admin"
password = "admin"

enablePrometheus = true

```

The dashboard listens on the specified port, and the metrics endpoint inherits this address. According to the source code in [`server/service.go`](https://github.com/fatedier/frp/blob/main/server/service.go), the `registerRouteHandlers` function (lines 94–104) conditionally attaches `promhttp.Handler()` to the `/metrics` route only when `EnablePrometheus` is true.

## How frp Collects and Exposes Metrics

### Configuration Layer

In [`pkg/config/v1/server.go`](https://github.com/fatedier/frp/blob/main/pkg/config/v1/server.go), the `ServerConfig` struct contains the `EnablePrometheus` field. When parsed from TOML, this value determines whether the server initializes Prometheus instrumentation at startup.

### HTTP Route Registration

The `Service.registerRouteHandlers` method in [`server/service.go`](https://github.com/fatedier/frp/blob/main/server/service.go) builds the HTTP router for the administrative interface. If `EnablePrometheus` is true, it registers the standard Prometheus Go client handler (`promhttp.Handler()`) at the `/metrics` path, exposing all collected metric families.

### Internal Metrics Collection

The `server/metrics` package maintains metric vectors updated throughout the server's lifecycle. Functions such as `metrics.Server.NewClient()` and `metrics.Server.AddTrafficIn/Out()` increment counters and gauges whenever clients connect, disconnect, or transmit data. These updates feed the registry queried by the Prometheus scraper.

## Verifying the Endpoint Locally

Before adding the target to Prometheus, confirm the endpoint returns valid exposition format:

```bash
curl http://127.0.0.1:7400/metrics | head -n 10

```

Expect output containing metric families such as `frp_server_client_total` and `frp_server_proxy_total`:

```text

# HELP frp_server_client_total Total number of connected clients

# TYPE frp_server_client_total gauge

frp_server_client_total 1

# HELP frp_server_proxy_total Total number of active proxies

# TYPE frp_server_proxy_total gauge

frp_server_proxy_total 3

```

## Scraping Configuration for Prometheus

Add a scrape job to your [`prometheus.yml`](https://github.com/fatedier/frp/blob/main/prometheus.yml) pointing to the frp dashboard address:

```yaml
scrape_configs:
  - job_name: 'frp'
    static_configs:
      - targets: ['127.0.0.1:7400']
    metrics_path: '/metrics'
    scheme: http

```

Reload Prometheus to begin collecting `frp_*` time series.

## Visualizing Metrics in Grafana

Import the following dashboard JSON to monitor client connections and traffic rates:

```json
{
  "title": "frp Overview",
  "panels": [
    {
      "type": "graph",
      "title": "Connected Clients",
      "targets": [{ "expr": "frp_server_client_total" }]
    },
    {
      "type": "graph",
      "title": "Traffic In (bytes)",
      "targets": [{ "expr": "rate(frp_server_traffic_in_bytes[1m])" }]
    }
  ]
}

```

## Summary

- The **frps** server exposes Prometheus metrics only when both the `webServer` port and `enablePrometheus` are configured in [`frps.toml`](https://github.com/fatedier/frp/blob/main/frps.toml).
- The `EnablePrometheus` flag in [`pkg/config/v1/server.go`](https://github.com/fatedier/frp/blob/main/pkg/config/v1/server.go) controls whether `registerRouteHandlers` in [`server/service.go`](https://github.com/fatedier/frp/blob/main/server/service.go) mounts the `promhttp.Handler()`.
- Metric collection occurs inside the `server/metrics` package, tracking client connections and traffic via vectors like `frp_server_client_total`.
- Verification requires curling the `/metrics` endpoint on the dashboard port before configuring Prometheus scraping.

## Frequently Asked Questions

### Do I need to enable the web dashboard to use Prometheus monitoring with frp?

Yes. The `/metrics` endpoint is served by the same HTTP server instance that hosts the administrative dashboard. If `webServer.port` is unset or zero, the `registerRouteHandlers` function never executes, leaving the Prometheus handler unregistered regardless of the `enablePrometheus` setting.

### What frp metrics are available in Prometheus?

The `server/metrics` package exposes gauges and counters for total connected clients (`frp_server_client_total`), active proxies (`frp_server_proxy_total`), and traffic volume (`frp_server_traffic_in_bytes` and `frp_server_traffic_out_bytes`). These metrics update in real-time as clients connect and transmit data through the reverse proxy.

### Can I expose the metrics endpoint on a different port than the web dashboard?

No. According to the current implementation in [`server/service.go`](https://github.com/fatedier/frp/blob/main/server/service.go), the Prometheus handler attaches to the same HTTP listener used by the dashboard UI. Both services share the address and port defined in the `webServer` configuration section.

### Is the Prometheus metrics endpoint protected by dashboard authentication?

No. While the dashboard UI requires the credentials specified in `webServer.user` and `webServer.password`, the `/metrics` endpoint typically remains unauthenticated to allow Prometheus scrapers access without credential management. Verify your specific frp version behavior, as implementations may vary.