analyze-usage
БесплатноБез исполняемых скриптовНе проверенUse when analyzing BigQuery usage patterns, costs, and query performance for a GCP project
от openshift-eng★ 123 звезды на GitHubОб этом скилле
Analyze BigQuery Usage
This skill performs comprehensive analysis of BigQuery usage patterns, costs, and query performance for a given project. It identifies expensive queries, heavy users, and provides actionable optimization recommendations.
When to Use This Skill
This skill is automatically invoked by the /bigquery-cost-analysis:analyze-usage command to perform usage analysis.
Prerequisites
- Google Cloud SDK (
bqcommand-line tool) must be installed - User must have BigQuery read access to the project
- User must be authenticated (
gcloud auth login) - User needs
bigquery.jobs.listpermission at minimum
Parameters
When invoked, this skill expects:
- Project ID: The GCP project ID to analyze (required)
- Timeframe: Time period for analysis in hours (e.g., 24, 168 for 7 days)
Analysis Workflow
1. Validate Prerequisites
First, verify the environment is ready:
- Check if
bqcommand is available - Verify project access
- Parse timeframe into hours
2. Collect Usage Data
Execute the following BigQuery queries against INFORMATION_SCHEMA:
Total Usage Summary
SELECT
COUNT(*) as total_queries,
ROUND(SUM(total_bytes_processed) / POW(10, 12), 2) as total_tb_scanned,
ROUND(SUM(total_bytes_processed) / POW(10, 12) * 6.25, 2) as estimated_cost_usd
FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL @hours HOUR)
AND job_type = 'QUERY'
AND state = 'DONE'
AND statement_type != 'SCRIPT'
Usage by User/Service Account
SELECT
user_email,
COUNT(*) as query_count,
ROUND(SUM(total_bytes_processed) / POW(10, 12), 2) as total_tb_scanned,
ROUND(SUM(total_bytes_processed) / POW(10, 12) * 6.25, 2) as estimated_cost_usd,
ROUND(AVG(total_bytes_processed) / POW(10, 9), 2) as avg_gb_per_query
FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL @hours HOUR)
AND job_type = 'QUERY'
AND state = 'DONE'
AND statement_type != 'SCRIPT'
GROUP BY user_email
ORDER BY total_tb_scanned DESC
LIMIT 20
Top Individual Queries by Cost
SELECT
creation_time,
user_email,
job_id,
ROUND(total_bytes_processed / POW(10, 12), 3) as tb_scanned,
ROUND(total_bytes_processed / POW(10, 12) * 6.25, 2) as cost_usd,
SUBSTR(query, 1, 200) as query_preview
FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL @hours HOUR)
AND job_type = 'QUERY'
AND state = 'DONE'
AND statement_type != 'SCRIPT'
AND total_bytes_processed > 0
ORDER BY total_bytes_processed DESC
LIMIT 20
Query Pattern Analysis
SELECT
SUBSTR(query, 1, 200) as query_pattern,
COUNT(*) as execution_count,
ROUND(SUM(total_bytes_processed) / POW(10, 12), 3) as total_tb_scanned,
ROUND(AVG(total_bytes_processed) / POW(10, 9), 2) as avg_gb_per_execution,
ANY_VALUE(user_email) as sample_user
FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL @hours HOUR)
AND job_type = 'QUERY'
AND state = 'DONE'
AND statement_type != 'SCRIPT'
AND total_bytes_processed > 0
GROUP BY query_pattern
HAVING execution_count > 10
ORDER BY total_tb_scanned DESC
LIMIT 15
3. Per-User Deep Dive Analysis
For the top 2-3 users by data scanned, perform detailed query pattern analysis:
SELECT
SUBSTR(query, 1, 300) as query_pattern,
COUNT(*) as execution_count,
ROUND(SUM(total_bytes_processed) / POW(10, 12), 3) as total_tb_scanned,
ROUND(AVG(total_bytes_processed) / POW(10, 9), 2) as avg_gb_per_execution,
MIN(creation_time) as first_execution,
MAX(creation_time) as last_execution
FROM `region-us`.INFORMATION_SCHEMA.JOBS_BY_PROJECT
WHERE creation_time >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL @hours HOUR)
AND job_type = 'QUERY'
AND state = 'DONE'
AND statement_type != 'SCRIPT'
AND user_email = @user_email
AND total_bytes_processed > 0
GROUP BY query_pattern
ORDER BY total_tb_scanned DESC
LIMIT 20
This reveals:
- What each heavy user is querying
- Patterns in their query behavior
- Opportunities for user-specific optimizations
- Whether queries are automated (service accounts) or manual (humans)
4. Analyze Results and Identify Patterns
Look for common issues:
Query Anti-Patterns:
SELECT *on large tables- Full table scans without WHERE clauses
- High-frequency queries that could be cached
- Queries scanning data unnecessarily (e.g., counting rows by scanning 40GB)
- Missing partitioning filters
- Repeated identical queries
User Behavior Patterns:
- Service accounts with high query volume (automation candidates)
- Deduplication checks that scan large amounts of data
- Dashboard queries hitting raw tables instead of materialized views
- Scheduled queries running too frequently
Cost Drivers:
- Single expensive queries
- High-volume low-cost quer
Установить analyze-usage в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл analyze-usage?
Use when analyzing BigQuery usage patterns, costs, and query performance for a GCP project
Как установить скилл analyze-usage?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл analyze-usage запускает скрипты?
Нет, скилл состоит только из инструкций (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