You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`cloudflared tunnel --metrics <IP:PORT> run <UUID or NAME>`|`localhost:`|`TUNNEL_METRICS`|
84
+
|`cloudflared tunnel --metrics <IP:PORT> run <UUID or NAME>`|Refer to [Tunnel metrics](/cloudflare-one/connections/connect-networks/monitor-tunnels/metrics/)|`TUNNEL_METRICS`|
85
85
86
-
Exposes a Prometheus endpoint on the specified IP address/port, which you can then query for [usage metrics](/cloudflare-one/connections/connect-networks/monitor-tunnels/metrics/).
86
+
Exposes a Prometheus endpoint on the specified IP address and port, which you can then query for [usage metrics](/cloudflare-one/connections/connect-networks/monitor-tunnels/metrics/).
Copy file name to clipboardExpand all lines: src/content/docs/cloudflare-one/connections/connect-networks/monitor-tunnels/metrics.mdx
+19-9Lines changed: 19 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,27 +6,37 @@ sidebar:
6
6
head:
7
7
- tag: title
8
8
content: Tunnel metrics
9
-
tableOfContents: false
10
9
---
11
10
12
-
Tunnel metrics show a Cloudflare Tunnel's throughput and resource usage over time. When you run a tunnel, you can configure `cloudflared`to spin up a Prometheus metrics endpoint — an HTTP server that exposes metrics in [Prometheus](https://prometheus.io/docs/introduction/overview/) format. You can then use the Prometheus toolkit on a remote machine to scrape metrics data from the `cloudflared` server.
11
+
Tunnel metrics show a Cloudflare Tunnel's throughput and resource usage over time. When you run a tunnel, `cloudflared`will spin up a Prometheus metrics endpoint — an HTTP server that exposes metrics in [Prometheus](https://prometheus.io/docs/introduction/overview/) format. You can use the Prometheus toolkit on a remote machine to scrape metrics data from the `cloudflared` server.
13
12
14
-
## Start the metrics server
13
+
## Default metrics server address
15
14
16
-
Perform these steps on the `cloudflared` server.
15
+
In non-containerized environments, `cloudflared` starts the metrics server on `127.0.0.1:<PORT>/metrics`, where `<PORT>` is the first available port in the range `20241` to `20245`. In case of all ports being unavailable then the fallback is to bind to a random port. In containerized environments such as Docker and Kubernetes, the default address is `0.0.0.0:<PORT>/metrics`.
17
16
18
-
1. Use the [--metrics](/cloudflare-one/connections/connect-networks/configure-tunnels/tunnel-run-parameters/#metrics) flag to create a metrics endpoint at the specified IP address and port. Here is an example command for a locally-managed tunnel:
17
+
## Check the metrics server address
18
+
19
+
To determine the metrics server address that is being used by a `cloudflared` instance, check your [Tunnel logs](/cloudflare-one/connections/connect-networks/monitor-tunnels/logs/) around the time when the tunnel started. For example:
20
+
21
+
```text
22
+
2024-12-19T21:17:58Z INF Starting metrics server on 127.0.0.1:20241/metrics
23
+
```
24
+
25
+
## Configure the metrics server address
26
+
27
+
To serve metrics on a custom IP address and port, perform these steps on the `cloudflared` host:
28
+
29
+
1. Run the tunnel using the [--metrics](/cloudflare-one/connections/connect-networks/configure-tunnels/tunnel-run-parameters/#metrics) flag. Here is an example command for a locally-managed tunnel:
19
30
20
31
```sh
21
32
cloudflared tunnel --metrics 127.0.0.1:60123 run my-tunnel
22
33
```
23
34
24
35
To learn how to add the `--metrics` flag to a remotely-managed tunnel, refer to [Configure a remotely-managed tunnel](/cloudflare-one/connections/connect-networks/configure-tunnels/remote-management/#add-tunnel-run-parameters).
25
36
26
-
:::note
27
-
28
-
If you plan to fetch metrics from another machine on the local network, replace `127.0.0.1` with the internal IP of the `cloudflared` server (for example, `198.168.x.x`). To serve metrics on all available network interfaces, use `0.0.0.0`.
29
-
:::
37
+
:::note
38
+
If you plan to fetch metrics from another machine on the local network, replace `127.0.0.1` with the internal IP of the `cloudflared` server (for example, `198.168.x.x`). To serve metrics on all available network interfaces, use `0.0.0.0`.
39
+
:::
30
40
31
41
2. Verify that the metrics server is running by going to `http://localhost:60123/metrics`. This will only work if you configured a localhost IP (`127.0.0.1` or `0.0.0.0`).
0 commit comments