Status: design merged, cloud side in progress, nothing applied. This page is an operator runbook written from the settings and mini SOC design (sections 3.5, 4 and 4.1) and the stage 2 logging design (section 4). Everything here happens on your network, in your firewall and in your Prometheus. Nothing in this repository can check it for you, so the page asks you to write the evidence down. Every address below is from a documentation range (
192.0.2.0/24,198.51.100.0/24,203.0.113.0/24); replace them with yours and keep your real values out of the repository, issues and pull requests.Unfamiliar word or acronym? The Glossary defines it.
Prerequisites: Twingate, Telemetry crosses the trust boundary and Networking basics for this project.
The cloud half is the stage 2 guide. It builds Twingate objects only, behind two flags that default to off. The home half is this page. The order is fixed: the firewall and its recorded negative tests come first. No logging resource is applied until the record in section 3 exists (design section 4.1).
Everything between the cloud and home travels over Twingate, so your firewall sees one source address: the home connector. A droplet, a later workload host and a compromised machine all look the same to it.
| Layer | Question it answers | Enforced by |
|---|---|---|
| Twingate resources and groups | Which cloud identity may reach which host and port | One resource per host and port, one service per role |
| Your firewall on the connector's VLAN | What the connector can reach at all, if Twingate is misconfigured or the connector is compromised | Rules on the connector's source address, only the listed host and ports, default deny |
Per-host separation inside a VLAN is Twingate's job alone. The firewall only caps the damage at one VLAN's allowed targets.
Rules are keyed to the connector's source address, allow only the listed host and ports, and end in a logged deny. The shape, with placeholders (the worked example uses the connector at 192.0.2.50, the log manager at 192.0.2.10, a management subnet 198.51.100.0/24 and a user subnet 203.0.113.0/24):
| Order | Source | Destination | Port | Action |
|---|---|---|---|---|
| 1 | connector address (192.0.2.50) |
log manager (192.0.2.10) |
tcp 1514 | allow |
| 2 | connector address | log manager | tcp 1515 | allow |
| 3 | connector address | whatever the connector needs to reach Twingate, outbound | per Twingate's current documentation | allow |
| 4 | connector address | any | any | deny, log |
Notes:
A rule you have not tested to fail is a rule you hope works. From the connector's address (or from a test host placed in the connector's VLAN with the same rules), try each connection below. Every "must fail" row is expected to time out or be refused. Run the set again after any rule change, and keep the filled table with your private notes; do not paste real addresses into the repository.
| # | From | To | Port | Expected | Result | Date | Tester | Rule set version |
|---|---|---|---|---|---|---|---|---|
| 1 | connector | 198.51.100.10 (management host) |
tcp 22 | must fail | not run yet | |||
| 2 | connector | 198.51.100.10 |
tcp 443 | must fail | not run yet | |||
| 3 | connector | 203.0.113.20 (user host) |
tcp 445 | must fail | not run yet | |||
| 4 | connector | 192.0.2.10 (log manager) |
tcp 9200 (any port but 1514 and 1515) | must fail | not run yet | |||
| 5 | connector | 192.0.2.10 |
tcp 1514 | must work | not run yet | |||
| 6 | connector | 192.0.2.10 |
tcp 1515 | must work | not run yet | |||
| 7 | connector | Twingate, outbound | as in row 3 above | must work | not run yet |
A copy-paste form for each probe (a plain TCP connect with a short timeout, run on the connector or test host):
timeout 5 bash -c '</dev/tcp/198.51.100.10/22' && echo "OPEN" || echo "no connection"
Change the address and port for each row. OPEN on a must-fail row is a failed test: fix the rule, record the failure, and run the whole table again. Also read the firewall's deny log once: the failed attempts should appear there, which proves the deny rule is the one stopping them.
Metrics are pulled: your Prometheus scrapes the cloud connectors through Twingate. That needs a Twingate headless client (a service account with a key, no interactive login) on the host that runs Prometheus, or on a sidecar in the same compose stack.
metrics_enabled is on (telemetry-<resource_key>-scrape). That service sees only the scrape resources, one per scrape_allowlist entry per connector. It must not be the service used for logs.Prometheus reads the cloud targets from a file_sd JSON file, kept next to your existing target files and listed under the scrape job named twingate-ztna, the job the on-prem Twingate targets use (the file carries no job label: Prometheus sets it from the job name). One entry per scrape endpoint. The label set is the same on every entry except endpoint, and instance is the one host label every panel and alert uses (design section 3.2). endpoint is required: the node exporter and the connector metrics of one host share job, site and instance, so without a label that tells them apart their up and scrape_* series would be identical and collide. Use exactly node-exporter or connector-metrics; the dashboards in this repository filter and group on it (role is taken: it names the host):
[
{
"targets": ["192.0.2.21:9100"],
"labels": {
"site": "site-tor1",
"region": "tor1",
"provider": "digitalocean",
"role": "connector",
"instance": "site-tor1-connector-a",
"endpoint": "node-exporter"
}
},
{
"targets": ["192.0.2.21:9101"],
"labels": {
"site": "site-tor1",
"region": "tor1",
"provider": "digitalocean",
"role": "connector",
"instance": "site-tor1-connector-a",
"endpoint": "connector-metrics"
}
}
]
Repeat both entries for connector b (192.0.2.22). That is four entries, so four expected endpoints per site (the inventory in section 6 counts endpoints, not hosts). Notes:
scrape_targets output (sensitive; read it with tofu output -json scrape_targets). The port 9101 here is only an example: your connector metrics port is the value you set for metrics_port_connector, which has no default and is never 9100 (node exporter keeps that).site values are placeholders. site is the telemetry label site_name (default site-<region>), not the resource_key that names cloud objects.scrape_interval_seconds to what you want (the design's default is 15). If your existing config labels hosts with another name such as instance_name, the relabel that maps it to instance should be tested with promtool, not copied from memory.absent(up{job="twingate-ztna"}) is true only when no series exists for the job, so it cannot tell you a whole site went quiet while another site stays healthy. The design replaces it with an inventory of how many targets each site should have, recorded as a metric, and two alerts compared against it. The shape (design section 3.5; the numbers come from the stack 20 output):
- record: cah_expected_targets
expr: vector(4)
labels: { site: "site-tor1", job: "twingate-ztna" }
# a site with no healthy target at all
- alert: CloudSiteSilent
expr: cah_expected_targets unless on(site) count by (site) (up{job="twingate-ztna"} == 1)
for: 5m
# a site with fewer healthy targets than expected
- alert: CloudSiteDegraded
expr: cah_expected_targets > on(site) count by (site) (up{job="twingate-ztna"} == 1)
for: 5m
Here vector(4) is two connectors times two endpoints each; your number follows your target file. These expressions are proposed, not yet tested: the design requires promtool test rules fixtures of 2 sites by 2 hosts (all healthy; one host down; a whole site's series missing; a site removed from the inventory; every target up == 0) before they are trusted, and those fixtures belong in the home repository's change. Two limits to write into your own notes: the inventory is only as current as its last generation, so a site added in the cloud but not here is never alerted on; and removing a site is a reviewed change to this data, because a removed site raises no alert.
You are finished with the home side when you hold, privately:
promtool fixtures passing.The cloud-side checks that prove the whole path (targets up, agent active, a test alert, zero open ports from outside, no-op plans for stacks 00 and 10) are in the stage 2 guide's verification section, and each is marked not run yet until you run it.
For the whole list in one place (who runs each check, which ones cost money, what a pass and a fail look like, and the Twingate 5.x provider refresh read), see the checklist at a glance. Everything on it is not run yet. The theory path (reading and the offline tests) is free; the hands-on checks need running droplets and cost money.
Rollback: remove the cloud entries from the target file and reload Prometheus, delete the headless client's key in the Twingate console, and restore the previous firewall rules.
Next: Grafana dashboards, the importable dashboards for what you just set up. Then the Roadmap, where stage 2 is tracked.