8000 ✨ quieter, more accurate alerts by abahmed · Pull Request #633 · abahmed/kwatch · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ LABEL org.opencontainers.image.source="https://github.com/abahmed/kwatch" \
org.opencontainers.image.created="${BUILD_DATE}" \
org.opencontainers.image.licenses="Elastic-2.0"

RUN apk add --no-cache ca-certificates && \
# The base image is pinned by digest, so it lags behind Alpine's security
# fixes until a rebuilt image is published. Upgrade its packages to the
# fixed versions so the image scan, which fails on fixed findings, passes.
RUN apk upgrade --no-cache && \
apk add --no-cache ca-certificates && \
adduser -D -u 1000 kwatch
COPY --from=builder /build/kwatch /bin/kwatch
# Numeric, so runAsNonRoot can be verified without runAsUser; it matches the
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@ per release to your channels; turn that off with
`upgrader.disableUpdateCheck: true`. Both settings sit under `config:` in
the chart values.

No internet access? Community runs fully offline; Pro needs the license
server at least once every 7 days. See
[air-gapped and offline clusters](./docs/air-gapped.md).

## ❓ FAQ

<details>
Expand Down Expand Up @@ -433,8 +437,8 @@ overrides, runbook links and a message budget per channel. See the
<summary><b>Why is Pro free?</b></summary>

We want kwatch proven on real clusters before we charge anything. Each
license is free for 3 months and we may renew it, with up to 2 clusters per
account or company. There are no payment details. If that changes, you will
license is free for 3 months, with up to 2 clusters per account or
company. There are no payment details. If that changes, you will
hear well in advance.
</details>

Expand Down
3,234 changes: 1,801 additions & 1,433 deletions RELEASES.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ implementation-only notes may remain beside code when they are not published.
- [What happens to alerts when kwatch restarts](./single-replica-restarts.md) — what is kept, resent or lost across a restart.
- [Production operations](./production-operations.md) — readiness, restarts,
recovery, outage handling, and release operations.
- [Air-gapped and offline clusters](./air-gapped.md) — every outbound
connection and how to turn it off, installing from a private registry,
and what Pro needs from the license server.
- [Configuration notes](./configuration.md) — offline configuration and
endpoint notes; the published reference remains on `kwatch.dev`.
- [Provider notes](./providers.md) — offline provider behavior and transport
Expand Down
213 changes: 213 additions & 0 deletions docs/air-gapped.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# 🔌 Air-gapped and offline clusters

Use this page when kwatch runs in a cluster with no internet access, or
with outbound traffic limited to a proxy. It says what works without a
network, every connection kwatch makes outside the cluster and how to turn
each one off, how to install from a private registry, and why Pro needs
the license server.

In short:

- **Community works fully offline, with no time limit.** Without a license
key kwatch makes no license call. Turn off the two checks that are on by
default (telemetry and the update check), pick an alert provider you can
reach inside your network, and nothing leaves the cluster except your
alerts.
- **Pro needs to reach the license server.** The first activation and the
daily renewal go to `https://api.kwatch.dev`. There is no offline license
mode, no long-lived key and no license file you can renew by hand. A
cluster that cannot reach the server keeps Pro for up to 7 days after the
last successful check, then runs the Community edition. Alerts never stop.
See [Pro without internet access](#pro-without-internet-access).

## Every outbound connection

Apart from the Kubernetes API server and the kubelets, these are all the
connections kwatch opens. The telemetry, the update check and the license
check go through kwatch's outbound HTTP client, so `app.proxyURL` and
`app.caBundlePath` apply to them, and they always verify TLS.

| Connection | Destination | When | How to turn it off | Without network |
| --- | --- | --- | --- | --- |
| Adoption telemetry | `https://api.kwatch.dev/telemetry/heartbeat` | Shortly after startup, then at most once every 7 days | `telemetry.enabled: false`, or `KWATCH_TELEMETRY=false` | Each attempt fails after at most 3 seconds and is retried after 1, 5, 15, 30 and then every 60 minutes, logged once, at info level; repeats of the same failure log only at verbosity 2. Monitoring is not affected |
| Update check | The GitHub API (latest kwatch release) | At startup, then every 24 hours | `upgrader.disableUpdateCheck: true`, or `SKIP_UPGRADE_CHECK=true` | One info log line ("failed to get latest release") per attempt. Nothing is sent to your providers |
| Pro license check | `https://api.kwatch.dev` | Only with a license key: activation, then about once a day | Remove the key (`license.key`, `KWATCH_LICENSE_KEY`) | See [Pro without internet access](#pro-without-internet-access) |
| Your alert providers | The URLs and hosts you configure under `alert.*` | On every alert | Configure only providers inside your network | Failed sends are retried and then dead-lettered, like any provider outage |
| Dead man's switch (Pro) | `heartbeatMonitor.url` | On its schedule | Leave `heartbeatMonitor.url` empty | Point it at monitoring inside your network |
| Active probes (Pro) | The targets you list in `activeProbeMonitor` | On their schedule | Leave `activeProbeMonitor` unset | Probes reach in-cluster targets as usual |
| Dashboard browser alerts (Pro) | The browser's push service (Google, Mozilla, Apple or Microsoft) | Only after someone turns on **Browser alerts** in the dashboard | Leave browser alerts off | The push services are on the internet, so these notifications cannot arrive |

Nothing else leaves the cluster. Development builds and CI environments
never send telemetry, and prerelease builds skip the update check. What
each request carries is in
[What leaves my cluster](../README.md#-what-leaves-my-cluster) and in the
[configuration notes](./configuration.md#-minimal-adoption-telemetry).

At startup kwatch logs `adoption telemetry skipped` with
`reason="disabled"` (or `disabled_env`) and `update check disabled`, so the
log shows that both are off.

## Configuration for an offline cluster

With the Helm chart, put both switches under `config:` in your values (or in
the `config.yaml` of the Secret that `configSecretName` names, which
replaces `config:`):

```yaml
config:
telemetry:
enabled: false
upgrader:
disableUpdateCheck: true
```

With your own `config.yaml`, set the same two keys, or set the environment
variables `KWATCH_TELEMETRY=false` and `SKIP_UPGRADE_CHECK=true`.

## Install from a private registry

The chart installs one image, `ghcr.io/abahmed/kwatch`, tagged with the
chart's `appVersion` (for example chart `1.3.0` runs image `v1.3.0`). The
`KwatchConfig` CRD is part of the chart, so nothing else is fetched at
install time. The `kwatch.sh` installer downloads release files from GitHub
while it runs and installs the image from `ghcr.io`, so use the Helm chart
for an air-gapped cluster.

On a machine with internet access, first
[verify the release](./release-integrity.md), then copy the image and the
chart. The image is published for `linux/amd64`, `linux/arm64`,
`linux/arm/v7` and `linux/arm/v6`; `--all` keeps every architecture:

```shell
VERSION=X.Y.Z
REGISTRY=registry.example.internal

skopeo copy --all \
docker://ghcr.io/abahmed/kwatch:v$VERSION \
docker://$REGISTRY/kwatch/kwatch:v$VERSION

helm repo add kwatch https://kwatch.dev/charts
helm pull kwatch/kwatch --version $VERSION
helm push kwatch-$VERSION.tgz oci://$REGISTRY/charts
```

The chart package is also at `https://kwatch.dev/charts/kwatch-X.Y.Z.tgz`.
If your network has no OCI registry for charts, carry the `.tgz` file
across and install from it directly.

Then point the chart at the mirror. If the registry needs credentials,
create a pull secret in the release namespace and name it in
`imagePullSecrets`:

```yaml
image:
repository: registry.example.internal/kwatch/kwatch
# Empty uses the chart's appVersion; set it when you mirror another tag.
tag: ""
imagePullSecrets:
- name: registry-pull
config:
telemetry:
enabled: false
upgrader:
disableUpdateCheck: true
```

```shell
helm install kwatch oci://registry.example.internal/charts/kwatch \
--version X.Y.Z --namespace kwatch --create-namespace \
-f values-offline.yaml
```

Without the chart, `deploy/deploy.yaml` holds the same image reference
(`ghcr.io/abahmed/kwatch:vX.Y.Z`); change it to your mirror before you
apply the file.

## Alert providers inside your network

Any provider whose address you can set can point at a server inside your
network. Private, loopback and in-cluster addresses are allowed; only cloud
instance-metadata addresses are refused (see
[How providers work](./providers.md#how-providers-work)). These providers
take a server address and have a self-hosted version:

| Provider | Setting |
| --- | --- |
| Email (an SMTP relay) | `alert.email.host`, `alert.email.port`; `tls: none` for a trusted relay |
| Mattermost | `alert.mattermost.webhook` |
| Rocket.Chat | `alert.rocketchat.webhook` |
| Matrix | `alert.matrix.homeServer` |
| Zulip | `alert.zulip.url` |
| ntfy | `alert.ntfy.url` (the default is the public `https://ntfy.sh`, so set it) |
| Gotify | `alert.gotify.url` |
| Signal (a signal-cli REST API) | `alert.signal.url` |
| Home Assistant | `alert.homeassistant.url` |
| GitLab, Gitea, GitHub Enterprise | `alert.gitlab.url`, `alert.gitea.url`, `alert.github.url` |
| GoAlert | `alert.goalert.url` |
| Alerta | `alert.alerta.url` |
| Sensu Go | `alert.sensugo.url` |
| Splunk HTTP Event Collector | `alert.splunk.url` |
| n8n | `alert.n8n.url` |
| Custom webhook | `alert.webhook.url` |

The Community edition sends to one provider; when more than one is
configured, `app.communityProvider` picks it. With the chart's
NetworkPolicy on (`networkPolicy.enabled`), open a provider port other than
443 with `networkPolicy.extraEgressPorts`, for example `[587]` for SMTP.

## Pro without internet access

Pro cannot run in a fully air-gapped cluster, and this is by design. The
license server binds each license to one cluster, and the regular check is
how it knows the same key is not running on another cluster at the same
time. A license that worked offline could not be checked that way. This is
how licensing behaves:

- **Verification is offline, activation is not.** kwatch checks the license
key and the activation lease against signing keys compiled into the
binary, with no network call. But the lease itself comes only from the
license server: without a first successful activation there is no lease,
and Pro never starts.
- **A key without a reachable server stays pending.** At the first start
kwatch waits at most 10 seconds for the activation, then runs the
Community edition. `/health` shows the `license` component as `waiting`
with `license_pending`; this does not affect readiness. kwatch logs one
warning ("license check with the license server failed") and retries
after 1, 5, 15 and 30 minutes, then every hour.
- **A running Pro install keeps Pro for up to 7 days.** Leases last 3 days
and are renewed about once a day; an expired lease has a 4 day grace
period. The lease is kept in the state file, so restarts do not shorten
this. When the lease expires, your providers get "the kwatch license
could not be renewed and is in its grace period until ...". When the
grace period ends, they get "kwatch Pro is disabled: ... kwatch continues
in the Community edition.", `/health` shows `license` as `degraded` with
`license_expired`, and kwatch rebuilds as Community in the same process.
- **Alerts never stop.** Licensing never takes monitoring down. After the
fallback kwatch runs with Community's limits: Pro detections and features
stop, and alerts go to one provider (`app.communityProvider`).
- **Pro comes back on its own.** kwatch keeps retrying the server. The
first renewal that succeeds after the network returns restores Pro, and
your providers get "kwatch Pro is enabled."
- **No offline key change.** Each license runs for a fixed period (see
"Why is Pro free?" in the [README](../README.md) FAQ). Activating a new
key also needs the license server; there is no license file to carry
in.

### Restricted egress instead of none

If the cluster may reach the internet through a proxy, Pro works when the
proxy allows HTTPS to `api.kwatch.dev`. Set `app.proxyURL` to the proxy and,
if it re-signs TLS, `app.caBundlePath` to its CA bundle: the license call
always verifies TLS and ignores `app.insecureSkipTLSVerify`.
`api.kwatch.dev` has no fixed IP addresses, so allow it by host name at the
proxy rather than by address in a NetworkPolicy. The chart's NetworkPolicy
already opens port 443 when a license key is configured.

## Related pages

- [Configuration notes](./configuration.md): the `license`, `telemetry`,
`upgrader` and `app` settings.
- [Production operations](./production-operations.md#security-and-data-sent-out):
security and data sent out.
- [Licensing](./licensing.md): license keys and how they are verified.
- [Helm chart](../deploy/chart/README.md): every chart value.
5 changes: 4 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ listener, never on the health port. Everything about reaching it from outside
| `dashboard.sessionLifetime` | `12h` | How long a sign-in lasts, from sign-in, as a duration between `15m` and `168h` (7 days). A value outside that range, or not a duration, is a configuration error |
| `dashboard.signInHelp` | empty | Plain text the sign-in page shows above the link "How to get the password", for example where your team keeps the password. It is shown as text (escaped, never HTML); line breaks are kept. At most 500 characters, no control characters |
| `investigation.logs` | `true` | Reads container logs as evidence (redacted, bounded). `false` reads no log at all, and the dashboard shows the log section as turned off |
| `investigation.sampleLogs` | `true` | Samples a bounded slice of the log (the last 2 minutes, one pod per workload, at most 6 reads per 30 seconds) of Running and Ready pods and reports a burst of errors new against the workload's own earlier windows (`LogErrorBurst`: at least 20 error lines in the window, at least 5 times the earlier rate per window with that rate counted as at least 8, so a quiet service needs 40 lines, and at least 10 minutes of earlier windows). Only error-level lines count: a line that states a level (`level=`, JSON `level`/`severity`, klog `I`/`W`/`E`/`F`, or `INFO`/`DEBUG`/`ERROR` tokens) must be error, fatal, panic or critical, and a line with no level counts when it looks like an error, ignoring empty fields such as `error=null`. Pro users can mute just this finding with `reasons: ["!LogErrorBurst"]` or a silence instead of turning sampling off. The same samples report, as a low finding listed in the daily summary (`LogServiceMissing`), a workload whose log keeps failing to resolve a name shaped like a Service of the cluster (`name`, `name.namespace`, `name.namespace.svc…`) when no such Service exists in a namespace that does: the name must show in at least 3 sampled windows spread over at least 20 minutes, it clears when the Service appears or the lookups stop for 30 minutes, and a similar existing Service name is given as a hint. It never pages and reads no more logs. Reads nothing when `investigation.logs` is `false`. A refused log read pauses it quietly for 5 minutes |
| `investigation.sampleLogs` | `true` | Samples a bounded slice of the log (the last 2 minutes, one pod per workload, at most 6 reads per 30 seconds) of Running and Ready pods and reports a burst of errors new against the workload's own earlier windows (`LogErrorBurst`: at least 20 error lines in the window, at least 5 times the earlier rate per window with that rate counted as at least 8, so a quiet service needs 40 lines, and at least 10 minutes of earlier windows). A window judged a burst is left out of the baseline of the windows after it, so an error storm that goes on stays a burst instead of raising its own bar; once the quiet windows of the last hour cover less than 10 minutes, the storm's rate is the workload's new normal and every window counts again. Only error-level lines count: a line that states a level (`level=`, JSON `level`/`severity`, klog `I`/`W`/`E`/`F`, or `INFO`/`DEBUG`/`ERROR` tokens) must be error, fatal, panic or critical, and a line with no level counts when it looks like an error, ignoring empty fields such as `error=null`. Pro users can mute just this finding with `reasons: ["!LogErrorBurst"]` or a silence instead of turning sampling off. The same samples report, as a low finding listed in the daily summary (`LogServiceMissing`), a workload whose log keeps failing to resolve a name shaped like a Service of the cluster (`name`, `name.namespace`, `name.namespace.svc…`) when no such Service exists in a namespace that does: the name must show in at least 3 sampled windows spread over at least 20 minutes, it clears when the Service appears or the lookups stop for 30 minutes, and a similar existing Service name is given as a hint. It never pages and reads no more logs. Reads nothing when `investigation.logs` is `false`. A refused log read pauses it quietly for 5 minutes |

The bearer token and the sign-in password are not in the file. The chart
ships the Secret `<release>-dashboard` empty and kwatch fills both values
Expand Down Expand Up @@ -756,6 +756,9 @@ naming the endpoint and either that it is enabled or why it is skipped
(`disabled`, `disabled_env`, `dev_build`, `ci_environment`). Outcomes are
counted by `kwatch_telemetry_attempts_total`, `_successes_total`,
`_retries_total` and `kwatch_telemetry_failures_total{reason}`.
A failed heartbeat is retried after 1, 5, 15, 30 and then every 60 minutes.
Only the first failure of each kind is logged; repeats log at verbosity 2,
so a cluster without internet access gets one line, not one an hour.

---

Expand Down
Loading
Loading
0