Skip to main content

Module dogstatsd

Module dogstatsd 

Source
Expand description

DogStatsD payload generation.

Dogstatsd is three message types: metric, event, service check.

§Metrics

<NAME>:<VALUE>|<TYPE>|@<SAMPLE_RATE>|#<TAG>,<TAG>...|c:<CONTAINER>|T<TS>|e:<EXT>|card:<CARD>

Required: <NAME>:<VALUE>|<TYPE>.

<NAME>        := [^:|\n]+
<VALUE>       := <NUMBER>(:<NUMBER>)*        ':'-packed multi-value, non-set
               | [^|\n]+                     raw string, set type
<NUMBER>      := [+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)? | [+-]?(inf|infinity|nan)
<TYPE>        := c|g|ms|h|s|d                count gauge timer histogram set distribution
<SAMPLE_RATE> := @<NUMBER>
<TAG>         := [^,|\n]+                    conventionally <KEY>:<VALUE>, the ':' is not required
<CONTAINER>   := c:[^|\n]+                   e.g. ci-<id>, in-<inode>
<TS>          := T\d+                        unix seconds
<EXT>         := e:[^|\n]+                   e.g. it-,cn-,pu-
<CARD>        := card:[^|\n]+                recognized: none|low|orchestrator|high

§Events

_e{<TITLE_LEN>,<TEXT_LEN>}:<TITLE>|<TEXT>|d:<TS>|h:<HOST>|k:<AGGKEY>|p:<PRIO>|s:<SRC>|t:<ALERT>|#<TAGS>

Required: _e{<TITLE_LEN>,<TEXT_LEN>}:<TITLE>|<TEXT>. c: / e: / card: are valid here too.

<TITLE_LEN>,<TEXT_LEN> := \d+               byte length of TITLE / TEXT
<TITLE>,<TEXT>         := [^\n]{LEN}         length-delimited, so '|' and ':' are allowed
<TS>          := d:\d+                       unix seconds
<HOST>        := h:[^|\n]+
<AGGKEY>      := k:[^|\n]+
<PRIO>        := p:[^|\n]+                   recognized: normal|low (else default)
<SRC>         := s:[^|\n]+
<ALERT>       := t:[^|\n]+                   recognized: error|warning|info|success (else default)
<TAGS>        := #<TAG>(,<TAG>)*

§Service checks

_sc|<NAME>|<STATUS>|d:<TS>|h:<HOST>|#<TAG>,<TAG>...|m:<MESSAGE>

Required: _sc|<NAME>|<STATUS>. c: / e: / card: are valid here too.

<NAME>        := [^|\n]+
<STATUS>      := [0-3]                       OK warning critical unknown
<TS>          := d:\d+                       unix seconds
<HOST>        := h:[^|\n]+
<TAGS>        := #<TAG>(,<TAG>)*
<MESSAGE>     := m:[^|\n]+

§Name combinatorics

A clean name is c segments from COMPLIANT_WORD (10 words) joined by NAME_SEPARATORS (4). Distinct names at count c: 10^c · 4^(c-1). c is sampled by vibe: clean draws from ELEMENT_COUNTS_CLEAN (a small body, no boundary cases); feral draws from ELEMENT_COUNTS_FERAL, which adds the 0 and large boundary counts as a tail.

cP(c) cleanP(c) feraldistinct names
01/121 (empty)
1-36/96/1210 .. ~16e3
4-63/93/12~640e3 .. ~1e9
1271/12~10^203
2551/12~10^408

Enums§

Vibe
Clean by-the-book output, or feral.

Functions§

sample_vibe
Sample a per-line vibe, evenly.
send
Write one DogStatsD message of a sampled type to buf at the given vibe. Returns the packed value count when a multi-value metric was emitted, else None.