Real-time Connection Logs

📘

Note that the functionality described here is exclusive to the Enterprise product tier. Contact us if you'd like to change your product tier.

The functionality described here requires running Connector v1.22.0 or higher. See the Connector changelog for more details, and Updating Connectors for guidance on how to update your running Connectors.

This describes how to enable and interpret real-time connection logs from running Connectors. If you wish to export historical data instead, see Exporting network traffic.

Enabling real-time connection logs

Real-time connection logs are controlled by setting an environment variable before the Connector starts. If the environment variable TWINGATE_LOG_ANALYTICS is set to v1, the Connector will output network connection logs (described below in detail).

In all cases, local connection logs will be output to stdout in single-line JSON format. This allows log collection by SIEM platforms such as AWS CloudWatch, Datadog, Splunk, Promtail/Loki, etc.

Docker

If you are using Docker, you can add --env TWINGATE_LOG_ANALYTICS="v1" to the Docker run command to enable local network connection logs.

K8s Helm Chart

The official Twingate Helm Chart includes a configurable parameter env which can be used to set additional environment variables, including TWINGATE_LOG_ANALYTICS="v1" to enable real-time connection logs.

More information about this and other configurable parameters can be found in our Helm Chart's README.

systemd

If you are using our systemd Connector, you can add the line TWINGATE_LOG_ANALYTICS=v1 to the file /etc/twingate/connector.conf.

Local connection logs can be read using journalctl. For example, the following command will output the most recent 100 logging lines and follow any new output:

journalctl -u twingate-connector -n 100 -f

Single-line JSON output schema (v1)

Connection logs are output as single-line JSON objects, making them straightforward to ingest and parse by SIEM and other log aggregation products. Each network connection line starts with ANALYTICS followed by a single JSON object.

An example log line is shown below:

ANALYTICS {"connection":{"client_ip":"124.214.168.162","id":"27a35374-343eb9ce-b-3000003-60c16b09-9cca1","protocol":"tcp","resource_ip":"192.168.5.1","resource_port":80},"connector":{"id":"108","name":"AWS-instance-1208"},"device":{"id":"AFCDBA53-CC2F-48D8-8EFC-EE26E7F8EF9C"},"event_type":"established_connection","relays":[{"ip":"32.127.13.179","name":"relaybalancer+https:\/\/relays.twingate.com","port":30000}],"remote_network":{"id":"535","name":"AWS VPC"},"resource":{"address":"host.autoco.internal","applied_rule":"192.168.5.0/24","id":"1171"},"timestamp":1623288585643,"user":{"email":"[email protected]","id":"1455"}}

For clarity, the JSON object in the log line above is formatted below for readability:

{
  "connection": {
    "client_ip": "124.214.168.162",
    "id": "27a35374-343eb9ce-b-3000003-60c16b09-9cca1",
    "protocol": "tcp",
    "resource_ip": "192.168.5.1",
    "resource_port": 80
  },
  "connector": {
    "id": "108",
    "name": "AWS-instance-1208"
  },
  "device": {
    "id": "AFCDBA53-CC2F-48D8-8EFC-EE26E7F8EF9C"
  },
  "event_type": "established_connection",
  "relays": [
    {
      "ip": "32.127.13.179",
      "name": "relaybalancer+https://relays.twingate.com",
      "port": 30000
    }
  ],
  "remote_network": {
    "id": "535",
    "name": "AWS VPC"
  },
  "resource": {
    "address": "host.autoco.internal",
    "applied_rule": "192.168.5.0/24",
    "id": "1171"
  },
  "timestamp": 1623288585643,
  "user": {
    "email": "[email protected]",
    "id": "1455"
  }
}

Notes on the connection schema

  • connection.id is common to events for the same network connection. In success scenarios, this will correspond to a log with an event_type of established_connection and another with an event_type of closed_connection. Error states will not have a corresponding closed_connection event type.
  • connection.client_ip corresponds to the IP address of the client as visible from the internet. This usually means that this is an Internet-facing NAT address.
  • connection.resource_ip will always be the private IP address of the resource being accessed. For resources defined by a DNS address in Twingate, connection.resource_ip will be the local address as resolved by the Connector. See How DNS Works with Twingate for more information on how we handle DNS and local address translation.
  • device.id is an internal ID that Twingate uses to identify the user's device. This may not correspond to an ID presented by the device itself depending on the operating system. We will be standardizing this device ID in a future logging schema version.
  • resource.address is the address of the resource as defined in the Twingate Admin console. If this is a DNS address, it will appear as defined here, with the resolved IP address logged in the field connection.resource_ip.

Did this page help you?