# Realtime Telemetry Log Streaming

> For AI tools: this is the Markdown copy of https://xproxy.io/document/realtime-telemetry-log-streaming. Every XProxy guide has one at its URL + `.md`; the index of all guides is https://xproxy.io/llms.txt.

Stream proxy access logs to Graylog or SigNoz in real time.

Send your proxy access logs to Graylog or SigNoz as they happen. Watch many XProxy servers in one place, build dashboards and get alerts on errors.

**You need:** a Graylog or SigNoz server that your XProxy box can reach. The guide shows how to install one.

In short

**Live, line by line**

XProxy reads its proxy log. Every new line goes to your log server as soon as it is written.

**Two tools**

**Graylog** gets GELF over UDP. **SigNoz** gets OTLP over HTTP. You use one of them.

**Search and alert**

Filter by device, port, website or error code. Build dashboards and alerts in your tool.

## Set it up

**Step 1: Install Graylog (Graylog)**

Graylog is the server that collects your logs. Already have one? Skip this step.

On an Ubuntu server (18.04, 20.04 or 22.04), run:

Terminal

```
curl x-proxy.io/graylog | bash
```

The script installs Graylog with Docker and asks for an admin password (press Enter to use `admin`). When it ends, open `http://&lt;server-ip>:9000` and log in as `admin`.

> The script opens ports 9000 (web) and 12201 (logs). On a cloud server, also allow them in the provider's firewall for your XProxy box.

**Step 2: Get SigNoz ready (SigNoz)**

Use SigNoz Cloud, or install SigNoz on your own Ubuntu server (18.04, 20.04 or 22.04):

Terminal

```
curl x-proxy.io/signoz | bash
```

The script installs SigNoz with Docker. When it ends, open `http://&lt;server-ip>:8080` and create your admin account. It opens ports 8080 (web) and 4317 and 4318 (logs).

For the next steps you need the **OTLP/HTTP endpoint** (port 4318) and an **ingestion key**.

> Using SigNoz Cloud? Copy the endpoint of your region and your ingestion key from your SigNoz account.

**Step 3: Create a GELF UDP input (Graylog)**

1. In Graylog, open **System → Inputs**.
2. Choose **GELF UDP** in the list and click **Launch new input**.
3. Give it a **Title**. Keep **Bind address** at `0.0.0.0` and **Port** at `12201`.
4. Click **Save**.

![Graylog window Launch new GELF UDP input: Title, Bind address 0.0.0.0, Port 12201 and Save marked](https://media1.xproxy.io/docs/telemetry/tel-graylog-input-v1.webp)

> The input must show **RUNNING** in the list. XProxy sends GELF over UDP.

**Step 4: Open Telemetry Logs in your panel**

In your XProxy panel, open **General Settings → Telemetry Logs**. Turn on **Enable Telemetry**.

![The panel menu with General Settings open and Telemetry Logs marked (demo data)](https://media1.xproxy.io/docs/telemetry/tel-1-menu-v2.webp)

> XProxy sends what the proxy writes to its access log. Make sure **Proxy Settings → General → Proxy Logging Setting → Proxy Access Logs → Enable** is on.

**Step 5: Fill in the Graylog form (Graylog)**

1. **Enable Telemetry** is on.
2. **Provider**: **Graylog**.
3. **Server (IP:Port)**: your Graylog server and the input port, like `192.168.1.50:12201`. Without a port, 12201 is used.
4. **Host Identifier**: a name for this XProxy server, like `us-east-01`.
5. **Service Name**: a name for the group, like `xproxy-us-east`. It is on every log.
6. **Log Path**: leave `/etc/xproxy/logs`. It is the folder where the box writes its proxy log.

![Telemetry Logs form with Provider Graylog: Server, Host Identifier, Service Name, Log Path and the Save and Test Connection buttons marked (demo data)](https://media1.xproxy.io/docs/telemetry/tel-2-graylog-v1.webp)

> Use one Service Name per region or group and one Host Identifier per server. They make dashboards easy.

**Step 6: Fill in the SigNoz form (SigNoz)**

1. **Enable Telemetry** is on.
2. **Provider**: **SigNoz**.
3. **OTLP/HTTP Endpoint**: the full address with port 4318. SigNoz Cloud: `https://ingest.us.signoz.cloud:4318`. Your own server: `http://&lt;server-ip>:4318`.
4. **Ingestion Key**: paste your key. The panel needs it before it saves.
5. **Service Name**: a name for the group, like `xproxy-us-east`. It becomes `service.name`.
6. **Log Path**: leave `/etc/xproxy/logs`. It is the folder where the box writes its proxy log.

![Telemetry Logs form with Provider SigNoz: OTLP/HTTP Endpoint, Ingestion Key, Service Name, Log Path and the Save and Test Connection buttons marked (demo data)](https://media1.xproxy.io/docs/telemetry/tel-3-signoz-v1.webp)

> The key in the picture is a demo value. Never share your real key.

**Step 7: Save and test (Graylog)**

Click **Save**, then **Test Connection**. XProxy sends one message: `Connection test from xproxy`.

UDP has no reply, so the panel cannot tell if Graylog got it. It says so. Open **Search** in Graylog and look for the message.

![Telemetry Logs form with the Save and Test Connection buttons marked (demo data)](https://media1.xproxy.io/docs/telemetry/tel-2-graylog-v1.webp)

> Save is enough to start streaming. Test Connection only sends the test message.

**Step 8: Save and test (SigNoz)**

Click **Save**, then **Test Connection**. XProxy sends one test log to SigNoz.

You see **SigNoz connection successful**, or the reason it failed. No key? The panel asks for it first.

![Telemetry Logs form with the Save and Test Connection buttons marked (demo data)](https://media1.xproxy.io/docs/telemetry/tel-3-signoz-v1.webp)

> Test fails? Check that the endpoint has port 4318, that the key is right, and that the box can reach the server.

**Step 9: See your logs in Graylog (Graylog)**

Send some traffic through any proxy port. Open **Search** in Graylog and look for your Service Name:

Graylog search

```
service_name:xproxy-us-east
```

Each message is one line of the proxy log. It looks like this:

Example message

```
xproxy-us-east | 06/11 14:03:21 [MAIN][POS:1][:4001][CLIENT-demouser-192.168.1.20:51822] access example.com:443 - CONNECT_example.com:443_HTTP/1.1 - ErrC: 00000 - RBytes:3799 - SBytes:800
```

Open a message to see its fields. The table below lists them all.

> Only new lines are sent. Old log lines from before you turned telemetry on are not.

**Step 10: See your logs in SigNoz (SigNoz)**

Send some traffic through any proxy port. Open **Logs** in SigNoz and filter by your Service Name:

SigNoz filter

```
service.name = "xproxy-us-east"
```

Clear the filter to see every log. Each row is one line of the proxy log. It looks like this:

Example message

```
xproxy-us-east | 06/11 14:03:21 [MAIN][POS:1][:4001][CLIENT-demouser-192.168.1.20:51822] access example.com:443 - CONNECT_example.com:443_HTTP/1.1 - ErrC: 00000 - RBytes:3799 - SBytes:800
```

Open a row to see its attributes. The table below lists them all.

> Only new lines are sent. Old log lines from before you turned telemetry on are not.

## What XProxy sends

- It reads the proxy log files (`xproxy.log`) in the **Log Path** folder. It sends only new lines, the moment they are written.
- Every line becomes one message: your Service Name, a `|`, then the original line.
- The message is marked as an error when `error_code` is not `00000`.
- The parts of the line also arrive as separate fields, so you can search and group by them:

| Field | Type | What it is |
| --- | --- | --- |
| `log_date` | Text | Date of the line, day/month |
| `log_time` | Text | Time of the line, HH:MM:SS |
| `proxy_service` | Text | Service tag of the line, for example MAIN |
| `modem_position` | Text | Position (slot) of the device that served the request |
| `proxy_protocol` | Text | Protocol label in the line. It can be empty |
| `proxy_port` | Number | Port of your XProxy that the client used |
| `proxy_user` | Text | Login the client used. Empty when it logged in by IP |
| `client_ip` | Text | IP of the client that used the proxy |
| `client_port` | Number | Port of that client |
| `destination_host` | Text | Website or host the client asked for |
| `destination_port` | Number | Port of that host |
| `action` | Text | CONNECT for an HTTPS tunnel, or the HTTP method (GET, POST,...) of a plain HTTP request |
| `error_code` | Text | 00000 means success. Any other code is an error |
| `received_bytes` | Number | Bytes from the website to the client |
| `sent_bytes` | Number | Bytes from the client to the website |
| `log_file` | Text | Name of the log file the line came from |
| `service_name` | Text | The Service Name from your form |

## Handy searches

| You want | Graylog | SigNoz |
| --- | --- | --- |
| One service or region | `service_name:xproxy-us-east` | `service.name = "xproxy-us-east"` |
| Only errors | `NOT error_code:00000` | `error_code!= "00000"` |
| Only HTTPS tunnels | `action:CONNECT` | `action = "CONNECT"` |
| One device | `modem_position:3` | `modem_position = "3"` |
| One proxy port | `proxy_port:4001` | `proxy_port = 4001` |

`modem_position` is text, so SigNoz wants quotes around the number. Query syntax can differ a little between versions of your tool.

## What you can do with it

| You want to | How |
| --- | --- |
| Count the different clients | Count unique client_ip. |
| Track the error rate | Count lines where error_code is not 00000. |
| Find top websites and bandwidth | Group by destination_host and add up received_bytes and sent_bytes. |
| Watch one dongle or port | Filter by modem_position or proxy_port. |
| Get an alert | Alert on a sudden rise of errors, or when a server sends no logs for a while. |

## Many servers

- Give every server its own **Host Identifier** (Graylog) and every region or group its own **Service Name**.
- Keep the names the same style. For example start with `prod-` or `stg-` to tell setups apart.
- Decide how long to keep logs in your tool. Graylog and SigNoz have their own retention settings.

## Error codes

`error_code` has five digits. The leading zeros are on purpose: they keep sorting and filtering simple.

| Code | Meaning |
| --- | --- |
| `00000` | Success. The connection closed normally |
| `00001–00009` | Login or access rule errors |
| `00010` | Traffic limit reached |
| `00011–00019` | Connection errors (socket, bind, connect) |
| `00020–00029` | Internal errors, such as memory |
| `00030–00039` | HTTP CONNECT redirection errors |
| `00050–00069` | SOCKS5 redirection errors |
| `00090–00099` | Timeouts and network problems |
| `00100` | Host not found |
| `00200–00299` | UDP port mapping errors |
| `00300–00399` | TCP port mapping errors |
| `00400–00499` | SOCKS proxy errors |
| `00500–00599` | HTTP proxy errors |

## Something not working?

| You see | What to do |
| --- | --- |
| No logs at all | Check that **Enable Telemetry** is on and you clicked **Save**. Send traffic through a proxy port: only new lines are sent. Check that **Proxy Access Logs** are on in **Proxy Settings**, and that **Log Path** is the folder that holds `xproxy.log`. |
| Save says an endpoint or key is required | SigNoz needs the endpoint and the ingestion key. Graylog needs the server. Both need a Service Name and a Log Path. |
| Graylog shows nothing | Check that the GELF UDP input is running on port 12201, and that your firewall allows UDP 12201 from your XProxy box. |
| SigNoz test fails | The endpoint must have port 4318 and be reachable from the box. Check the ingestion key. |

## Questions

### Why is proxy_user empty?

The client logged in by IP, so there is no username.

### What is the difference between CONNECT and GET or POST?

`CONNECT` opens a tunnel, used for HTTPS. A plain HTTP request shows its method instead, such as `GET` or `POST`.

### How do I alert on errors?

Make a rule on `error_code` not equal to `00000` over a time window. Group by `service_name` or `modem_position` to see where it comes from.

---

Source: https://xproxy.io/document/realtime-telemetry-log-streaming
