statsd

配置自定义聚合规则与刷新间隔以收集 StatsD 指标,并通过基于标签的维度路由将指标发送到 Graphite Carbon、InfluxDB Line Protocol 或 Datadog DogStatsD 端点。

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "statsd":https://skillpi.com/zh/skills/deepskill-e1abd99588a979e67a02ce9140e776a45174534c3150ccc651405f3fdd69f99b。安装前核对上游来源和版本:https://skillhub.cn/skills/user_3c6cb52e/statsd-metrics-aggregation-pipeline。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

skillhub.cn

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

配置自定义聚合规则与刷新间隔以收集 StatsD 指标,并通过基于标签的维度路由将指标发送到 Graphite Carbon、InfluxDB Line Protocol 或 Datadog DogStatsD 端点。

0 下载

介绍来源: third_party · user_3c6cb52e · 1.0.0 参考来源

SkillPi 解读

实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: statsd
description: >-
  StatsD metric instrumentation: push metrics over UDP, choose the right metric
  type, name consistently. Invoke whenever task involves any interaction with
  StatsD metrics — emitting counters, gauges, timers, histograms, sets, or
  distributions; configuring DogStatsD tags; tuning sampling rates; or
  integrating with Graphite, Prometheus, or Telegraf backends.

StatsD

Choose the right metric type, name it with dot-delimited hierarchy, tag dimensions instead of encoding them in names. StatsD is fire-and-forget: UDP means zero latency impact, but wrong metric types or bad naming corrupt your data silently.

References

  • Metric types — [${CLAUDE_SKILL_DIR}/references/metric-types.md]: Wire format details, type comparison, sampling correction
  • Naming — [${CLAUDE_SKILL_DIR}/references/naming.md]: Graphite namespace mapping, character rules, naming examples
  • DogStatsD — [${CLAUDE_SKILL_DIR}/references/dogstatsd.md]: Events format, service checks, protocol versions, distributions vs histograms
  • Aggregation — [${CLAUDE_SKILL_DIR}/references/aggregation.md]: Flush mechanics, Graphite downsampling, DogStatsD aggregation, timestamps
  • Client patterns — [${CLAUDE_SKILL_DIR}/references/client-patterns.md]: High-throughput tuning, error handling, K8s deployment, UDS configuration
  • Backends — [${CLAUDE_SKILL_DIR}/references/backends.md]: statsd_exporter config, Telegraf setup, migration guides

Metric Types

Wire format: <metric_name>:<value>|<type>[|@<sample_rate>][|#<tags>]

Decision Matrix

Question Type
How many times did X happen? Counter (c)
What is X right now? Gauge (g)
How long did X take? Timer (ms)
What is the distribution of X? Histogram (h)
How many unique X occurred? Set (s)
What is the global distribution of X? Distribution (d, DogStatsD only)

Wrong metric type = wrong math at the server. A gauge used as a counter loses data between flushes; a counter used as a gauge produces meaningless rates.

Counter (|c)

Measures rate of events over time. Server sums all values during flush interval, resets to 0 after flush, reports both raw count and per-second rate.

  • Use for: request counts, error counts, event occurrences (cache hits, logins)
  • Sample rate correction: value multiplied by 1/rate
  • Supports sampling (|@<rate>)

Gauge (|g)

Instantaneous value at a point in time. Server stores last value received, retains between flushes (sticky).

  • Use for: queue depth, active connections, memory/CPU usage, thread pool size
  • Signed values (+N, -N) modify current value incrementally
  • Cannot set to a negative number directly — set to 0 first, then decrement
  • Do not sample gauges — server cannot correct for sampling on point-in-time values

Timer (|ms)

Duration of an operation in milliseconds. Server computes per flush interval: count, mean, upper (max), lower (min), sum, stddev, median, configurable percentiles (p90, p95, p99).

  • Use for: HTTP request latency, DB query duration, function execution time
  • Supports sampling (|@<rate>)

Histogram (|h)

Distribution of values over time. Identical to timer in most implementations. DogStatsD treats histograms as the native distribution type.

  • Use for: request payload sizes, response body sizes, batch sizes
  • Conceptually: timers measure duration, histograms measure arbitrary distributions

Set (|s)

Count of unique values per flush interval. Server tracks distinct values, reports cardinality at flush, resets.

  • Use for: unique users, unique IPs, unique error codes per interval
  • Do not sample sets — sampling breaks uniqueness tracking

Distribution (|d) — DogStatsD Only

Global distribution across all hosts. Raw values sent to Datadog servers (not aggregated locally). Use when you need accurate fleet-wide percentiles.

See ${CLAUDE_SKILL_DIR}/references/dogstatsd.md for distributions vs histograms comparison and protocol version details.

Naming

Format: <namespace>.<subsystem>.<target>.<metric>.<unit>

Example: myapp.api.request.duration.ms, myapp.cache.hit.count.total

Naming Rules

  • Always namespace by service name — myapp.api.requests not just requests
  • Use dot-delimited hierarchy
  • Include the unit: .ms, .bytes, .total, .items
  • Dimensions go in tags, not metric names (when tags are available)
  • Use lowercase everywhere — some backends are case-sensitive
  • Use underscores within path segments: http_request not httpRequest
  • No dashes — they break Graphite navigation

See ${CLAUDE_SKILL_DIR}/references/naming.md for Graphite namespace mapping, character rules table, and naming anti-patterns.

Tags (DogStatsD)

Format: metric.name:1|c|#key1:value1,key2:value2 — comma-separated, no spaces.

Tag Rules

  • Use tags for dimensions you will filter or group by — not metric names
  • Keep cardinality bounded — each unique tag combination creates a separate time series
  • No spaces in tag values — use underscores: region:us_east

Unified Service Tagging

Set these as global/constant tags on the client — attach to every metric automatically:

  • env — Deployment environment (env:production)
  • service — Service name (service:payment-api)
  • version — Deployed version (version:2.1.0)

Tag Cardinality

Rule of thumb: if a tag can have >1000 distinct values, do not use it. Use logs or traces for high-cardinality data.

  • env:production — ~3-5 values: Yes
  • method:GET — ~7 values: Yes
  • status_code:200 — ~20-50 values: Yes
  • endpoint:/api/users — ~50-200 values: Caution
  • user_id:12345 — Unbounded: No

Aggregation and Flush

The flush cycle determines metric resolution. Default: 10 seconds.

  • Counters reset to 0 after flush; gauges are sticky (retain last value)
  • If no counter values received during flush: behavior depends on deleteCounters config (default: send 0)
  • Enable client-side aggregation for high-throughput applications (Go v5.0+, Java v3.0+, .NET v7.0+) — pre-aggregates before sending to Agent

See ${CLAUDE_SKILL_DIR}/references/aggregation.md for flush mechanics, Graphite downsampling rules, DogStatsD aggregation details, and pre-aggregated timestamps.

Client Patterns

Initialization

  • One client instance per application — do not create per-request
  • Set namespace prefix — auto-prepends to all metric names
  • Set global/constant tags — env, service, version set once
  • Close/flush on shutdown — buffered metrics lost otherwise

Buffering

Enable client-side buffering — packs multiple metrics into single UDP packets. Reduces syscall overhead in hot paths. Most modern DogStatsD clients buffer by default. Call flush() before shutdown.

Sampling

Client randomly decides whether to send each metric based on sample rate. Datagram includes |@<rate> so server corrects the count.

  • < 1000 metrics/sec — rate=1.0 (no sampling)
  • 1000-10000/sec — rate=0.5 to 0.1 for counters/timers
  • > 10000/sec — rate=0.1 or lower; enable client-side aggregation

Never sample gauges or sets — server cannot correct for these types.

See ${CLAUDE_SKILL_DIR}/references/client-patterns.md for high-throughput tuning steps, error handling, and Kubernetes deployment patterns.

Backends

  • Simple, self-hosted graphing — Graphite
  • Cloud monitoring + APM — Datadog (DogStatsD)
  • Prometheus ecosystem integration — statsd_exporter
  • Flexible multi-output pipeline — Telegraf
  • Migrating StatsD to Prometheus — statsd_exporter with relay

See ${CLAUDE_SKILL_DIR}/references/backends.md for statsd_exporter configuration, Telegraf setup, and migration guides.

Application

When writing StatsD instrumentation:

  • Choose the metric type based on what the value represents, not convenience.
  • Apply naming conventions silently — don't narrate each rule.
  • If an existing codebase contradicts a convention, follow the codebase and flag the divergence once.
  • Always configure client-side buffering for production use.

When reviewing StatsD instrumentation:

  • Check metric type correctness first — most common and most damaging mistake.
  • Verify tag cardinality is bounded.
  • Cite the specific issue and show the fix inline.

Integration

The coding skill governs workflow; this skill governs StatsD instrumentation choices.

当前收录版本

1.0.0

核对来源版本 ↗

安全与评测信息

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • Comprehensive StatsD instrumentation guide covering all major aspects
  • Practical decision matrices and rules of thumb for real-world usage
  • Clear target audience of developers working with monitoring systems
触发精准90/100

亮点

  • Frontmatter description precisely defines StatsD-related scenarios
  • Covers all major StatsD operations: metric emission, configuration, integration
  • Clear boundary definition for when this skill should be invoked
结构规范95/100

亮点

  • Well-organized sections with logical flow from basics to advanced topics
  • Includes practical decision matrix for metric type selection
  • Clear application guidelines for both writing and reviewing instrumentation
执行可靠90/100

亮点

  • Specific wire format specifications reduce ambiguity
  • Clear warnings about common pitfalls and anti-patterns
  • References to external documentation provide implementation details
证据可验 (前四项均值)90/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。