Honeycomb(クラウド基盤の分析プラットフォーム)でのクエリ(検索・分析命令)の構築と結果の解釈について、実用的で確かな方法を説明します。 対象範囲: - 操作の選択: パーセンタイル値(遅延時間の分布を100段階で表示)の活用、AVG(平均値)ではなく HEATMAP(分布図)の使用 - リレーショナルフィールド(root.、parent.、any.、none. といった関連データの参照パターン) - 計算済みフィールド(既存データから自動算出される項目) - クエリの数式演算 - 結果の読み取り: P99/P50 比率、ヒートマップの帯状表示、TOTAL/OTHER 行、JSON 形式での生データ取得 次のような場合に使用: ユーザーがスパン(処理単位の記録)・トレース(一連の処理フロー)・ログやイベントデータを Honeycomb で検索したいとき。「レイテンシ(応答時間)を表示してほしい」「エラー率を知りたい」「遅いリクエストを見つけたい」「外れ値を抽出したい」「結果を解釈してほしい」「リレーショナルフィールドについて」「計算済みフィールドについて」「生データをダウンロードしたい」といった要望があるとき。 メトリクスデータセット(dataset_type=metrics)を除くすべてのデータセット種別に対応します。メトリクス用のクエリについては、metrics-queries スキルを使用してください。
Opinionated guidance for constructing and interpreting Honeycomb queries on trace and event datasets — operation selection (percentiles not AVG, HEATMAP for distributions), relational field patterns (root., parent., any., none.), calculated fields, query math, and result interpretation (P99/P50 ratios, heatmap bands, TOTAL/OTHER rows, raw JSON via query_result_json). Use this skill when the user wants to query spans, traces, or log/event data in Honeycomb — requests like "show me latency", "error rate", "find slow requests", "find outliers", "interpret results", "relational fields", "calculated fields", or "download raw results". This skill covers all dataset types except metrics datasets (dataset_type=metrics) — for those, use metrics-queries instead.
効果的なHoneycombクエリを書くための実践的なガイドです。MCPツールには既にパラメータとスキーマの説明がありますが、このスキルは「いつ なぜ 各パターンを使うのか」に焦点を当てており、「どうやって ツールを呼び出すか」ではありません。
COUNT, P99(duration_ms), HEATMAP(duration_ms) を1つのクエリで実行すると、API呼び出しが減り、全体像が見えます。find_queries を呼び出してください。誰かが既に同じ質問に答えているかもしれません。| 知りたいこと | 使用する操作 |
|---|---|
| トラフィック量はどのくらい? | COUNT(ルートまたはサービスでグループ化) |
| ユニークな利用者/IPアドレスは何個? | COUNT_DISTINCT(フィールド) |
| ほとんどの利用者にはどのくらい速い? | P50(duration_ms) |
| 遅い利用者にはどのくらい速い? | P99(duration_ms) |
| 二山分布のパターンがある? | HEATMAP(duration_ms) |
| 最悪のケースは? | MAX(duration_ms) |
| 同時実行の処理は何個? | CONCURRENCY |
| 時間とともに悪化している? | RATE_AVG(duration_ms) |
関連フィールドのプレフィックスを使って、トレース内のスパン(処理の記録)をまたいだ質問をします:
any.service.name でフィルタして、そのサービスが関わるトレースを探し、root.http.route でグループ化して、影響を受けているユーザー向けエンドポイントを把握します。any.error = true でフィルタし、root.name でグループ化して、トレース木のどのエントリポイントにエラーがあるかを見ます。none.service.name = "health-check" でヘルスチェックを含むトレースを削除します。計算フィールドはクエリ実行時に評価される行ごとの式です。コードに変更を加えることなく、既存フィールドを変換・分類・組み合わせます。
3つのスコープ — 必要に応じて最も狭い範囲を選ぶ:
error_pct)一般的なパターン:
MUL(IF($error, 1, 0), 100) → AVG(error_pct) でパーセンテージを取得IF(GTE($http.status_code, 500), "5xx", GTE($http.status_code, 400), "4xx", "ok")BUCKET($duration_ms, 500, 0, 3000)IF(STARTS_WITH($url, "/admin"), "admin", STARTS_WITH($url, "/api"), "api", "other")IF(EQUALS(...)) をつなげるのではなく SWITCH を使う — 同じ式でより効率的重要な注意点:
REG_MATCH、REG_VALUE、REG_COUNT を exception.stacktrace、db.statement、長いログ行に実行すると非常に遅くなります。より対象を絞ったOpenTelemetry(技術標準)フィールド(exception.type、exception.message、db.operation)が存在するかを先に確認してください。長いフィールドに正規表現を使わなくてはならない場合は、まず CONTAINS チェックで守ってください。EQUALS は厳密な型チェック — EQUALS($http.status_code, 200) はフィールドが文字列として保存されていると黙って false を返します。比較する前に find_columns でフィールド型を確認してください。FORMAT_TIME は重い処理 — 大量のクエリでは避けてください。完全な構文、操作リファレンス、さらに詳しいアンチパターン例は ${CLAUDE_PLUGIN_ROOT}/skills/query-patterns/references/calculated-fields.md を参照してください。
is_root でフィルタする — これがないと、内部の処理記録が数値を膨らませます"24h"、"-6h")— ユニックスタイムスタンプはエラーが起きやすく、見直しが難しくなりますfind_columns でカラムを検証する — フィールド名の存在確認と、結果が空になることを防げますクエリを実行すると、MCPツールは整形されたマークダウンとメタデータを返します。最も重要なメタデータフィールドは query_result_json — 生のJSON結果へのURLです。正確な分析のため、ASCIIレンダリングだけに頼らず、ダウンロードしてjqやPythonで解析してください。
重要な解釈ルール:
▁▂▃▄▅▆▇█ = 低から高への密度;2つの帯 = 2つの利用者グループquery_run_pk — 外れ値分析のため run_bubbleup に直接渡します${CLAUDE_PLUGIN_ROOT}/skills/query-patterns/references/visualize-operations.md — VISUALIZE 操作の完全リファレンスと例${CLAUDE_PLUGIN_ROOT}/skills/query-patterns/references/relational-fields.md — 関連フィールド詳細ガイドとサービス横断パターン${CLAUDE_PLUGIN_ROOT}/skills/query-patterns/references/query-examples.md — ユースケース別に整理された充実したクエリ集${CLAUDE_PLUGIN_ROOT}/skills/query-patterns/references/result-interpretation.md — クエリ結果解釈、生JSONアクセス、統計的ヒューリスティックスガイド${CLAUDE_PLUGIN_ROOT}/skills/query-patterns/references/calculated-fields.md — 計算フィールド構文、操作リファレンス全体、一般的なパターン、アンチパターン(表示用フィールド、重い文字列操作、型不一致)Opinionated guidance for writing effective Honeycomb queries. The MCP tools already document their parameters and schemas — this skill focuses on when and why to use each pattern, not how to call the tools.
COUNT, P99(duration_ms), HEATMAP(duration_ms) in a single query reduces API calls and gives a complete picture.find_queries before writing new queries. Someone may have already answered the question.| Question | Use |
|---|---|
| How much traffic? | COUNT grouped by route or service |
| How many unique users/IPs? | COUNT_DISTINCT(field) |
| How fast for most users? | P50(duration_ms) |
| How fast for the worst-off users? | P99(duration_ms) |
| Is there a bimodal pattern? | HEATMAP(duration_ms) |
| What's the worst case? | MAX(duration_ms) |
| How many concurrent operations? | CONCURRENCY |
| Is it getting worse over time? | RATE_AVG(duration_ms) |
Use relational prefixes to ask cross-span questions within a trace:
any.service.name to find traces where that service participates, group by root.http.route to see which user-facing endpoints are affected.any.error = true, group by root.name to see which entry points have errors somewhere in their trace tree.none.service.name = "health-check" removes traces containing health checks.Calculated fields are per-event expressions evaluated at query time. They transform, classify, and combine existing fields without re-instrumenting code.
Three scopes — choose the narrowest that fits the need:
error_pct)Common patterns:
MUL(IF($error, 1, 0), 100) → use AVG(error_pct) to get percentageIF(GTE($http.status_code, 500), "5xx", GTE($http.status_code, 400), "4xx", "ok")BUCKET($duration_ms, 500, 0, 3000)IF(STARTS_WITH($url, "/admin"), "admin", STARTS_WITH($url, "/api"), "api", "other")SWITCH instead of IF(EQUALS(...)) chains — same expression, more efficientKey guardrails:
REG_MATCH, REG_VALUE, or REG_COUNT on exception.stacktrace, db.statement, or full log lines can be very slow. Check whether a more targeted OTel field exists first (exception.type, exception.message, db.operation). If you must regex a long field, guard it with a CONTAINS check first.EQUALS has strict type matching — EQUALS($http.status_code, 200) silently returns false if the field is stored as a string. Use find_columns to verify the field type before comparing.FORMAT_TIME is expensive — avoid in high-volume queries.For full syntax, operator reference, and extended anti-pattern examples, consult
${CLAUDE_PLUGIN_ROOT}/skills/query-patterns/references/calculated-fields.md.
is_root when measuring user-facing latency — without it, internal spans inflate the numbers"24h", "-6h") — epoch timestamps are error-prone and hard to reviewfind_columns before querying — confirms field names exist and prevents empty resultsAfter running a query, the MCP tool returns formatted markdown plus metadata.
The most important metadata field is query_result_json — a signed URL to the raw
JSON result. For precise analysis, download it and parse with jq or python rather
than relying solely on the ASCII rendering.
Key interpretation rules:
▁▂▃▄▅▆▇█ = density from low to high; two bands = two populationsrun_bubbleup for outlier analysis${CLAUDE_PLUGIN_ROOT}/skills/query-patterns/references/visualize-operations.md — Complete VISUALIZE operation reference with examples${CLAUDE_PLUGIN_ROOT}/skills/query-patterns/references/relational-fields.md — Detailed relational field guide with cross-service patterns${CLAUDE_PLUGIN_ROOT}/skills/query-patterns/references/query-examples.md — Extensive query cookbook organized by use case${CLAUDE_PLUGIN_ROOT}/skills/query-patterns/references/result-interpretation.md — Guide to interpreting query results, raw JSON access, and statistical heuristics${CLAUDE_PLUGIN_ROOT}/skills/query-patterns/references/calculated-fields.md — Calculated field syntax, full operator reference, common patterns, and anti-patterns (presentational fields, expensive string ops, type mismatches)原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。