Skip to main content
Version: 1.3.0

Masking

Keep the names, text, credentials and addresses of a monitored system out of the data Insights publishes.

A node that scrapes a system can mask what it reads before it publishes anything. On a collector, the data leaves the remote system already masked: the hub node's database, web UI, API, checks and notifications only ever hold pseudonyms, and the key that reverses them stays with the collector.

What is masked​

Each class is off by default and is turned on separately.

SettingValuesCovers
mask.identifiersoff, pseudonymizeAccount, stream, consumer, server, cluster and user names; connection names; subjects, permissions and mappings; tags; paths; metadata keys; raft peer IDs
mask.textoff, redactDescriptions, metadata values and other free text
mask.credentialsoff, redactUser and account JWTs and activation tokens
mask.networkoff, redactIP addresses, hosts, URLs and CIDRs

A pseudonym is the name encrypted under your key. The same name always gets the same pseudonym, of the same length, so accounts, streams and servers keep their history, and pages and checks work on the pseudonyms, with the losses listed below. Redacted text, addresses, JWTs and tokens read [redacted], and one that was empty stays empty. A JWT or token is redacted whenever any class is on, since it encodes names.

Identifiers can't be redacted. Insights tells accounts, servers, streams and subscriptions apart by name, so a redacted name would merge them into one and change what the checks find.

Masking covers the data the node reads from the monitored system:

  • Every scraped reply, before it reaches the scrape stream.
  • Connection events on the real-time feed.
  • Server EXPVARZ diagnostics. Their command line is redacted whenever any class is on, since an argument can be a password.

CPU profiles and other server profiles are refused while masking is on. nats-server labels its profiles with account, stream and consumer names, and a profile can't be masked.

The node's own status isn't masked. When it can't connect to the monitored system, the error it reports to the hub can name that system's address.

Turn it on​

Create a key on the node that scrapes, and keep a copy somewhere safe. Without it, no pseudonym can be reversed.

insights mask keygen /etc/insights/mask.key

The file holds 64 hex characters and is readable only by its owner. keygen refuses to replace an existing file.

Then select what to mask:

mask:
key-file: /etc/insights/mask.key
identifiers: pseudonymize
text: redact
credentials: redact
network: redact

mask.key-file is required when identifiers are pseudonymized, and refused when they are not. Masking applies to every system the node scrapes.

Reveal a name​

Whoever holds the key turns a pseudonym from the UI, an alert or a query back into the original:

insights mask reveal --key-file /etc/insights/mask.key 8nm8zO_e00Q kqhNr6.6X.v2IFhy1
ORDERS_ACME
orders.eu.created

reveal runs offline and is in the collector binary too. INSIGHTS_MASK_KEY_FILE sets the key file.

Before you turn it on​

  • The key is the identity. Turning masking on or off, or changing the key, gives every account, stream and server a new name, so its history splits at that epoch. Every node that scrapes the same system needs the same key and settings.
  • Turning it on doesn't mask what is already stored. Epochs scraped before masking stay in the scrape stream and the hub's database, under their real names, until retention removes them.
  • Names keep their shape. A pseudonym has the original's length and characters of the same width, and a subject is masked token by token, so orders.eu.created stays three tokens. NATS's own names are kept: $G, $SYS, the $JS and $KV subjects, and the KV_ and OBJ_ prefixes that mark a bucket's stream. So is a user's token that equals a NATS keyword, such as INFO in orders.INFO. Case is lost: Orders and orders get unrelated pseudonyms.
  • Text and addresses are gone. With network: redact, clients can't be placed on the map. With text: redact, descriptions and metadata values read [redacted].
  • Credentials are gone, but not whether one was presented. A bearer token user is found on servers that leave its JWT out of connz (2.11.17, 2.12.8, 2.14.0 and later) and missed on older ones. account-003 still finds a failed JWT import, but can't read a token's issuer or expiry, so it can give the wrong reason.
  • A new server field is redacted until Insights knows it. The text in a field a newer nats-server adds is redacted rather than passed through, until an Insights release that knows the field.
  • A pseudonym is reversible by design. Masking keeps names from the people who read the data. It isn't meant to hold out against someone set on decoding it: anyone who learns one name's pseudonym can spot that name everywhere.