Skip to content

UDP and HTTP servers to collect and display user-bound metrics

Notifications You must be signed in to change notification settings

Doist/metric-watcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Metric watcher

Metric watcher is a pair of UDP and HTTP servers to collect and display user-bound metrics.

It's not intended to collect time series, instead it's focused on collecting and displaying "current state of the art". Collected data should help answering on following types of questions:

  1. What's the average response time of the query? Are there any "outliers", users, whose response time is significantly and unexpectedly greater that the average value.

  2. What's the average number of queries per second for users? Are there any users who make much more queries than the average.

Starting the server

Usage:

node lib/metric_watcher.js [--tcp-port 1234] \
        [--udp-port 1234] \
        [--store-limit 1000] \
        [--stores filename.json]

All arguments are optional:

  • --tcp-port: TCP port of HTTP server (by default, 1234)
  • --udp-port: port of UDP server (by default, 1234)
  • --store-limit: limit for each store, in items (by default, 1000)
  • --stores: stores filename, where data will be read from on startup, and written to on shutdown

UDP server and protocol

UDP server waits data from a web application on UDP port 1234. Every incoming packet contains one or more newline-separated strings. Each string describes one metric, it's a space-separated line, starting with the type of metric and then containing a bunch of type-specific data.

We support two types of metrics.

Gauge data (such as response time)

gauge <key> <id> <value> [[[gamma0] timestamp] reset]\n

For example:

gauge syncRequest 123 123.45 1000 1380904002.80 0\n

where

  • gauge: should be provided exactly as is, it's the metric type
  • <key>: (string) metric name
  • <id>: (int or string) user id (or email, or other type of unique identifier)
  • <value>: (float) current metric value
  • [gamma0]: (optional, positive float). Describes how previous values affect current one (smoothing factor). The bigger gamma0 is, the bigger the smoothing is. If not set, value 1.0 is used
  • timestamp: (optional, positive float). Timestamp in seconds since epoch. If not set, current time will be used.
  • reset: (optional, 0 or 1). If set to 1, don't take previous values into account while saving a new one. Default value is 0.

Counter data (such as number of requests per second)

counter <key> <id> [[[gamma0] timestamp] reset]\n

For example:

counter getRequest 123 1000 1380904002.80 0\n

The meaning of values is the same as for gauge, except that there is no "value" field.

HTTP server

RESTful API


- `/metrics/dump`: get the dump of metrics, as stored in json dump whe
  `--stores` option is used
- `/metrics`: get the dict `metric name -> number of unique element in metric`
- `/metrics/get?name=<metric_name>`: for a given metric name get the dict
  `user id -> metric value`

About

UDP and HTTP servers to collect and display user-bound metrics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published