• Projects
  • Service
  • About
  • branding.bz
  • Podcast
  • Tips
  • FAQ
  • Recruit
  • Download
  • Contact
  • branding.bz(ブランド構築SaaS)
  • DESIGN NOW(デザインメディア)
  • X
  • LinkedIn
  • Spotify
  • Facebook

213-0011 神奈川県川崎市高津区久本3-6-7-303

© 2026 ID INC. All rights reserved

claude-skills/スキル
SKILLKnowledge Workmonitoring

signoz-writing-clickhouse-queries

プラグイン
SigNoz
ソース
GitHub で見る ↗
説明

SigNoz ダッシュボードパネル用の ClickHouse SQL(データベース問い合わせ言語)を作成します。これは、ビルダー UI では表現できない複雑な処理に対応します。具体的には、複数テーブルの結合、ウィンドウ関数(時系列データの統計計算)、ログ本文からの正規表現による抽出、ビルダー構文では対応できない集計などを含む、時系列グラフ・数値表示・テーブルなどのウィジェットに対応しています。 **次のような場合に使用:** - ユーザーが「ClickHouse クエリ」「生の SQL パネル」「カスタム SQL ウィジェット」を明示的に要求する場合 - SigNoz ダッシュボードパネルの説明で、ビルダーでは作成できない SQL クエリが必要な場合 このスキルはダッシュボードパネルの SQL 作成に特化しています。一度きりのデータ探索で、ダッシュボードパネルに組み込まない場合は、代わりに `signoz-generating-queries` を使用してください。

原文を表示

Write raw ClickHouse SQL for a SigNoz dashboard panel — timeseries, value, or table widgets that the builder UI cannot express (custom joins, window functions, regex extraction over log bodies, aggregations beyond builder syntax). Trigger when the user explicitly asks for a "ClickHouse query", a "raw SQL panel", a "custom SQL widget", or describes a SigNoz dashboard panel whose query needs SQL the builder cannot produce. Anchored to dashboard-panel SQL specifically. For ad-hoc data exploration that does not need to land in a panel, use `signoz-generating-queries` instead.

ユースケース
  • ビルダーUIでは表現できない複雑なSQL処理が必要
  • 複数テーブルの結合が必要
  • ウィンドウ関数で時系列データを統計計算
  • ログ本文から正規表現で抽出
  • ダッシュボードパネルにカスタムSQLウィジェットを組み込む
本文(日本語訳)

SigNozダッシュボード向けClickHouseクエリの作成

使用場面

次のようなSigNozクエリについてユーザーが質問した場合に使用します:

  • ログ: 重大度、本文、ログ量、構造化フィールド、コンテナ、サービス、環境
  • トレース: スパン(処理の個別単位)、遅延、処理時間、p95またはp99パーセンタイル、HTTPオペレーション、データベース操作、エラースパン
  • ダッシュボードパネル: 時系列グラフ、数値ウィジェット、テーブル形式の内訳

ユーザーがダッシュボードパネルをリクエストしたがClickHouseに言及していない場合でも、このスキルを使用してください。

シグナル判定

リクエストがログについてなのかトレースについてなのかを判断します。

  • ログ: ログ行、重大度、本文、ログ量、コンテナログ、構造化ログフィールド
  • トレース: スパン、遅延、処理時間、p99、トレース分析、HTTPオペレーション、データベース操作、エラースパン

リクエストが曖昧な場合は、ユーザーに明確にするよう求めてください。

リファレンス参照

  • ログ: クエリを作成する前に references/clickhouse-logs-reference.md を参照してください。
  • トレース: クエリを作成する前に references/clickhouse-traces-reference.md を参照してください。

各リファレンスには、テーブルスキーマ、最適化パターン、属性アクセス方法、ダッシュボードテンプレート、クエリ例、検証チェックリストが含まれています。

クイックリファレンス

  • 時系列パネル: 時系列グラフ用に (ts, value) の行を返す
  • 数値パネル: 統計情報やカウンターウィジェット用に単一の value を返す
  • テーブルパネル: グループ別の内訳用にラベル付き列を返す

シグナルごとの主要変数

ログ

  • タイムスタンプ型: ナノ秒単位の UInt64
  • 時間フィルタ: $start_timestamp_nano および $end_timestamp_nano
  • バケットフィルタ: $start_timestamp および $end_timestamp
  • 表示変換: fromUnixTimestamp64Nano(timestamp)
  • メインテーブル: signoz_logs.distributed_logs_v2
  • リソーステーブル: signoz_logs.distributed_logs_v2_resource

トレース

  • タイムスタンプ型: DateTime64(9)
  • 時間フィルタ: $start_datetime および $end_datetime
  • バケットフィルタ: $start_timestamp および $end_timestamp
  • 表示変換: タイムスタンプをそのまま使用
  • メインテーブル: signoz_traces.distributed_signoz_index_v3
  • リソーステーブル: signoz_traces.distributed_traces_v3_resource

よくある落とし穴

  • ts_bucket_start BETWEEN $start_timestamp - 1800 AND $end_timestamp が抜けている
  • 分散テーブルを読む副問い合わせを含む単純な IN / JOIN: distributed_product_mode='deny' の場合は失敗します。代わりに時間制限付きのフィンガープリント GLOBAL IN パターンまたはローカル副問い合わせテーブルを使用してください。GLOBAL JOIN は確実に小規模で制限された右側のみに使用してください(全シャードにデータセットを送信するため)
  • リソース属性フィルタがないのにリソース共通表式(CTE)を追加している
  • GROUP BY から集約されていない列(JSONExtractString(body, ...) などの計算列を含む)を省略している
  • ログクエリで $start_datetime または $end_datetime を使用している
  • トレースクエリで $start_timestamp_nano または $end_timestamp_nano を使用している
  • signoz_logs.logs、素の logs、distributed_logs に対するログクエリ: 常に signoz_logs.distributed_logs_v2 を使用してください
  • resources_string['service.name'] ではなく resource_string_service$$name を使用するトレースクエリ

クエリの帰属表記

生成されたすべてのクエリは、監視用に SETTINGS 句で終わる必要があります:

SELECT ...
FROM ...
WHERE ...
SETTINGS log_comment = 'signoz-writing-clickhouse-queries skill | YYYY-MM-DD'

YYYY-MM-DD を今日の日付に置き換えてください(例: 2026-04-03)。クエリにすでに SETTINGS 句がある場合は、コンマで区切って log_comment を追加してください。

ワークフロー

  1. シグナルを判定: ログかトレースか
  2. リファレンスファイルを読む(該当する方を先に読んでください)
  3. パネルタイプを選ぶ: 時系列、数値、またはテーブル
  4. リファレンスの必須パターンを使用してクエリを構築する
  5. SETTINGS log_comment 帰属表記句を追加する
  6. リファレンスのチェックリストで結果を検証する
原文(English)を表示

Writing ClickHouse Queries for SigNoz Dashboards

When to Use

Use this skill when the user asks for SigNoz queries involving:

  • Logs: severity, body text, log volume, structured fields, containers, services, or environments.
  • Traces: spans, latency, duration, p95 or p99, HTTP operations, DB operations, or error spans.
  • Dashboard panels: timeseries charts, value widgets, and table breakdowns.

If the user asks for a dashboard panel but does not mention ClickHouse, still use this skill.

Signal Detection

Identify whether the request is about logs or traces.

  • Logs: log lines, severity, body text, log volume, container logs, or structured log fields.
  • Traces: spans, latency, duration, p99, trace analysis, HTTP operations, DB operations, or error spans.

If the request is ambiguous, ask the user to clarify.

Reference Routing

  • Logs: read references/clickhouse-logs-reference.md before writing any query.
  • Traces: read references/clickhouse-traces-reference.md before writing any query.

Each reference covers table schemas, optimization patterns, attribute access syntax, dashboard templates, query examples, and a validation checklist.

Quick Reference

  • Timeseries panel: return rows of (ts, value) for a chart over time.
  • Value panel: return a single value for a stat or counter widget.
  • Table panel: return labelled columns for a grouped breakdown.

Key Variables by Signal

Logs

  • Timestamp type: UInt64 in nanoseconds.
  • Time filter: $start_timestamp_nano and $end_timestamp_nano.
  • Bucket filter: $start_timestamp and $end_timestamp.
  • Display conversion: fromUnixTimestamp64Nano(timestamp).
  • Main table: signoz_logs.distributed_logs_v2.
  • Resource table: signoz_logs.distributed_logs_v2_resource.

Traces

  • Timestamp type: DateTime64(9).
  • Time filter: $start_datetime and $end_datetime.
  • Bucket filter: $start_timestamp and $end_timestamp.
  • Display conversion: use the timestamp directly.
  • Main table: signoz_traces.distributed_signoz_index_v3.
  • Resource table: signoz_traces.distributed_traces_v3_resource.

Top Anti-Patterns

  • Missing ts_bucket_start BETWEEN $start_timestamp - 1800 AND $end_timestamp.
  • Plain IN / JOIN whose subquery reads a distributed table: with distributed_product_mode='deny' it fails. Prefer the time-bounded fingerprint GLOBAL IN pattern or a local subquery table. Use GLOBAL JOIN only for a demonstrably small, bounded RHS; it broadcasts that dataset to every shard.
  • Adding a resource CTE when there is no resource attribute filter.
  • Omitting a non-aggregated projection from GROUP BY, including computed projections such as JSONExtractString(body, ...).
  • Logs query with $start_datetime or $end_datetime.
  • Traces query with $start_timestamp_nano or $end_timestamp_nano.
  • Logs query against signoz_logs.logs, bare logs, or distributed_logs; always use signoz_logs.distributed_logs_v2.
  • Traces query with resources_string['service.name'] instead of resource_string_service$$name.

Query Attribution

Every generated query MUST end with a SETTINGS clause for monitoring:

SELECT ...
FROM ...
WHERE ...
SETTINGS log_comment = 'signoz-writing-clickhouse-queries skill | YYYY-MM-DD'

Replace YYYY-MM-DD with today's date (e.g., 2026-04-03). If the query already has a SETTINGS clause, append log_comment to it with a comma.

Workflow

  1. Detect the signal: logs or traces.
  2. Read the matching reference file before writing the query.
  3. Pick the panel type: timeseries, value, or table.
  4. Build the query using the required patterns from the reference.
  5. Append the SETTINGS log_comment attribution clause.
  6. Validate the result with the checklist in the reference.

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。