querying-production-databases-via-metabase
БесплатноБез исполняемых скриптовНе проверенFallback for read-only production database analysis through PostHog's internal Metabase instances. Use the `querying-production-databases` skill first. Use…
от PostHog★ 41 278 звёзд на GitHubОб этом скилле
Querying production databases via Metabase
[!NOTE] The default path is the
querying-production-databasesskill, which runs queries through the PostHog MCP with no SSO step. Use Metabase only for what that path cannot do: Postgres query plans, the test cluster,clusterAllReplicas()over livesystem.query_log, and shareable links.
PostHog's production databases are reachable for ad-hoc, read-only analysis through internal Metabase instances. Both Metabases sit behind an AWS ALB with Cognito OAuth, so authentication is SSO-gated — Metabase API keys alone won't work.
Two engines are behind the same API surface, and the reason to reach for each is different:
- ClickHouse —
system.query_loganalysis: which queries are slow, what they read, who runs them. - Postgres (the app database) — the real query plan for an app query, and how a per-project table's rows spread across the fleet.
For pre-built canned ClickHouse queries (slow query summaries, materialization
analysis), see the query-performance-analysis repo, which is the source of
truth for those and uses the same Metabase API surface.
Environment
| Region | Metabase URL |
|---|---|
| US | https://metabase.prod-us.posthog.dev |
| EU | https://metabase.prod-eu.posthog.dev |
Database IDs are not stable — they change when Metabase's metadata DB is rebuilt or connections are re-added. Never hardcode an ID. Always discover the current list:
hogli metabase:databases --region us
hogli metabase:databases --region eu
Regional layout (names may vary; re-check with metabase:databases):
- US exposes one ClickHouse database (used for
query_logand data reads). - EU exposes two ClickHouse databases — a query tier (use for
query_loganalysis) and a data tier (production reads: events, persons, etc.). Pick the one whose name indicates the query tier. - Both Metabases also expose Postgres databases (the app DB) and, on EU, the ingestion-layer and migrations databases.
Authentication
Use hogli to get a valid cookie. It opens the system browser for SSO,
captures cookies from the user's logged-in browser profile, and caches them
at ~/.config/posthog/metabase/cookie-{region} (mode 0600).
# Log in once per region. --region is required (no default — you pick which one).
# Already-valid sessions are fast-pathed (no browser tab opens), so re-running
# is cheap.
hogli metabase:login --region us
hogli metabase:login --region eu
Prompt the user to run hogli metabase:login themselves — the harness
blocks Keychain access from agent shells, so the user has to authenticate
interactively.
On macOS, the terminal app needs Full Disk Access to read browser cookies —
without it, metabase:login fails with an error naming which browsers it
couldn't read. Several browsers installed and logged into the wrong one?
Pass --browser <name> to target one directly.
Agents: use metabase:query
hogli metabase:query reads the cached cookie internally and only emits
results — the session value never appears in the agent's transcript.
metabase:cookie exists for humans who want to hand-roll curl against
Metabase.
Running a ClickHouse query
- Discover the current ClickHouse DB ID:
hogli metabase:databases --region <region>. - Pass that ID into
hogli metabase:query. Pipe SQL via stdin or--file.
# 1. Find the ClickHouse database ID for your region
hogli metabase:databases --region us
# e.g. output row: 42 ClickHouse clickhouse
# 2. Run the query. The cookie is read internally; nothing leaks to stdout.
hogli metabase:query --region us --database-id 42 --save /tmp/out.tsv <<'SQL'
SELECT
JSONExtractInt(log_comment, 'team_id') AS team_id,
count() AS query_count,
formatReadableSize(sum(read_bytes)) AS total_bytes
FROM clusterAllReplicas(posthog, system, query_log)
WHERE event_time > now() - INTERVAL 1 DAY
AND is_initial_query
AND query_duration_ms > 30000
GROUP BY team_id
ORDER BY query_count DESC
LIMIT 20
SQL
clusterAllReplicas(posthog, system, query_log) is the standard table reference —
it fans out across the cluster.
For large result sets, use --save <path> so rows land in a file rather
than streaming through the terminal/transcript. Default output is TSV;
--format json gives you the raw /api/dataset response body.
If the DB ID is wrong, metabase:query exits non-zero with a pointer back
to metabase:databases. Fail-fast is intentional — silently querying the
wrong database is worse than failing.
ClickHouse: what counts as a slow query
query_duration_ms > 30000
OR exception_code IN (159, 160, 241)
| Code | Meaning |
|---|---|
| 159 | TIMEOUT_EXCEEDED |
| 160 | TOO_SLOW |
| 241 | MEMORY_LIMIT_EXCEEDED |
ClickHouse que
Установить querying-production-databases-via-metabase в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл querying-production-databases-via-metabase?
Fallback for read-only production database analysis through PostHog's internal Metabase instances. Use the `querying-production-databases` skill first. Use this one for Postgres query plans and index selection (EXPLAIN), the test cluster, live `system.query_log` across the cluster, shareable Metabase links, or a session without the PostHog MCP. Covers US and EU database discovery, SSO login through `hogli`, safe query rules, and query patterns for both engines.
Как установить скилл querying-production-databases-via-metabase?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл querying-production-databases-via-metabase запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic