mcpField
C
cost-management

cost-management

github.com/grafanaクラウド・DevOps2954.3k 回インストール1 日前に更新
リポジトリ

cost-management について

Grafana Cloud のコスト管理スキルです。コストの帰属、Adaptive シグナルの最適化、使用量アラートの設定手順を、可観測性の支出を管理するチーム向けにまとめています。

主な機能

  1. 01チームやサービス別のコスト帰属
  2. 02Adaptive Metrics の推奨事項の適用
  3. 03Alloy でのログフィルタリング
  4. 04使用量アラートの設定
  5. 05PromQL によるコスト調査

活用シーン

  1. 01チームやプロジェクト別のテレメトリー費用の把握
  2. 02メトリクスのカーディナリティとログ取り込み量の削減
  3. 03クォータ到達前の使用量監視

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/grafana/skills --skill cost-management

インストール後、Claude Code で/cost-managementを入力して読み込まれたか確認します。

同梱ファイルreferences/adaptive-signals.mdreferences/alerts-and-queries.md

詳細

Grafana Cloud のコスト管理

ドキュメント: https://grafana.com/docs/grafana-cloud/cost-management-and-billing/

Adaptive シグナルとコスト帰属ラベルを使って、メトリクス/ログ/トレースの費用を削減します。

前提条件

  • Adaptive Metrics/Logs/Traces が有効になっている Grafana Cloud スタック(Cost Management で確認できます)
  • Alloy(または Grafana Agent)でテレメトリーを取り込み、スコープ metrics:write + logs:write(+ traces:write)の API キーを使用していること
  • Adaptive の推奨事項を適用するための、スタックへの管理者アクセス

一般的なワークフロー

1. チーム/サービスにコストを割り当てる
# 1. Add external labels in Alloy (metrics + logs configs)
prometheus.remote_write "cloud" {
  endpoint { url = sys.env("PROMETHEUS_URL") /* ... */ }
  external_labels = { team = "platform", project = "checkout-service" }
}
# 2. Reload Alloy
curl -X POST http://localhost:12345/-/reload

# 3. Verify labels arrived in Grafana Cloud
#    In Explore, run:  count by (team, project) ({__name__=~".+"})
#    Then visit Cost Management → group by `team` / `project`

Alloy の完全なスニペットについては、references/adaptive-signals.md を参照してください。

2. Adaptive Metrics でメトリクスのカーディナリティを削減する
# 1. Pull recommendations
curl https://<stack>.grafana.net/api/plugins/grafana-adaptive-metrics-app/resources/v1/recommendations \
  -H "Authorization: Bearer <token>" | jq '.recommendations | length'

# 2. In the UI: Grafana Cloud → Adaptive Metrics → review rules sorted by series-reduction impact
# 3. Test in "Preview" mode before applying
# 4. Apply (takes effect within 5 min)

# 5. Verify — series count should drop on the affected metrics
#    Before applying, capture baseline:
#      count({__name__="http_request_duration_seconds_bucket"})
#    Wait 10 min after apply, run again — expect 10x+ reduction for high-card metrics.

# Rollback if needed: open the rule in the UI → Disable, or DELETE /v1/rules/<id>.
3. Alloy でノイズの多いログを破棄する
# 1. Add a filter stage (see references/adaptive-signals.md for the full block)
loki.process "filter_logs" {
  forward_to = [loki.write.cloud.receiver]
  stage.drop { expression = ".*GET /health.*" }
}
# 2. Reload Alloy
curl -X POST http://localhost:12345/-/reload

# 3. Verify the filter — health logs should NOT appear in Logs Drilldown
#    LogQL check (should return 0):
#      sum(rate({app="my-app"} |= "GET /health" [5m]))
#    Bytes-ingested should also drop. Compare 24h before/after:
#      sum(increase(loki_ingester_chunk_size_bytes_sum[24h])) by (namespace)
4. クォータに達する前に使用量アラートを設定する

すぐに貼り付けて使えるルール(MetricsUsageHigh、LogsIngestionHigh)については、references/alerts-and-queries.md を参照してください。

最適化チェックリスト

  • Adaptive Metrics の推奨事項を適用する — 通常、時系列数を 40~60% 削減できます
  • Alloy でヘルスチェック/レディネスプローブのログを破棄する
  • トレースを 5~10% にテールサンプリングし、エラー/低速スパンは保持する
  • すべての Alloy 設定に team + project 外部ラベルを追加する
  • クォータの 80% で使用量アラートを設定する
  • コストの高いアドホッククエリをレコーディングルールに置き換える

参考資料

リソース

コメント