StatsD is originally a simple daemon developed to aggregate and summarize application metrics. (https://thenewstack.io/collecting-metrics-using-statsd-a-standard-for-real-time-monitoring/)
StatsD is a standard and, by extension, a set of tools that can be used to send, collect, and aggregate custom metrics from any application.
StatsD uses client-server-backend model and three components are: a client, a server and a backend, client-server-backend model provides (a) language independence and (b) reliability.
These metrics are collected by the StatsD server (sometimes also called the daemon). The server aggregates these metrics, then sends the aggregates to one or more backends at regular intervals.
The StatsD client library
The client is a library that is invoked within your application code to send metrics. It sends each individual call to the StatsD server over a UDP datagram.
The StatsD daemon will then listen to the UDP traffic from all application libraries, aggregate data over time and “flush” it at the desired interval to the backend of your choice.
import statsd statsd_client = statsd.StatsClient('localhost', 8125) def login(username, password): statsd_client.incr('login.invocations')</span> if password_valid(username, password): render_welcome_page() else: render_error(403)
The Role of the StatsD Server
The server aggregates the metrics it receives from clients and forwards the results regularly to a backend for storage and visualisation. How often that happens is defined by the flush interval, which is set to 10 seconds by default.
The Role of the backend Server
The monitoring backend will turn your metrics from a stream of numbers on the wire into usable charts and alert you when needed. like DataDog , Graphite, Grafana.