Skip to content

Check metabase-stats

Overview

Retrieves recent activity and usage statistics from a Metabase instance via its API. Reports active users, executed queries, dashboards, and other operational metrics. Credentials are cached to reduce API calls.

Important Notes:

  • This plugin is currently not production-ready and needs a rewrite (undefined variable references, dangerous default values). Use with caution.
  • Requires a Metabase superuser account. Logins are rate-limited by Metabase for security, which is why credentials are cached. See the Metabase API documentation for details

Data Collection:

  • Authenticates against the Metabase API using username/password and caches the session token in SQLite (default expiry: ~14 days, matching Metabase's default session lifetime)
  • Queries /api/activity for the most recent activity entry and /api/util/stats for aggregated usage statistics
  • Reports site name, Metabase version, user count, analyzed databases, GUI questions, alerts, pulses, collections, CPUs, and RAM

Fact Sheet

Fact Value
Check Plugin Download https://github.com/Linuxfabrik/monitoring-plugins/tree/main/check-plugins/metabase-stats
Nagios/Icinga Check Name check_metabase_stats
Check Interval Recommendation Every hour
Can be called without parameters No (--password is required)
Runs on Cross-platform
Compiled for Windows No (runs with Python interpreter)
Uses State File $TEMP/linuxfabrik-monitoring-plugins-metabase-stats.db

Help

usage: metabase-stats [-h] [-V] [--always-ok] [--cache-expire CACHE_EXPIRE]
                      [-c CRIT] [--insecure] [--no-perfdata] [--no-proxy]
                      -p PASSWORD [--proxy PROXY] [--timeout TIMEOUT]
                      [--url URL] [--username USERNAME] [-w WARN]

Retrieves recent activity and usage statistics from a Metabase instance via
its API. Reports active users, executed queries, dashboards, and other
operational metrics. Credentials are cached to reduce API calls. The figures
are reported for trending and never alert on their own.

options:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  --always-ok           Always returns OK.
  --cache-expire CACHE_EXPIRE
                        Time after which the credential cache expires, in
                        hours. Default: 335
  -c, --critical CRIT   CRIT threshold in percent. Default: >= 90
  --insecure            This option explicitly allows insecure SSL
                        connections.
  --no-perfdata         Suppress the performance data section from the output.
                        The status message and the exit code are unaffected,
                        so alerting keeps working while trending data is
                        dropped.
  --no-proxy            Do not use a proxy, not even one the environment
                        names. Overrides `--proxy`.
  -p, --password PASSWORD
                        Password for authenticating against the Metabase API.
  --proxy PROXY         Proxy to reach the target through. The scheme defaults
                        to `http` when omitted. Overrides the proxy the
                        environment names (`http_proxy`, `https_proxy`,
                        `all_proxy`) together with the exceptions it lists in
                        `no_proxy`, and is itself overridden by `--no-proxy`.
                        Without either parameter the environment applies.
                        Credentials belong into the environment variable
                        rather than here, because a command-line argument is
                        visible to every user on the host. Example:
                        `--proxy=http://proxy.example.com:3128`.
  --timeout TIMEOUT     Network timeout in seconds. Default: 8 (seconds)
  --url URL             Base URL of the Metabase instance. Default:
                        http://localhost:3000
  --username USERNAME   Username for authenticating against the Metabase API.
                        Default: metabase-admin
  -w, --warning WARN    WARN threshold in percent. Default: >= 80

Documentation:
https://linuxfabrik.github.io/monitoring-plugins/check-plugins/metabase-stats/

Usage Examples

./metabase-stats --username=user --password=pass --url=http://metabase:3000

Output:

MyCube on Metabase v0.39.1; 8 users, 1 DB analyzed, 55 questions (GUI), 0 alerts, 0 pulses, 13 collections; 6 CPUs, 5462 MiB RAM
Last activity: "card-create/My Card" by John Doe (3D 16h ago)

States

  • Always returns OK.

Perfdata / Metrics

Name Type Description
alerts Number Number of configured alerts.
collections Number Number of collections.
cpu Number Number of CPUs available to the Metabase instance.
dbs_analyzed Number Number of analyzed databases.
pulses Number Number of configured pulses.
questions_gui Number Number of questions created via the GUI.
ram MiB RAM available to the Metabase instance.
users Number Total number of users.

Credits, License