HUB
Sign inSign up
overwatch logo

metabase/overwatch

By metabase

•Updated about 5 hours ago

Image
0

101

metabase/overwatch repository overview

⁠Overwatch

Overwatch monitors your Metabase instances for data exfiltration. It reads each Metabase's application database with a read-only login, learns each person's normal activity, runs detection rules, groups alerts into incidents, and notifies you. It runs as one Docker image, metabase/overwatch, and keeps its data in a ClickHouse and a Postgres that you run.

⁠What you need

whatrequirement
A host for the imageDocker, 2 vCPU and 4 GB of memory for the container, x86_64
ClickHouse26.3 or later, or ClickHouse Cloud. A database for Overwatch, and at least 4 GB of memory
Postgres16 or later. A database for Overwatch. It can be the server that holds the Metabase application database below
A Metabase for Overwatch's dashboardsMetabase Enterprise v1.65.6.2, new and not set up, used only by Overwatch
A licence tokenMetabase Enterprise, with the features serialization, embedding-sdk and sso-jwt
SMTPoptional, for email notifications

Each Metabase you monitor needs:

  • Metabase Enterprise 63 (v1.63) or later, with the licence feature change-log, and audit-app for all rules to run;
  • its application database on Postgres;
  • a read-only login in the application database (step 1).

Overwatch serves plain HTTP. Put your TLS proxy or load balancer in front of it, as you do for Metabase. Overwatch calls token-check.metabase.com:443 for the licence check, and download.db-ip.com:443 once a month for GeoIP data.

⁠1. Make the databases and logins

Overwatch needs two logins in ClickHouse and two in Postgres: one for itself, and a read-only one for its Metabase. Replace each … with a password.

In ClickHouse:

CREATE DATABASE overwatch;

CREATE USER overwatch IDENTIFIED BY '…' SETTINGS join_use_nulls = 1;
GRANT SHOW, SELECT, INSERT, ALTER, CREATE TABLE, CREATE VIEW, CREATE DICTIONARY, DROP TABLE, DROP VIEW,
      DROP DICTIONARY, TRUNCATE, dictGet ON overwatch.* TO overwatch;
GRANT CREATE FUNCTION, DROP FUNCTION, SYSTEM RELOAD DICTIONARY ON *.* TO overwatch;

CREATE USER overwatch_metabase IDENTIFIED BY '…' SETTINGS join_use_nulls = 1, readonly = 2;
GRANT SELECT, SHOW, dictGet ON overwatch.* TO overwatch_metabase;
GRANT SELECT ON system.processes TO overwatch_metabase;
  • join_use_nulls = 1 is required. Without it, some rules and dashboards give wrong results.
  • The grants ON *.* are for what ClickHouse grants on the whole server only: Overwatch's four SQL functions, whose names start with ow_, and the reload of its GeoIP dictionary.
  • system.processes lets Metabase cancel a query when a viewer leaves a dashboard.

In Postgres:

CREATE ROLE overwatch LOGIN PASSWORD '…';
CREATE DATABASE overwatch OWNER overwatch;
CREATE ROLE overwatch_metabase LOGIN PASSWORD '…';

Overwatch grants overwatch_metabase read access to the tables its dashboards use.

In each Metabase you monitor, make a read-only login. Run this in its application database:

CREATE ROLE overwatch LOGIN PASSWORD '…';
GRANT SELECT ON ALL TABLES IN SCHEMA public TO overwatch;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO overwatch;
ALTER DEFAULT PRIVILEGES FOR ROLE metabase IN SCHEMA public GRANT SELECT ON TABLES TO overwatch;
ALTER DEFAULT PRIVILEGES FOR ROLE metabase IN SCHEMA public GRANT SELECT ON SEQUENCES TO overwatch;

metabase is the user that Metabase itself connects as (MB_DB_USER). The last two lines cover the tables that a Metabase upgrade adds.

⁠2. Start Overwatch's Metabase

Run Metabase Enterprise v1.65.6.2 with its own application database, such as a database metabase on the same Postgres. Do not open it or set it up: Overwatch does that at its first start, with Metabase's setup token.

Overwatch sets what it needs in this Metabase: the licence token, its admin, JWT single sign-on, the embedding settings, its two databases and the dashboards.

⁠3. Configure Overwatch

Overwatch reads its configuration from environment variables, from one file, or from both. The file is /config/overwatch.yaml in the container, or the path in OW_CONFIG_FILE. When a key is set in both, the environment variable wins.

Each key's variable is its path in capitals, with OW_ in front: clickhouse.password is OW_CLICKHOUSE_PASSWORD. In the file, {{ env NAME }} reads a variable, so the file can hold no passwords.

keyvariablerequiredwhat
license_tokenOW_LICENSE_TOKENyesthe Metabase Enterprise licence token
encryption_keyOW_ENCRYPTION_KEYyesencrypts the passwords Overwatch stores, as MB_ENCRYPTION_SECRET_KEY does for Metabase. 32 characters or more
base_urlOW_BASE_URLyesthe address people use, such as https://overwatch.acme.com
portOW_PORTthe port Overwatch listens on. Default 8000
admin.email, admin.passwordOW_ADMIN_EMAIL, OW_ADMIN_PASSWORDfirst startthe first admin. The password needs 12 characters or more
postgres.host, .port, .database, .user, .passwordOW_POSTGRES_HOST, …yesOverwatch's login. Port default 5432
postgres.metabase_user, .metabase_passwordOW_POSTGRES_METABASE_USER, …yesthe read-only login for Overwatch's Metabase
clickhouse.host, .port, .secure, .database, .user, .passwordOW_CLICKHOUSE_HOST, …yesOverwatch's login. secure: true for HTTPS, which ClickHouse Cloud needs. Port default 8123, or 8443 with secure
clickhouse.metabase_user, .metabase_passwordOW_CLICKHOUSE_METABASE_USER, …yesthe read-only login for Overwatch's Metabase
metabase.urlOW_METABASE_URLyesOverwatch's Metabase, as browsers reach it
metabase.internal_urlOW_METABASE_INTERNAL_URLOverwatch's Metabase, as Overwatch reaches it, when that differs from metabase.url
smtp.host, .port, .user, .password, .from_addr, .tlsOW_SMTP_HOST, …email notifications. With smtp.host, Overwatch makes an email channel to admin.email, for incidents of severity high or more. port is 587 by default. tls, true by default, uses STARTTLS. A server that wants TLS from the first byte, as on port 465, does not work

An example file:

license_token: "{{ env OW_LICENSE_TOKEN }}"
encryption_key: "{{ env OW_ENCRYPTION_KEY }}"
base_url: https://overwatch.acme.com
admin:
  email: [email protected]
  password: "{{ env OW_ADMIN_PASSWORD }}"
postgres:
  host: pg.acme.internal
  database: overwatch
  user: overwatch
  password: "{{ env OW_POSTGRES_PASSWORD }}"
  metabase_user: overwatch_metabase
  metabase_password: "{{ env OW_POSTGRES_METABASE_PASSWORD }}"
clickhouse:
  host: abc123.us-east-1.aws.clickhouse.cloud
  secure: true
  database: overwatch
  user: overwatch
  password: "{{ env OW_CLICKHOUSE_PASSWORD }}"
  metabase_user: overwatch_metabase
  metabase_password: "{{ env OW_CLICKHOUSE_METABASE_PASSWORD }}"
metabase:
  url: https://overwatch-metabase.acme.com
smtp:
  host: smtp.acme.com
  port: 587
  user: [email protected]
  password: "{{ env OW_SMTP_PASSWORD }}"
  from_addr: [email protected]

⁠4. Run it

docker run -d --name overwatch --restart unless-stopped -p 8000:8000 \
  --env-file overwatch.env -v "$PWD/overwatch.yaml:/config/overwatch.yaml:ro" \
  metabase/overwatch:latest

overwatch.env holds the environment variables of step 3, one NAME=value on each line.

At each start, Overwatch checks the licence and its configuration, migrates its tables in Postgres and ClickHouse, and sets up its Metabase when it is new. It keeps no data in the container. The container runs as uid 10001, so a mounted overwatch.yaml must be readable by others.

  • You should see overwatch ready in docker logs overwatch, and the UI at base_url, where you log in as the admin.
  • If it does not start, the log's last lines say which check failed and what to change.

/healthz answers 200 when Overwatch serves. Use it for your load balancer's health check. For the container's health check, run overwatch health: it also checks that each service is alive.

⁠5. Monitor a Metabase

Open Instances, click Register instance, type the URL that people open the Metabase at, an instance id and the connection to its application database, click Test, then Save. Test says what is wrong with a connection, and which rules cannot run on that Metabase.

  • You should see the first read in the instance's Data pipeline tab within a minute.

Overwatch first reads the last 126 days of the Metabase's history. On a large application database this takes hours. Overwatch does not notify the incidents it finds in the history, but the incident list shows them. It notifies everything it detects after that.

Overwatch keeps what it reads, and nothing expires: the rules compare each person with their own history. This includes people's emails, IP addresses and query text. To remove a Metabase's data, delete the instance in Instances: that removes everything read from it, its incidents and their triage.

⁠Upgrade

  1. Read the release notes of each version between yours and the new one.

  2. Back up the Overwatch databases in ClickHouse and Postgres.

  3. Pull the new image and run it in place of the old one:

    docker pull metabase/overwatch:latest
    docker rm -f overwatch
    docker run -d --name overwatch ... metabase/overwatch:latest
    

At start, the new version migrates its tables, then reads each Metabase from where the old one stopped. Migrations do not run backwards: to go back, restore the backup and run the old version by its tag, metabase/overwatch:<version>.

Metabase deletes its change log entries after 30 days. If Overwatch is stopped for longer than 29 days, it can miss some changes, and an alert says so.

⁠Back up

All of Overwatch's data is in its two databases. Back them up as you back up your other databases: the Postgres database overwatch, and the ClickHouse database overwatch. Keep encryption_key too. Without it, Overwatch cannot read the passwords it stores, and you must enter each instance's and channel's password again.

⁠Commands in the image

commandwhat it does
docker exec overwatch overwatch healthhealthy, or which service is not, with why
docker exec overwatch overwatch diagnosea report to send us when something is wrong: versions, health, each instance's phase and errors. Ids, counts and times only, no query text or emails
docker exec overwatch overwatch versionthe version
docker exec overwatch overwatch metabase-adminthe login of the admin Overwatch made in its Metabase

Tag summary

Content type

Image

Digest

sha256:1f4286e3d…

Size

85.9 MB

Last updated

about 5 hours ago

docker pull metabase/overwatch