본문으로 건너뛰기

cloudflare/cloudflare-prometheus-exporter

Export Cloudflare metrics to Prometheus. Built on Cloudflare Workers with Durable Objects for stateful metric accumulation.

https://skillcdn.ai/gh/cloudflare/cloudflare-prometheus-exporter

내 AI에 이 주소를 연결하면 이 스킬을 쓸 수 있어요. 연결 방법 보기

  • 미확인
  • 기본 브랜치main
  • 커밋85d98a1
  • 라이선스MIT
  • 검색단어
GitHub에서 보기

adding-metrics

Add new Prometheus metrics to the Cloudflare exporter. Use when adding metrics, implementing new GraphQL/REST queries, or extending metric coverage. Covers the full workflow from schema discovery through client implementation and README updates.

경로
.agents/skills/adding-metrics/SKILL.md
라이선스
MIT

Adding Metrics

Guided workflow for adding new Prometheus metrics to the Cloudflare Prometheus Exporter. Derived from patterns in PRs #10, #13, #14, #15, and opencode session 1770403408223-happy-garden.

Decision Tree

What kind of metric are you adding?
|
+-- Uses Cloudflare GraphQL API?
|   |
|   +-- Scoped to a single account (no zones)?
|   |   -> Account-level GraphQL
|   |   -> See workflow.md, Step A
|   |
|   +-- Scoped to zones (needs zoneTag_in)?
|       -> Zone-level GraphQL
|       -> See workflow.md, Step B
|
+-- Uses Cloudflare REST API?
    -> REST API (zone-scoped DO)
    -> See workflow.md, Step C

Quick Reference: Files to Modify

StepFileChange
1src/cloudflare/gql/queries.tsAdd graphql() tagged template (skip for REST)
2src/cloudflare/queries.tsAdd to MetricQueryNameSchema enum + category arrays
3src/cloudflare/client.tsImport query, add switch case, implement handler
4src/durable-objects/MetricExporter.tsOnly if special guardrails needed (e.g. allowlists)
5README.mdAdd metric docs + update architecture diagram counts

Key Conventions

  • Metric names: cloudflare_<scope>_<thing>_<unit> -- _total for counters, _seconds for durations
  • Label keys: snake_case always. Normalize accounts via normalizeAccountName(), zones via findZoneName()
  • Counter vs Gauge: counters for window totals (DO accumulates); gauges for snapshots/rates/ratios
  • Null safety: noUncheckedIndexedAccess is on -- null-coalesce everything: dims?.field ?? ""
  • Empty filter: Always return [...metrics].filter(m => m.values.length > 0)
  • Exhaustive switch: Both dispatch methods use const _exhaustive: never = query -- TS errors if case missing

Reading Order

TaskFiles
Add a metric (full workflow)workflow.md
Copy/paste code templatespatterns.md
Avoid known pitfallsgotchas.md

In This Reference

FilePurpose
workflow.mdStep-by-step checklist per metric category
patterns.mdCode templates for queries, handlers, and MetricDefinitions
gotchas.mdPitfalls from real PRs and code reviews

이 스킬의 파일

지원 파일 전체 둘러보기