Unverified draft: the stage 2 telemetry pieces this page describes are built and merged (opt-in node exporter, Wazuh agent with auditd, metrics firewall rules, Grafana dashboards), but none of it has been applied or run against real infrastructure, and nothing has been measured. Sources: the settings and mini SOC design section 3 (2026-10-16),
docs/cost.md(the stack-instance section, read 2026-10-16), and the merged settings layer described in Variables, tfvars and secrets. The settings layer, the cost gate's stack instances, the telemetry stack (stack 20, everything off by default) and the site-aware dashboards exist as code. No second site is deployed, and none of it is applied. Stack 20 also has asitesmap that creates a separate logging service and scrape service per site (issue #104, mock-tested only). Statements about Twingate's behavior that are marked UNVERIFIED were not checked.Unfamiliar word or acronym? The Glossary defines it.
Prerequisites: Cloud telemetry: what and why, Variables, tfvars and secrets and Twingate.
One site is easy to name: it is "the cloud". The moment a second one exists (another region, another account, another cloud), every telemetry question gets a second answer, and "which one?" becomes part of every query. This page is about what a site is, what breaks at two, and why adding one should be a new settings file and not new code.
A site is one deployment of the same code with its own values. The home network counts as a site too, so one dashboard can put home next to the clouds.
| Attribute | Example | Meaning |
|---|---|---|
site_name |
site-tor1, site-home |
A short, unique name. The join key in telemetry |
region |
tor1, on-prem |
Where it physically is |
provider |
digitalocean, aws, onprem |
Which cloud, or none |
Two settings carry that identity, and they must never be confused. This is the most expensive mistake on the page, so it comes first.
| Setting | Goes into | Default | Can it change on a live stack? |
|---|---|---|---|
resource_key |
Names and tags of cloud and Twingate objects: access-tor1, cah-connector-tor1, droplet access-tor1-connector-a |
The region, so every existing name is unchanged |
Never. A new name is a replace, and several replaces force a new machine |
site_name |
Telemetry only: metric labels, the site_identity output (including the agent group) and dashboard variables. Agent names take their prefix from a separate stack 10 input, log_shipping.agent_name_prefix, which you keep equal to it by hand |
Empty, meaning site-<region> |
Yes. It renames nothing in the cloud; it changes the identity under which history is recorded |
Why two? Because the obvious design uses one value for both, and that renames live infrastructure the day someone decides a label should be friendlier. Variables, tfvars and secrets walks through the plan you would see. Both settings exist in the code (step 2 of the build order), and stack 20 reads site_name into its site_identity and scrape_targets outputs (stacks/20-telemetry/site.tf). No telemetry carries the label yet, because nothing is applied. Stack 20 also accepts a sites map: each extra site gets its own logging and scrape Twingate services and resources, and its site_name label in the outputs, while the single-site plan keeps every address it has (docs/stages/02-telemetry.md section 2.5). Service keys are still issued by hand, one per host.
When Prometheus stores a number, it stores it with labels: key and value pairs. The design uses exactly five identity labels:
| Label | Example values | Question it answers |
|---|---|---|
site |
site-tor1, site-home |
Where? |
region |
tor1, on-prem |
In what part of the world? |
provider |
digitalocean, onprem |
On whose platform? |
role |
connector, workload, soc |
Doing what? |
instance |
connector-a, connector-b |
Which machine? |
One label per question, one name per label. The design found a mistake of the opposite kind in its own first draft: dashboard panels filtered on a label called host that no target file set. A panel that filters on a label nobody sets shows nothing, or everything, depending on the query. It is better to pick the label once (instance) and use it everywhere.
Why site is a label and not a job name. A Prometheus job names a kind of thing that gets scraped. If each site had its own job, every dashboard panel and alert that selects the job would need rewriting for each site, and "all sites" would be a list of names to maintain. As a label, site costs one more filter, and by (site) turns any query into a per-site view.
Every distinct combination of label values is a separate time series, stored and indexed on its own. Labels that take few values (site, role) are cheap. A label that takes a new value for every event (a request id, a user name, a timestamp) turns one metric into millions of series and brings the server down. The design limits free-form labels to an allow-list (env, role, owner_team) with values no longer than 32 characters, and stack 20's labels variable refuses any other key and any value over 32 characters (stacks/20-telemetry/variables.tf). The home-side generator that writes the Prometheus target file is not built.
Worked scale: two sites with two connectors each is four targets. One metric on those four targets is four series. Add a label env with the value lab everywhere, and it is still four, because every series has the same value. Add a label with a different value per scrape, and the number of series grows with time. The first is a label; the second is a mistake.
| Problem | Why | What the design does | Status of the fact |
|---|---|---|---|
| Overlapping VPC ranges | Both sites default to 10.78.0.0/24. A Twingate resource's address is an IP, so two networks with the same range make an address ambiguous |
reserved_ranges validation: list the other ranges and the plan fails on overlap |
The validation exists. That Twingate cannot tell two same-address resources apart is UNVERIFIED |
| Names collide | Every name embeds the region; two stacks in one region produce equal names | A distinct resource_key on the new stack |
Whether Twingate or DigitalOcean refuses duplicates is UNVERIFIED |
| One stolen key reaches too much | A Twingate service key authorizes access to all resources assigned to its service (Twingate documentation, https://www.twingate.com/docs/services/ , fetched 2026-10-16, quoted in the design) | One service per site per role; one key per host; each service granted only that role's resources | Key facts from one page. Re-checked 2026-10-21 on the Twingate pricing page and the Services page: they name "secure service accounts" as a plan feature but state no count per plan. Not documented is not the same as "no limit": the maintainer reads the limit in the Twingate console (Settings, Billing) before any stack 20 apply that enables a flag (even one site creates two services) |
| Label cardinality | See above | The label allow-list and the generator test | General Prometheus behavior |
| Agent name reuse | A rebuilt droplet enrolls again under the same name | A site prefix in agent names, set through the separate log_shipping.agent_name_prefix input (the access stack never reads site_name), which you set to the same value by hand |
Built as the opt-in log_shipping.agent_name_prefix in stack 10 (<prefix>-connector-<a or b>), not applied |
| Dashboards show only some sites | The existing Twingate dashboard at home has variables for exactly two named connectors; a third host shows nothing | site and instance variables |
Read from the home stack on 2026-10-16, by role only |
| A whole site goes silent and nothing alerts | absent() cannot say which site is gone |
An expected-target inventory | See Reading a dashboard as an operator |
| The home logging connector is a single point | Every site's telemetry uses the same home-side path | Two connectors at home; the inventory alert runs at home | From the design |
| The cost gate is blind to the second site | It sees directories, not Spacelift stacks | Stack instance manifests, below | Exists, docs/cost.md |
Here is what the design says adding site-tor2 takes. Every step is data.
region or a new resource_key (for example tor2), a vpc_ip_range that overlaps nothing (the first site's range goes in reserved_ranges), a site_name, and its own list of logging servers. The shape of that file is the terraform.tfvars.example of each stack.sites map does the same job without a new stack..spacelift/config.yml entries for the new stack ids. The entry tells the hook which Doppler secrets to fetch for that stack (see Fork, private stacks and the pipeline). It is not what attaches credentials: in docs/spacelift-secrets.md (sections 4 and 8, read for this page) the cah-doppler context attaches to any stack carrying the cah label and supplies DOPPLER_TOKEN to every run type, independently of config.yml. So a new stack's label, context attachments and run policies are Spacelift settings you must control by hand.scrape_targets output covering the default site and every entry of its sites map, each with its own site label. The generator that turns it into a target file and an expected-target inventory is not built, and the inventory in the synthetic lab is written by hand.The lesson is the shape: code is the thing that does not change per site; values are the thing that does. If adding a site needs a code change, the code has a hard-coded value that belongs in a setting.
The gate (scripts/cost_check.py) finds cost.json manifests under stacks/ on disk and checks, in each stack directory, that the number of connector modules equals the number of machines listed. Two Spacelift stacks on one directory look like one stack to it, so the second site's $12 would be invisible. The fix, built and documented in docs/cost.md, is a stack instance manifest: a data-only file at stacks/sites/<resource_key>/10-access/cost.json with "instance_of": "stacks/10-access". The gate then:
.spacelift/config.yml to have exactly one manifest (config_problems() in scripts/cost_check.py), so a declared stack cannot be added without being costed. The id for the example is cah-10-access-tor2;optionally reads a sites map in approved.json, so each site is named in the approval:
"digitalocean": { "approved_monthly_total": 24.0, "active": true,
"sites": { "tor2": { "approved_monthly_total": 12.0 } } }
The gate checks declared stacks only. It cannot see a Spacelift stack that someone creates and never lists in config.yml, and such a stack is not harmless: if it carries the cah label, the context supplies DOPPLER_TOKEN to its runs whether or not config.yml mentions it (docs/spacelift-secrets.md sections 4 and 8). Stack creation, context attachment and the push and run policies have to be controlled in Spacelift; the cost gate does not do that.
The money. A DigitalOcean site carries two connectors. At the list price of s-1vcpu-1gb in docs/cost-prices.json (retrieved 2026-10-10), that is $6 + $6 = $12 per site, so two sites are $24 before any telemetry component, against the $30 shared ceiling in docs/stages/approved.json. That leaves $6. The reference environment's planned stage 3 option A is $29 on one site (docs/cost.md), so a second site and stage 3 A together are $29 + $12 = $41, which does not fit.
access-tor1, cah-tor1-admins, cah-tor1-connector-a-ssh, cah-connector-tor1, access-tor1-connector-a), which would collide if two stacks in tor1 used the default resource_key? Does anything stop the second apply?10.78.0.0/24. The home network uses 10.50.0.0/16 and 10.60.0.0/16. Which of 10.79.0.0/24, 10.50.4.0/24 and 10.78.0.0/25 may the second site use, and what must you list in reserved_ranges first?site_name = "site-tor1" on the live stack. What does the plan show? You set resource_key = "tor1-main" instead. What does it show?site a label and not a job name?terraform.tfvars.example to a scratch directory, write the values for a second site, and mark each one public, private or secret using the decision table.docs/cost.md "Stack ids and .spacelift/config.yml" and write the stack id the rule gives for stacks/sites/east/aws/10-access.Next: Telemetry crosses the trust boundary. Back to the Reading order.