Skip to content

Commit c1a4f8c

Browse files
committed
instructions for getting logs
1 parent 2844e6f commit c1a4f8c

File tree

1 file changed

+138
-0
lines changed
  • src/content/docs/cloudflare-one/connections/connect-networks/troubleshoot-tunnels

1 file changed

+138
-0
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
---
2+
pcx_content_type: how-to
3+
title: Diagnostic logs
4+
sidebar:
5+
order: 1
6+
head:
7+
- tag: title
8+
content: Tunnel diagnostic logs
9+
---
10+
11+
Cloudflare Tunnel generates a set of diagnostic logs that can be used to troubleshoot issues with `cloudflared`. A diagnostic report covers a single instance of `cloudflared`.
12+
13+
## Get diagnostic logs
14+
15+
The steps for getting diagnostic logs depend on your `cloudflared` deployment environment.
16+
### Prerequisites
17+
18+
- Access to the `cloudflared` host being diagnosed
19+
- `cloudflared` version 2024.12.2 or later
20+
21+
### Host environment
22+
23+
These instructions apply to remotely-managed and locally-managed tunnels running directly on the host machine.
24+
25+
1. (Linux only) Allow the `cloudflared` user to create RAW and PACKET sockets without root permissions:
26+
27+
```sh
28+
sudo setcap cap_net_raw+ep /usr/bin/traceroute && sudo setcap cap_net_raw+ep /usr/bin/traceroute
29+
```
30+
31+
2. Get diagnostic logs:
32+
33+
```sh
34+
cloudflared tunnel diag
35+
```
36+
37+
If multiple instances of `cloudflared` are running on the same host, specify the [metrics server address](/cloudflare-one/connections/connect-networks/monitor-tunnels/metrics/#check-the-metrics-server-address) for the instance you want to diagnose:
38+
39+
```sh
40+
cloudflared tunnel diag --metrics 127.0.0.1:20241
41+
```
42+
43+
This command will output the status of each diagnostic task and place a `cloudflared-diag-YYYY-MM-DDThh-mm-ss.zip` file in your working directory.
44+
45+
### Docker
46+
47+
`cloudflared` reads diagnostic data from the `cloudflared` [metrics server](/cloudflare-one/connections/connect-networks/monitor-tunnels/metrics/#check-the-metrics-server-address). Therefore, the metrics server must be exposed from the Docker container and reachable from the host machine.
48+
49+
Run the following commands on the `cloudflared` host:
50+
51+
1. Verify that you can reach the metrics server address. For example, if the metrics server is listening at `0.0.0.0:20241`, run the following command:
52+
53+
```sh
54+
curl localhost:20241/diag/tunnel
55+
```
56+
57+
This command should return a JSON:
58+
```json
59+
{
60+
"tunnelID": "ef96b330-a7f5-4bce-a00e-827ce5be077f",
61+
"connectorID": "d236670a-9f74-422f-adf1-030f5c5f0523",
62+
"connections": [
63+
{ "isConnected": true, "protocol": 1, "edgeAddress": "198.41.192.167"},
64+
{"isConnected": true, "protocol": 1, "edgeAddress": "198.41.200.113", "index": 1},
65+
{"isConnected": true, "protocol": 1, "edgeAddress": "198.41.192.47", "index": 2},
66+
{"isConnected": true, "protocol": 1, "edgeAddress": "198.41.200.73", "index": 3}
67+
],
68+
"icmp_sources": ["192.168.1.243", "fe80::c59:bd4a:e815:ed6"]
69+
}
70+
```
71+
72+
2. If the metrics server is not reachable, deploy the container again and expose the port:
73+
74+
```sh
75+
docker run -d -p 20241:20241 docker.io/cloudflare/cloudflared tunnel ...
76+
```
77+
78+
3. Take note of the container ID and then run the diagnostic:
79+
80+
```sh
81+
cloudflared tunnel diag --diag-container-id=<containerID>
82+
```
83+
84+
Alternatively, you can specify the container's name instead of its ID:
85+
```sh
86+
cloudflared tunnel diag --diag-container-id=<containerName>
87+
```
88+
89+
This command will output the status of each diagnostic task and place a `cloudflared-diag-YYYY-MM-DDThh-mm-ss.zip` file in your working directory.
90+
91+
### Kubernetes
92+
93+
`cloudflared` reads diagnostic data from the `cloudflared` [metrics server](/cloudflare-one/connections/connect-networks/monitor-tunnels/metrics/#check-the-metrics-server-address). You must use port forwarding to expose the metrics server running in a Kubernetes cluster.
94+
95+
Run the following commands on the `cloudflared` host:
96+
97+
1. Forward a local port to the `cloudflared` metrics server port:
98+
99+
```sh
100+
kubectl port-forward <pod> <known_port>:<metrics_port>
101+
```
102+
103+
Alternatively, you can let `kubectl` choose an available local port:
104+
105+
```sh
106+
kubectl port-forward <pod> :<metrics_port>
107+
```
108+
109+
2. Run the diagnostic:
110+
111+
```sh
112+
cloudflared tunnel diag --diag-pod-id=<podID>
113+
```
114+
115+
If the pod has multiple applications/services running and `cloudflared` is not the first in the pod, you must specify either the container ID or name:
116+
117+
```sh
118+
cloudflared tunnel diag --diag-pod-id=<podID> --diag-container-id=<containerName>
119+
```
120+
121+
This command will output the status of each diagnostic task and place a `cloudflared-diag-YYYY-MM-DDThh-mm-ss.zip` file in your working directory.
122+
123+
124+
-------
125+
If you are managing the tunnel directly on the host:
126+
127+
1. Enable debug logging when you start the tunnel:
128+
129+
```sh
130+
cloudflared tunnel --loglevel debug --logfile cloudflared.log run <UUID>
131+
```
132+
133+
## cloudflared-diag files
134+
135+
The `cloudflared-diag-YYYY-MM-DDTHH-MM-SS.zip` archive contains the files listed below. The data in a file either applies to the `cloudflared` instance being diagnosed (`diagnosee`) or the instance that triggered the diagnosis (`diagnoser`). For example, if your tunnel is running in a Docker container, the diagnosee is the Docker instance and the diagnoser is the host machine instance. The diagnosee and diagnoser could also be the same instance.
136+
137+
| File name | Description | Instance |
138+
| -| - | - |

0 commit comments

Comments
 (0)