Federated deployment
Monitor several remote NATS systems and see all of them in one web UI.
In a federated deployment, Insights runs next to each remote NATS system, and a hub serves the web UI. Each remote system connects to the hub's NATS server over a leafnode that carries only the account Insights uses. Its system account never leaves it, and the hub never connects to the monitored systems.
Choose what runs at each remote system
Each remote system runs one of two things. The network setup is the same for both. What differs is where the data is stored and checked.
| Insights node (recommended) | Collector | |
|---|---|---|
| Runs at the remote system | insights, the full binary | insights-collector, a smaller binary that only scrapes |
| Database and checks | At the remote system | At the hub |
| Data kept at the remote system | History for db.retention.duration | A short buffer the hub reads from |
| Runs at the hub | insights web, or any Insights node | An Insights node that stores and checks the system's data |
Run a full Insights node at a remote system unless you have a reason not to. Each one keeps its own data and runs its own checks, and nothing is copied between them.
Run a collector when a remote system can't spare the memory and disk for a database, or when monitoring data should not be kept there. The hub then reads its scrape stream across the leafnode and does the storage and checks. The collector has no DuckDB, no web UI, no Prometheus endpoint, and no embedded NATS server. It scrapes, publishes to a stream, and serves the part of the $INS API that needs no database.
You can mix both in one deployment.
If a hub node can reach a monitored system directly, it doesn't need either: list the system under systems: with a scrape: block and the node scrapes it itself. See Multiple Systems on One Node.
Connect the remote systems
Every remote system needs the following, whichever option it runs:
- A NATS server at the remote system with JetStream enabled and its own JetStream domain.
- A NATS server at the hub with JetStream enabled and a different domain.
- A leafnode from the remote system to the hub that carries the account Insights uses. This guide calls that account
INS. Its system account is not bridged. - A unique
system.idfor each remote system, and a uniquenode.idfor each Insights process. This guide useseastfor a remote system with an Insights node andwestfor one with a collector. - Network access from each remote system to the hub on the leafnode port (
7422by convention). The hub never connects to them. - Insights 1.3 or later in every Insights process, at the hub and at each remote system. Upgrade each remote system's collector or node before the hub. A hub node takes on a remote system only once its collector or node runs 1.3, because it learns of the system from a heartbeat 1.2 does not send.
The nats CLI commands below were written against v0.4.x.
The system id names everything Insights creates for that system: the $INS.sys.<id>.* API, the scrape_<id> stream, and its subjects, $INS.sys.<id>.scrape.>. Because every subject includes the id, remote systems can share the INS account without their subjects colliding. The subject namespace is never configured.
This is not access control: any user in the account can query every remote system. If they must not see each other's data, give each Insights user permissions scoped to its own system (see Insights Permissions) Separate accounts per system would also stop the hub web UI from finding them, because it discovers and queries them within one account.
Remote system NATS server
A domain is how JetStream tells two JetStreams apart over one leafnode: a stream in one domain is reached from the other through the domain's API prefix, $JS.<domain>.API. Give each remote system's domain the same name as its system id, so $JS.west.API clearly refers to west. Nothing requires it, but with several systems the alternative is remembering which domain is which.
Bridge only the INS account:
# west.conf
server_name: west-1
listen: 0.0.0.0:4222
jetstream {
domain: west
store_dir: /data/nats/jetstream
}
leafnodes {
remotes = [
{
url: "nats-leaf://insights:insights-password@hub.example.com:7422"
account: INS
}
]
}
accounts {
INS: {
jetstream: enabled
users: [ { user: insights, password: insights-password } ]
}
SYS: {
users: [ { user: sys, password: sys-password } ]
}
}
system_account: SYS
Two accounts matter here:
| Account | Holds | Reachable from the hub |
|---|---|---|
SYS | The monitored system's system account, which Insights scrapes | No |
INS | The scrape stream and the $INS.sys.<id>.* API | Yes |
Insights at the remote system holds a connection to each: it reads from SYS locally and writes to INS. Only INS crosses the leafnode.
The examples on this page use passwords to stay short. In production, use your usual NATS authentication, such as JWT credentials, and point Insights at it with creds or context.
Sharing an account is not sharing a JetStream. The domains separate the two JetStreams and the account separates the traffic. A leaf server with no jetstream block does not gain one by being bridged into a JetStream-enabled account.
Hub NATS server
The hub NATS server runs JetStream under its own domain, accepts leafnode connections, and defines the same INS account. A leafnode joins the account of the user it logs in as, so remote systems that log in as insights join only that account.
# hub.conf
server_name: hub-1
listen: 0.0.0.0:4222
jetstream {
domain: hub
store_dir: /data/nats/jetstream
}
leafnodes {
port: 7422
}
accounts {
INS: {
jetstream: enabled
users: [ { user: insights, password: insights-password } ]
}
}
Insights permissions
If you restrict the users Insights connects with, this is a working baseline for a remote system's node, a collector, or a hub node. It is the same connection shape as any external NATS server, described in Sink connection permissions:
permissions {
publish {
allow = [
"$INS.>", # scrape data, discovery, and the Insights API
"$JS.API.>", # stream management
"$JS.FC.>", # flow control replies
"_INBOX.>" # request replies
]
}
subscribe {
allow = [
"_INBOX.>", # request replies
"$INS.>", # discovery and the Insights API
"$SRV.>" # NATS service discovery
]
}
}
Everything Insights owns is under $INS, including the scrape stream, so the grant doesn't have to list it. To limit a connection to one system, replace $INS.> with $INS.sys.<id>.>, $INS.node.<node_id>.>, $INS.systems and $INS.ping.
Remote system permissions
The hub node, the Insights node remote systems report to, reads each one across its leafnode. The user that leafnode logs in as on the hub NATS server decides what crosses. Give each remote system its own user, scoped to its system id, so it can report only as itself: a heartbeat published at east under west's id never reaches the hub. For a leafnode user, publish is what the remote system sends to the hub, and subscribe is what the hub sends to the remote system:
| Subject | For | |
|---|---|---|
| publish | $INS.sys.<id>.> | The heartbeats and epochs the hub follows the remote system by |
| publish | _INBOX.> | Replies to the hub's requests, and the stream messages it reads |
| subscribe | $INS.node.*.ping | The identity check a hub node makes at start, which finds a remote system's node already using its node.id |
| subscribe | $INS.sys.<id>.> | The remote system's API: ops.sink.info, which reports its JetStream domain, the ping a hub web UI reads its name and labels with, and the web UI's queries |
| subscribe | $JS.<domain>.API.> | The hub's reads of the findings stream of an Insights node, or the scrape stream of a collector |
The same grants serve an Insights node and a collector. Drop any but $INS.node.*.ping and the hub stops taking on or reading the remote system. Without that one, a hub node that shares a node.id with a remote system's node starts anyway, and can then take for its own the catalog that node holds. For a collector read through an api-prefix, subscribe to <api-prefix>.> in place of $JS.<domain>.API.>.
The hub's own user needs no grant on these subjects beyond the baseline, except to publish $JS.<domain>.API.>, or <api-prefix>.>, for each remote system it reads.
Operator mode
Issue every remote system's user from one scoped signing key whose template takes the system id from a system tag on the user. Adding a remote system is then one new user, with no change to the account:
nats auth account keys add INS remote-system \
--pub-allow '$INS.sys.{{tag(system)}}.>' \
--pub-allow '_INBOX.>' \
--sub-allow '$INS.node.*.ping' \
--sub-allow '$INS.sys.{{tag(system)}}.>' \
--sub-allow '$JS.{{tag(system)}}.API.>'
nats auth account push INS
# one user per remote system, tagged with its system id
nats auth user add west INS --key <SIGNING_KEY> --tags system:west --defaults
nats auth user credential west.creds west INS
The template assumes each remote system's JetStream domain is its system id, as recommended above. NATS lowercases tag values, so it also needs lowercase ids. Issue a user that doesn't fit, such as one for a collector read through an api-prefix, with its own grants on nats auth user add instead of --key.
The remote system's leafnode logs in with the credentials:
leafnodes {
remotes = [
{
url: "nats-leaf://hub.example.com:7422"
credentials: "/etc/nats/west.creds"
account: INS
}
]
}
Server config
In the hub NATS server's config, add a user per remote system to the INS account, and log the remote system's leafnode in as it (nats-leaf://west:west-password@hub.example.com:7422):
accounts {
INS: {
jetstream: enabled
users: [
{ user: insights, password: insights-password }
{
user: west, password: west-password
permissions {
publish { allow = [ "$INS.sys.west.>", "_INBOX.>" ] }
subscribe { allow = [ "$INS.node.*.ping", "$INS.sys.west.>", "$JS.west.API.>" ] }
}
}
]
}
}
Node ids
Each Insights process checks its identity at startup by asking whether anyone already answers its node id ($INS.node.<node_id>.ping) or a system it serves ($INS.sys.<id>.ping). Under the remote system permissions, both are answered across the leafnode when the hub node asks, but not when a remote system's node does, so a clash between the two is caught when the hub node starts. A node's node.id defaults to its system id when it serves one system, so two processes serving the same system clash unless at least one is named. A hub has no default: it must set node.id, and each hub needs its own (see Failover). The node that finds the clash stops with:
node.id "west" is already in use on this NATS
Sharing a system id is fine when the roles differ: a collector holds the system's scrape role and the hub node its catalog role.
Option 1: Insights node at each remote system
The node at a remote system is an ordinary single-system Insights node. It scrapes the system, stores the data, and runs checks. What makes it part of a federation is its connection to the INS account on the system's NATS server, and turning off the embedded NATS server so its stream lives on that server. There is no federation-specific config:
# east.yaml, run with: insights -c east.yaml
node:
id: east
system:
id: east
data-dir: /var/lib/insights
# The INS account on the remote system's NATS server. The hub reaches this
# node's API through the leafnode.
nats:
server: nats://east:4222
user: insights
password: insights-password
# The system account, which is what Insights monitors.
sys:
server: nats://east:4222
user: sys
password: sys-password
sink:
embed: false
A trial build also needs a license: section on every remote system's node.
That node can also serve its own web UI. Leave web enabled if people at the remote system should use it directly.
At the hub, run a web UI connected to the hub NATS server's INS account. It needs no database and no license:
insights web \
--server nats://hub:4222 \
--user insights --password insights-password \
--web.hostname 0.0.0.0
The web UI follows the heartbeats and epoch announcements every system sends on the shared account, and lists each system with a catalog on its Systems page within seconds of it first reporting, with no restart. It asks a system for its name, labels and capabilities when it first hears it, and again only when its name or labels change. A hub node, one with a remotes: block or a systems: list, does the same. A node serving one system with the flat system: config shows only its own system, so to see every system at the hub, run insights web there or use a hub node's web UI.
Give every web UI at the hub, each insights web and each hub node's, the same web.session-seed. Behind a load balancer or under one hostname a browser's requests reach several of them, and a node whose seed differs from the one that signed the session cookie starts a new session (see All-in-one (persistent)).
Check that every remote system is reachable from the hub:
insights system list --server nats://hub:4222 --user insights --password insights-password
insights db query --server nats://hub:4222 --user insights --password insights-password \
--system east "SELECT count(*) FROM hx.servers"
Notifications from the hub
Each remote system's node delivers its own notifications by default, so each needs the endpoints in its config. To configure endpoints only at the hub, run an Insights node there with a remotes: block. It takes on each remote system as it first hears it, so adding one needs no change at the hub:
# hub.yaml, run with: insights -c hub.yaml
node:
id: hub # required on every hub, and unique to each
data-dir: /var/lib/insights
# The INS account on the hub NATS server.
nats:
server: nats://hub:4222
user: insights
password: insights-password
sink:
embed: false
remotes:
# Which remote systems to take on. Leave accept out to take on all of them.
accept:
- { env: prod }
- { id: "ship-*" }
notifications:
alertmanager:
- name: am
url: http://alertmanager:9093/api/v2/alerts
subscriptions: ["*"]
Then remove the endpoints from each remote system's own config, or each alert is delivered twice. Nothing stops either side, but a hub node that relays a remote system to its own endpoints logs a warning, naming the system's node, if that node still has an endpoint delivering it. It checks when it starts reading the system and again after any gap in its read. A systems: list beside remotes: holds the systems the hub node scrapes itself; like systems:, the block can't be combined with the flat system.id and sys: config. A trial build needs a license: section here too.
A remote system's node publishes a heartbeat for its system on $INS.sys.<id>.feed.heartbeat every 15 seconds. When the hub node first hears one for a system it does not scrape, index or already act for, it reads the system once: its labels, the system's own system.metadata, from its $INS.sys.<id>.ping reply, and its JetStream domain from $INS.sys.<id>.ops.sink.info. A read that fails, as it does while that node is still starting, is tried again on the next heartbeat. It takes the system on when:
- a node checks the system and its findings stream,
findings_<id>, is on the system's JetStream domain. A collector whose system no node checks yet is a collector-fed system, which the hub node indexes itself; see Hub node config. - the system's JetStream domain is not the hub node's own. A system on the hub node's own JetStream belongs to another hub node, which delivers its own notifications.
- an
acceptentry matches the system. A map must match on every key, and any one entry in the list is enough. Values take*as a wildcard,"*"alone asks that the label be present, andidmatches the system id. Withoutaccept, every remote system is taken on.
The node logs took on remote system with the entry that matched. A remote system it turns down is logged at debug level with the reason, and read again within 10 minutes, so one restarted with new labels is taken on then. Once taken on, a system stays with the node: changing accept later does not drop it, so move or remove it instead.
A system taken on is expected from then on: the node keeps acting for it while it is dark and across restarts, and raises system-012 when it stops reporting, until it is removed.
The hub node keeps no copy of a remote system's findings. It asks the system's node for its JetStream domain on $INS.sys.<id>.ops.sink.info, then reads its findings_<id> stream across the leafnode through that domain. On start, and whenever it loses the system, it reads the current findings again and brings each receiver up to date with them. A finding a receiver holds that the system no longer reports is resolved, however long ago it was resolved there. Between those reads it delivers each change as the system stores it.
While a remote system is out of reach, the hub node keeps re-sending its last known alerts to alertmanager and servicenow endpoints each minute, so they don't expire. Each carries a data_as_of annotation with about when the hub node last heard from the system. A remote system whose NATS server shuts down is noticed at once; one that crashes, enters lame duck or is cut off, as by a network partition, after about 30 seconds. Nothing is resolved while it is out of reach, since silence is not evidence that a problem is fixed. A hub node that restarts while a remote system is out of reach holds nothing for it until it returns, so alertmanager and servicenow let its alerts expire; the other types keep what they hold.
A remote system cannot report that it has gone silent, so the hub node evaluates System Not Reporting (system-012) for each one itself, from the heartbeat the system publishes and the epochs it announces on $INS.sys.<id>.feed.epoch. It fires as it does on the system itself: at once on a scrape error or a license stop, and once no epoch has arrived for max_age, going critical after critical_age. Its detail says whether the heartbeat stopped, the heartbeat arrives but no epochs do, or the scraper reports an error. A leafnode that drops for less than max_age raises nothing, and a hub node that starts during an outage counts from its own start and pages every endpoint, even for a system it has never reached. It is one alert with the system's own system-012: while the hub node reads the system, the system's is delivered whenever it fires, and while the system is out of reach the hub node's takes its place and is re-sent as current, without data_as_of. It resolves once the system is heard committing epochs again, with the detail the remote system is reporting again. Its thresholds come from the hub node's top-level check-thresholds, overlaid by remotes.check-thresholds, which may set only system-012. The node evaluates it each minute, so set critical_age at least a minute past max_age, or the finding can go critical without first raising a warning; the node logs a warning at startup when it is not. The top-level disabled-checks turns it off.
An endpoint can select remote systems by their labels, which the hub node reads from each system's $INS.sys.<id>.ping reply each time it starts reading it. See Scoping to systems.
If you restrict the user a remote system's leafnode logs in as, grant it the remote system permissions. Without the subscribe grant on $INS.sys.<id>.>, the hub node reads no remote system's labels: it takes on no remote system, and a node whose endpoints or label rules select systems by label never reads one it acts for, logging read the remote system's labels.
One hub node per remote system
Several hub nodes can share one INS account, but only one may act for each remote system, or every alert is delivered twice. The remotes key-value bucket on the account's JetStream holds one entry per remote system: the node bound to it, whether it is active, released or being removed, any move under way, its labels and JetStream domain, and the accept entry that matched it. A node takes a system by creating its entry, or by taking over a released one. Each write is conditional on the entry being as the node last read it, so when several nodes hear a system at once, exactly one takes it and the others leave it alone. A node restarted under the same node.id keeps its remote systems, including any that are out of reach, as long as it is back before its lease expires.
A node that cannot reach the bucket at startup starts anyway, logs a warning, and keeps trying. A sink that can never hold sink.replicas replicas, a server outside a cluster asked for more than one, stops it starting instead. When a remote system reports a JetStream domain another entry already holds, the node binds it and logs a warning: a node that scrapes several systems reports one domain for all of them, but so does a system whose id changed, and its old id stays bound and reads as a system that stopped reporting. Remove the old id if that is the case.
Failover
Each hub node keeps a lease in the same remotes key-value bucket, under node.<id> beside the bindings under system.<id>: one entry per node, rewritten every 15 seconds and expiring 45 seconds after the last write. A binding stays with its node while that lease is live. A clean shutdown leaves the lease to expire rather than deleting it, so a hub restarted within 45 seconds keeps every remote system: it takes the lease back once its previous run has gone 20 seconds without renewing it. Each write is conditional on the lease being as the hub last wrote it, so two hubs given the same node.id cannot share one. The hub started second logs this node's id is in use by another hub with the id and acts for no remote system until the other stops, while the running hub carries on. The lease is written with a per-message TTL, which needs nats-server 2.11 or later. The TTL runs on the clock of the server leading the bucket's stream, so the clocks of the servers holding the bucket must agree within 15 seconds.
The bucket, and the webhook-open and webhook-deliveries streams hub nodes share, have sink.replicas replicas, and each node scales them to its own value when it starts, so give every hub node the same one. On a clustered hub set it to 3. With one replica, a restart of the server holding them stops every hub node relaying within 30 seconds, and if the server is down for more than 45 seconds every lease has expired when it returns, so every relay system fails over at once.
When a node's lease expires, the other hub nodes take over its relay systems, dark ones included, so system-012 keeps paging for a system that went silent with its node. A crashed node's systems move within 45 seconds of the crash, and their alerts wait until they do.
- Only a node whose
acceptmatches the labels stored with the system takes it. If no live node matches, the system stays with its node, andinsights remotes listshows the expired lease. - The takeover is conditional on the entry as each node read it, so exactly one node takes each system.
- A collector-fed system does not fail over: its node holds the only copy of its catalog, and it moves only when you move it (see Moving remote systems). A restarted node indexes it from the catalog's latest epoch, so what the collector scraped meanwhile is indexed then, as long as the collector's stream still holds it, and a lease expiry leaves it bound where it is. A node cut off from the bucket keeps indexing its collector-fed systems; only relay delivery stops.
- A node with no notification endpoint enabled takes on no relay system, by failover or otherwise. Restarted that way, it releases the relay systems bound to it, since it can deliver nothing for them while its lease stays live, and keeps its collector-fed systems.
A node delivers only while its lease is live by its own clock. A failed lease write is retried every second and a half, so one failure, during a JetStream leader election say, changes nothing. Once 30 seconds pass without a lease write landing, it stops relaying and drops what it had queued, sending nothing beyond a delivery already under way, so a node cut off from the bucket stops at least 15 seconds before another node can see its lease expire. When a write lands again, it resumes the systems still bound to it and leaves those another node took over, resolving nothing.
Lame duck
Before restarting a hub node for an upgrade or maintenance, put it in lame duck, so its relay systems are delivered by other nodes while it is down:
insights node lameduck hub-1 --server nats://hub:4222 --user insights --password insights-password
Sending SIGUSR2 to the insights serve process does the same, as it does for nats-server. In lame duck the node:
- asks another node to take each relay system, picking, of the live nodes not in lame duck that have a notification endpoint enabled and whose
acceptmatches the system, the one holding the fewest. It keeps delivering each until that node accepts it, as described in Moving remote systems. - keeps a relay system no other node would take, delivering it as before, and hands it off when such a node starts.
- keeps its catalog systems.
- takes on no system, takes over none from a node whose lease expires, and refuses any moved to it, until it restarts.
- keeps running until it is stopped. Its lease shows
lameduck.
A node asked while it is still starting enters lame duck as soon as it begins acting for remote systems, before it can take one on.
The command waits up to 30 seconds (--wait) until no relay system is bound to the node, then says so. A restarted node comes back active, holding only what is still bound to it.
On Kubernetes, a preStop hook puts the node in lame duck before the pod is sent SIGTERM. The official images have no shell, so the hook runs the CLI from the image, which waits for the handoff; keep terminationGracePeriodSeconds longer than its --wait:
lifecycle:
preStop:
exec:
command: ["/usr/local/bin/insights", "-c", "/etc/insights/insights.yaml", "node", "lameduck", "hub-1", "--wait", "20s"]
In an image with a shell, kill -USR2 1 followed by a sleep does the same without the CLI.
Moving remote systems
insights remotes move moves one remote system to another node. With --to it goes to that node, which must be live, not in lame duck, have an accept that matches the system and, for a relay system, have a notification endpoint enabled. Without it, it goes to the node lame duck would pick. The move is written to the system's entry, so it survives either node restarting, and every handoff, whether from lame duck, a move, a rebalance or a node removal, runs in the same order:
- The target checks that it would take the system and marks the move
acceptedon the entry. A target that will not take it records why instead, andinsights remotes listshows either in theMOVEcolumn. A target with no notification endpoint enabled refuses a relay system, whose findings it would deliver nowhere. It takes a catalog system, whose catalog is still worth indexing, and logs a warning naming it, since hub nodes are expected to share their endpoint config. - The owner sees the acceptance, stops delivering the system without sending anything, and binds it to the target, in one write conditional on the entry as it read it.
- The target starts delivering when it sees itself bound. Like a node taking over after a failure, it reads the system's current findings and what the receivers hold, and sends only the difference.
A handoff is therefore a gap rather than an overlap, usually seconds, longer while a receiver or the target is slow: the owner waits out a delivery already under way before it stops, and a target busy reading a system that does not answer sees the handover late. A finding that changes during it is delivered once, by the target, so nothing is lost and nothing is sent twice. A system out of reach when it moves is like one out of reach when its node restarts: the target holds nothing for it until it returns, so alertmanager and servicenow let its alerts expire. If the owner stops before it hands the system over, the system fails over when the owner's lease expires. If the target's lease expires first, or it enters lame duck, the owner clears the move and keeps the system. The command waits up to 30 seconds for the move; --no-wait returns once it is written.
Before it writes the move, insights remotes move warns, and insights node remove does the same for each system it moves, when the owner and the target deliver to different notification endpoints, when the target's config does not set the api-prefix the owner's reads a catalog system's stream through, and when either node does not answer to be compared. For a catalog system it says about how much the copy will be. The warnings never stop the move. See insights remotes.
A remote system taken on stays with its node, so a node added later gets nothing until one moves. insights remotes rebalance plans moves from the busiest live nodes to the least busy until their counts differ by at most one, counting every system and moving relay systems before catalog systems, each to a node that accepts it, and makes them. --dry-run prints the plan only.
A remote system fed by a collector moves with its catalog, copied in two phases over $INS.sys.<id>.db.backup.stream. First the target copies the catalog's history while the owner keeps indexing, every table pinned to the latest epoch the owner had committed when the copy started, and marks the move copied. The owner then holds indexing, committing no epoch while it goes on answering queries, and marks the move held. The target copies what the owner committed after the pin, and copies whole the tables the owner rewrites in place rather than appends to: the indexer's cache, main.ips and service-002's state. Once the copy is in place the target accepts, the owner stops and binds the system to the target, and the target reads the collector's stream on from the copy's latest epoch, which is the owner's last. The hold lasts only as long as the second phase, usually seconds, and the owner logs how long it held. A hub holds for at most 5 minutes; past that, or if either hub restarts during the hold, the move fails and the owner indexes again. The old owner keeps its catalog until the target commits its first epoch from the copy, which it announces on $INS.sys.<id>.feed.epoch, and then deletes it, so a copy that will not open still has a source. The first phase takes as long as streaming the catalog's history does, so pass a longer --wait for a large one. If the copy fails or is cut short, the target deletes it, the system stays with its owner, and the move records why as it does any refusal. A hub whose lease has expired cannot be copied from; see Retiring a hub node.
Retiring a hub node
insights node remove retires a node for good. On a running node it asks another node to take each catalog system, as insights remotes move does, puts the node in lame duck and waits until nothing is bound to it, then says it can be stopped. It refuses before asking anything when no other live node would take one of the catalog systems.
A node whose lease has expired can hand nothing off. Its relay systems that a live node accepts were taken over when the lease expired; the rest stay bound to it, so system-012 keeps paging for them once a node that accepts them starts. insights node remove --force releases its catalog systems, so a node that hears one and accepts it takes it on. Each new owner rebuilds the catalog from what the system's stream holds, so the command prints, for each, how far back that stream goes: older history is lost. A remote system whose systems: entry sets api-prefix is read through the prefix the live hubs' configs set for it, since its collector can't report that route; every hub that may take it over needs that entry in its config anyway, to read the stream. Without --force the command refuses while there is a catalog system to release, and --force is refused while the node's lease is live. A node just stopped or crashed keeps its lease for up to 45 seconds; until then the command says the node has stopped, when its lease runs out, and to run it again then.
Removing remote systems
Removing a remote system marks its entry removing. The node bound to it resolves everything its receivers hold for the system, system-012 included, deletes a collector-fed system's catalog, and deletes the entry once every receiver that keeps a record of open alerts has accepted the resolves, so such a receiver that is down keeps the entry removing until it is back. A node that is stopped, or that stops before then, finishes the removal when it starts; if its lease expires first, the node that takes the relay system over finishes it instead. A node finishing a removal for a system it is not relaying resolves what the open-alert records name, so alertmanager and servicenow receivers, which keep no record, let its alerts expire. Stop the system first: nothing refuses to remove one that is still running, and a system still heard is taken on again by a node that would accept it.
insights remotes remove waits up to 30 seconds (--wait) for the entry to go, and exits non-zero if it hasn't, as while a receiver that keeps a record of open alerts is down; the removal stands. When the bound node is not running, it says so and returns at once, leaving the removal for that node. That includes a node stopped so recently that its lease has yet to run out, which answers no discovery: the command says when the lease runs out and who finishes the removal. If that node is gone for good and no live node's accept matches the system, --force deletes the entry with nothing resolved, so its receivers keep what they hold for the system until it expires or is cleared there. It is refused while the node's lease is live.
# Who acts for each remote system.
insights remotes list --server nats://hub:4222 --user insights --password insights-password
# Move east to hub-2, or let rebalance spread them.
insights remotes move east --to hub-2 --server nats://hub:4222 --user insights --password insights-password
insights remotes rebalance --dry-run --server nats://hub:4222 --user insights --password insights-password
# hub-1 is being retired: hand off everything bound to it.
insights node remove hub-1 --server nats://hub:4222 --user insights --password insights-password
# east is decommissioned: remove its entry and resolve its alerts.
insights remotes remove east --server nats://hub:4222 --user insights --password insights-password
The node that takes over a remote system reads what the last one left each webhook, splunk-oncall and datadog receiver holding (see Restarts), so it resolves what cleared in between and doesn't fire again what is still firing. Hub nodes share that record because they share the hub's JetStream domain; a remote system's node on its own domain keeps its own. The record is keyed by endpoint name, so hub nodes may define different endpoints, but one name must never point at two different receivers. Nothing checks this. The delivery log is shared the same way and keyed the same way: an endpoint's page on any hub node lists what every node delivered to that name, for every system, with the node that delivered each.
The bucket is written by publishing to $KV.remotes.>, which the baseline permissions do not cover. Add it to the publish allow list of the hub node's user. The user you run insights remotes move, rebalance and remove, and insights node remove, as needs $KV.remotes.> too; insights node lameduck and insights node remove also publish the request $INS.node.<node>.ops.lameduck, insights remotes list publishes $INS.systems, or $INS.ping where no node keeps the fleet table, insights node remove --force asks each live hub $INS.node.<hub>.ops.remotes, and insights remotes move and insights node remove ask each move's owner and target the same and a catalog system's owner $INS.sys.<id>.ops.storage, all of which $INS.> covers.
Option 2: Collector at a remote system
A collector scrapes the remote system and publishes the data to a stream on that system's NATS server. A hub Insights node reads that stream across the leafnode, stores the data and runs checks. The hub keeps no copy of the stream.
The collector is the insights-collector release archive, the -collector image tag (registry.synadia.io/insights:1.2.2-collector), or task build:collector from source.
Collector config
The collector monitors one system, so it uses the single-system config with no systems: list:
# collector.yaml, run with: insights-collector -c collector.yaml
node:
# Must differ from the hub node's node.id.
id: west-collector
system:
# Unique on the account: it names the stream and the $INS.sys.<id>.* API.
id: west
# The labels a hub node's remotes.accept selects this system by.
metadata:
env: prod
# The INS account on the remote system's NATS server, where the scrape stream lives.
nats:
server: nats://west:4222
user: insights
password: insights-password
# The system account, which is what the collector scrapes.
sys:
server: nats://west:4222
user: sys
password: sys-password
scraper:
interval: 1m
sink:
# How much data the stream keeps, and so how long the hub node can be
# down without a gap. See Retention below.
retention: 6h
# A trial build also validates a license:
# license:
# file: /etc/insights/license.jwt
Run it with insights-collector -c collector.yaml. serve is the collector's default command, so insights-collector serve -c collector.yaml does the same thing. From the collector image, with collector.yaml and the files it names mounted at /etc/insights:
docker run -v /path/to/collector:/etc/insights:ro \
registry.synadia.io/insights:1.2.2-collector \
-c /etc/insights/collector.yaml
The collector reads only the node, system, nats, sys, scraper, sink, mask, license, updater, telemetry, and data-dir settings, plus log-level. It has no database or embedded stream store, so it doesn't need a data directory. If no NATS server is configured, it stops at startup:
collector requires an external NATS sink: set --server (or --context, or --scraper.nats.server) to the local leafnode that stores the scrape stream and serves the $INS API
To keep the remote system's names, text and addresses out of what reaches the hub, turn on masking on the collector.
See the collector build reference for what the binary includes, and insights-collector serve for its flags.
The scrape stream
On startup, the collector creates the scrape_west stream on the remote system's NATS server with the subject $INS.sys.west.scrape.>. It derives the name from system.id; an explicit sink.stream still wins. If the stream already exists, the collector uses it without changing it, so a stream you created keeps your limits.
To replicate the stream, run a clustered NATS server at the remote system and set sink.replicas (and sink.storage for the storage class):
sink:
replicas: 3
storage: file
To create the stream yourself instead, run this against the remote system's NATS server:
nats stream add scrape_west \
--subjects '$INS.sys.west.scrape.>' \
--storage file \
--retention limits \
--discard old \
--replicas 1 \
--defaults
The stream must carry exactly one subject, $INS.sys.<id>.scrape.>. The collector publishes every epoch under that namespace and doesn't inspect a stream it finds, so a stream that captures anything else stores none of its scrapes.
Hub node config
A hub node takes on a collector-fed system by learning it. A remotes: block takes on the systems its accept selects, as it takes on full-node systems; a systems: entry without a scrape: block takes on one system by id, with settings of its own. With a remotes: block, the node knows nothing about a system in advance, so adding one needs no change at the hub:
# hub.yaml, run with: insights -c hub.yaml
node:
id: hub # required on every hub, and unique to each
data-dir: /var/lib/insights
# The INS account on the hub NATS server.
nats:
server: nats://hub:4222
user: insights
password: insights-password
# The remote systems' leafnodes join the hub NATS server, not an embedded one.
sink:
embed: false
db:
memory-limit: 4GiB # per collector-fed system
# A trial build also validates a license here, since this node indexes:
# license:
# file: /etc/insights/license.jwt
remotes:
# Which remote systems to take on, by the labels each collector reports in its
# system.metadata, or by id. Leave accept out to take on all of them.
accept:
- { env: prod }
- { id: west }
The collector's system.id is the only value the two configs share: the collector's scrape_west stream and the $INS.sys.west.* subjects follow from it. Give the collector the labels the hub node's accept selects it by. The two nodes need different node.id values; see Node ids.
When the hub node hears a heartbeat from a collector whose system no node checks, and accept matches the collector's labels, it binds the system to itself in the account's remotes key-value bucket with kind collector. It then creates the catalog, systems/<id>.db under its data directory, and indexes the collector's stream, all while it runs. Its pages appear in the web UI under the display name the collector reports in its system.name, and its $INS.sys.<id>.* API answers without a restart. The labels stored with the binding, the ones the collector reported when it was bound, route its notifications and select its overrides.
A collector-fed system's catalog stays with the node that built it. A restarted node takes its collector-fed systems back from the bucket and indexes each from its catalog's latest epoch, so what the collector scraped while the node was down is indexed then, as long as the collector's stream still holds it. insights remotes list shows the kind of each remote system, and as unbound a collector no hub has taken on, with the labels it reports. insights remotes remove <id> stops indexing the system and deletes its catalog; turn the collector off first, or the node takes it on again at its next heartbeat. A node whose own systems: list scrapes a system under the same id indexes that system from its config and leaves the binding alone. Two catalog nodes for one system split its queries between databases holding different data, so a node does not start a collector-fed system whose catalog another node already holds.
Nothing indexes a collector no hub has taken on, so once it has gone max_age unbound a hub raises System Not Reporting (system-012) for its system, critical after critical_age. Of the hubs with an enabled notification endpoint subscribed to system-012, and system-012 on, the one that has run longest raises it, so it pages once however many hubs run, and the next takes over when that hub stops or enters lame duck. The hub raising it records in the remotes bucket, under unbound.<id>, when it first found each collector unbound and the labels it reports, so the next hub, or the same one restarted, keeps the alert's age and severity. Its detail names the collector's node and the labels it reports, which no hub's accept matched. A hub learns of a collector from its heartbeat, which a collector on a release before 1.3 does not send, so no hub sees one: it is neither taken on nor paged for until it runs 1.3. Once a hub takes the collector on, that hub's first recovery resolves the alert, as long as it shares the endpoint's name; a collector whose heartbeat stops, for 45 seconds, has it resolved three minutes after that, or, if the hub restarts meanwhile, three minutes after it starts. Its unbound.<id> record stays until every receiver that keeps a record of open alerts has accepted the resolve, so a hub that restarts before then resolves it again. Its thresholds come from check-thresholds overlaid by remotes.check-thresholds, as a relay system's do. The election does not weigh an endpoint's systems selector, so give the hubs endpoints that match every collector's labels, or a collector outside them pages nowhere.
A node that runs neither a remotes: block nor a systems: entry without a scrape: block acts for none of the remote systems bound to it, and takes no lease. Add one back, or delete each system with insights remotes remove <id> --force.
One remote system by id
A systems: entry with a scrape: block is a system the hub node scrapes itself. An entry without one names a remote system:
systems:
- id: west
db: { memory-limit: 8GiB }
disabled-checks: [stream-010]
The node takes on west when it hears its collector, as a remotes.accept entry { id: west } would, and applies the entry's db, check-thresholds, disabled-checks, metadata and api-prefix to it. The entry can stand alone or sit beside a remotes: block. An entry without a scrape: block makes the node a hub, so it needs its own node.id. See the systems configuration reference.
Per-system overrides
A collector-fed system takes the hub node's top-level db, db.retention.duration, check-thresholds and disabled-checks. remotes.overrides sets them for the groups of systems each entry selects, and a system's own systems: entry sets them for that system:
remotes:
accept:
- { env: prod }
overrides:
- systems: [{ region: us-west }]
retention: 720h
db: { memory-limit: 4GiB }
check-thresholds: { system-012: { max_age: 2m } }
disabled-checks: [stream-010]
systems selects systems as an endpoint's systems and accept do, by labels or id; left out, the entry applies to every collector-fed system. retention is how long the system's catalog keeps history; the stream is the collector's to size, under its own sink.retention. Entries apply in order over the top-level settings, and a system's systems: entry over them, since it names one system: a later one wins per key, check-thresholds per check code, and disabled-checks add up. Overrides apply only to collector-fed systems. A relay system's checks run at that system under its own config, and its system-012 thresholds come from remotes.check-thresholds. Settings for one system, its api-prefix among them, belong on its systems: entry. An override entry with any other key, or one that names by id a system in the node's own systems: list, is a config error.
The node reads the overrides when it starts a system's catalog, so a change takes effect when the node restarts.
How the hub node reads the stream
The hub node asks the collector for its stream details over $INS.sys.west.ops.sink.info: the stream name, JetStream domain, and scrape interval. It reads the stream through the system's domain, $JS.west.API, with a consumer on that stream, unless the system's systems: entry names another route. It creates no stream for the system.
If the collector hasn't answered yet, or its stream doesn't exist yet, the hub node logs waiting for the scrape side at debug level and tries again every 15 seconds. Each system waits separately, so one unreachable collector doesn't hold up the others.
A remote system without a JetStream domain
If you reach the remote system's JetStream through a subject mapping or an account import instead of a domain, the collector can't report the prefix, because the mapping rewrites the subject before it reaches the collector's side; it reports no domain. Name the prefix on the hub node, in the system's systems: entry (examples/deployments/collector-topologies/02-mapped-prefix shows this arrangement):
systems:
- id: west
api-prefix: JS.west.API
The hub node then reads the stream through JS.west.API in place of the domain. A prefix reaches one system's JetStream, so it is set on that system's entry, never on a remotes.overrides entry, which selects a group.
A remote system with neither a domain nor a prefix is read through $JS.API, the hub node's own JetStream, where the collector's stream is not. The hub node waits for it there, or, if a stream of that name captures other subjects, logs that it does not reach the collector's JetStream.
Retention
The collector's sink.retention limits how much data its stream keeps. The collector removes whole epochs, oldest first, so the indexer never reads half an epoch. The streams Insights creates have no max_age, so nothing else bounds them. A stream you created with --max-age keeps it. That works, but the oldest epoch can then be cut in half instead of removed whole.
The hub node's database keeps history for db.retention.duration (32 days by default), or the retention a per-system override sets. Until the hub node has stored an epoch, the collector's stream holds the only copy, so the collector's retention bounds two things:
- How long the hub node can be down without a gap. When it comes back, it resumes from the latest epoch it stored; an epoch the stream removed in the meantime is not stored.
- How much history a new hub node, or one with a new database, can rebuild: what the stream still holds.
Check the read
Look at the collector's stream from the hub. While the hub node is reading it, the stream has a consumer:
nats stream info scrape_west --js-domain west
Confirm that new epochs are stored:
insights db query --system west "SELECT max(epoch) FROM hx.servers"
The result should advance with each scrape. insights node list shows both nodes: the collector holds one system as scrape and the hub node one as catalog; see Selecting a system or node. The hub node's web UI serves the system under /systems/west/.
If no new epochs are stored, check:
- The collector.
insights node listshows the collector only while it is running and reachable from the hub. - Permissions. The hub node's user must be able to publish to
$JS.west.API.>across the leafnode and receive the replies. See Permissions for the read. - The leafnode. Nothing is read while the leafnode is down. Check
nats server report connectionsor the server logs on both sides. The hub node notices a drop within seconds and resumes from the latest epoch it stored once the leafnode is back.
Permissions for the read
The hub node reads the collector's stream itself, through the remote system's JetStream API across the leafnode: it looks up the stream, creates a consumer on it, pulls from it, and deletes the consumer when it stops. The messages arrive on the hub node's _INBOX.>. With the INS account bridged and JetStream enabled on both sides, as above, this works without extra configuration. The examples use this arrangement.
If you restrict the hub node's user, add $JS.<domain>.API.> for each collector-fed system to its publish allow list, or <api-prefix>.> for one read through an api-prefix; the baseline already covers _INBOX.>. If you restrict the user a remote system's leafnode logs in as, grant it the remote system permissions. For a system read through an api-prefix, it subscribes to <api-prefix>.> in place of $JS.<domain>.API.>: the leafnode carries the subject as the hub node publishes it, and the remote server maps it to $JS.API.> only on arrival, so allowing $JS.API.> alone leaves its JetStream unreachable.
If the remote and hub sides use different accounts, reading across them is a cross-account JetStream setup: the remote account exports its JetStream API ($JS.west.API.>), the hub account imports it, and the replies must be shared the same way. Start from the shared account arrangement unless account isolation across the leafnode is a hard requirement.
The request to each collector, $INS.sys.<id>.ops.sink.info, is already covered by $INS.>.