ML Documentation

追加すべきメトリクス一覧

1. システムリソースメトリクス

2. ビジネスメトリクス

3. データ品質メトリクス

4. エラー率とリトライメトリクス

5. Kafkaメトリクス(詳細)

6. QuestDB詳細メトリクス

実装例(Rust)

// 価格変動率の計算
lazy_static! {
    pub static ref PRICE_CHANGE_PERCENTAGE: GaugeVec = register_gauge_vec!(
        "crypto_price_change_percentage",
        "Price change percentage over different time windows",
        &["symbol", "window"]
    ).unwrap();

    pub static ref SPREAD_PERCENTAGE: GaugeVec = register_gauge_vec!(
        "crypto_spread_percentage",
        "Bid-ask spread as percentage of mid price",
        &["symbol"]
    ).unwrap();

    pub static ref MARKET_DEPTH: GaugeVec = register_gauge_vec!(
        "crypto_market_depth_usd",
        "Market depth in USD at different price levels",
        &["symbol", "side", "level"]
    ).unwrap();
}

// 使用例
fn calculate_metrics(orderbook: &Orderbook) {
    // スプレッド計算
    let spread_pct = (orderbook.best_ask - orderbook.best_bid) / orderbook.mid_price * 100.0;
    SPREAD_PERCENTAGE
        .with_label_values(&[&orderbook.symbol])
        .set(spread_pct);

    // 市場深度計算(例:0.1%以内の流動性)
    let depth_bid = calculate_depth(&orderbook.bids, orderbook.mid_price * 0.999);
    let depth_ask = calculate_depth(&orderbook.asks, orderbook.mid_price * 1.001);

    MARKET_DEPTH
        .with_label_values(&[&orderbook.symbol, "bid", "0.1%"])
        .set(depth_bid);
}

Grafanaダッシュボード追加パネル案

  1. システムヘルス
    - CPU/メモリ使用率ゲージ
    - ディスク容量アラート
    - ネットワークスループット

  2. データ品質
    - データ遅延ヒートマップ
    - エラー率トレンド
    - 重複検出率

  3. ビジネスインサイト
    - 価格変動率チャート
    - 取引量ヒートマップ(時間×シンボル)
    - スプレッド推移グラフ

  4. アラート設定案
    - CPU使用率 > 80%
    - メモリ使用率 > 90%
    - データ遅延 > 1秒
    - エラー率 > 1%
    - スプレッド異常拡大