AlgoViz

Datadog

medium 27 min

Datadog is a hosted monitoring platform.

See it run

The way of a measurement, the flush, the buffer, merged percentiles, sampled traces and counted tags.

Operations

From code to chart

A request is measured, and a person is called.

Step 1 of 5

Measure

Our systemHTTPSOur service183 msAgentDatadogOn call

The service sends one small UDP packet to the Agent on the same host, and answers the customer.

Step 1: Measure

def handle(request):    start = now()    answer = work(request)    statsd.distribution("request_ms", now() - start, TAGS)    return answerdef agent_every_10s():    https_post(site, compress(flush()))
How often
About every 10 s
What it costs
Tags and points

The connection always starts at the Agent.

In the real world

The same datadog doing real jobs. Pick one and step through it.

Many nodes, one API server.

Step 1 of 3

Ask once

Our systemKubernetes APICluster Agentone readerNode Agent 1Node Agent 2Datadog

1 client

The Cluster Agent asks for services, pods and events.

Step 1: Ask once

Common mistakes

The bugs interviewers watch for, with the fix beside each.

  • An id as a tag

    critical

    Every value is a new combination, and it is billed and slow to query.

    Wrong
    statsd.increment("orders",    tags=[f"user:{user_id}"])
    Right
    statsd.increment("orders",    tags=["tier:paid"])log.info("order", extra={"user": user_id})
  • Average of p95

    major

    Percentiles of hosts cannot be averaged.

    Wrong
    avg:request_ms.95percentile{*}
    Right
    p95:request_ms{*}# a distribution with percentiles on
  • The wrong site

    major

    Keys belong to one site. Data for another is refused and charts stay empty.

    Wrong
    # account on EU1site: datadoghq.com
    Right
    # account on EU1site: datadoghq.eu
  • No rule for missing data

    major

    When the Agents cannot send, a threshold is never crossed.

    Wrong
    missing data: show OKfor every monitor
    Right
    missing data: notifyfor the heartbeat of each host group
  • Index everything

    minor

    Health checks and debug lines fill the index and hit the daily quota.

    Wrong
    exclusion filters: none
    Right
    exclude 100% of /healthkeep 5% of 2xx, all errorsarchive everything

Interview tips

  • How to explain it

    • One Agent per host collects.
    • It pushes out over HTTPS.
    • The service stores, shows and alerts.
  • Where state lives

    • Seconds of data: the Agent.
    • Everything else: one Datadog site.
    • Raw logs: your own archive.
  • Reach for it when

    • A small team needs all signals.
    • Data may leave the network.
    • The bill is below the cost of running it.
  • Before production

    • env, service, version everywhere.
    • Budget alerts on usage.
    • One independent probe.