Logs and metrics

Metrics

Set or change a number from your code, such as signups, orders or queue length, and watch it on a chart per minute, hour or day.

A metric is a named number, such as users, orders or queue_length. Your code sets it or changes it, and Logdash keeps its history and draws it on a chart. There is nothing to create first: a metric appears with its first value.

Send metrics

import { Logdash } from '@logdash/node';

const logdash = new Logdash(process.env.LOGDASH_API_KEY);

// to set absolute value
logdash.setMetric('users', 0);

// to modify existing metric
logdash.mutateMetric('users', 1);

Set or change

OperationWhat it doesUse it for
setReplaces the value.Numbers you can read, such as queue length, memory use or active users.
changeAdds to the value. Send a negative number to subtract.Things you count as they happen, such as signups or failed payments.

The SDKs name these operations differently, such as setMetric and mutateMetric in Node.js, or metrics.set and metrics.mutate in Python. Over HTTP, send them in operation.

Apps

Metrics belong to an app. Two apps can each have a metric called users, and they stay apart. Name the app with the app option of the SDK or the app field over HTTP. See Apps.

Read a metric

Open your domain and go to Metrics. Click a metric to see its chart, with its current value under Now. New values show up as they arrive.

  • Pick the range of the chart: 1h, 24h or 7d on every plan, and 12h or 30d on paid plans.
  • Short ranges show a point per minute, 24h a point per hour and 7d and 30d a point per day. Your plan sets how long each of them is kept, so a range can show less than its full length.
  • Focus the chart and use the arrow keys to read each point.
  • Delete metric deletes the metric and its history, and frees its place for a new metric.

Limits

  • Names can be up to 255 characters, and values have to be numbers.
  • Each app can have a fixed number of metrics. A value for a new metric past that answers 409 with "You have reached the maximum number of metrics for this service", and values of existing metrics keep working.
LimitHobbyBuilderPro
Metrics per app51030
Per-minute points kept1 hour6 hours1 day
Hourly points kept1 day3 days7 days
Daily points kept-7 days30 days

For the full request and the read API, see HTTP API.