On 1 May 2016 at 20:36, Matt Bostock <
ma...@mattbostock.com> wrote:
> "Alert if metric `db_lag` has not reported from a given node in the last 5
> minutes"
That's not really the way Prometheus works. Prometheus scrapes the
monitored target, and in a sane setup, it always scrapes all the
metrics, or none at all (if the whole scrapes fail).
The latter can be tracked via the `up` metric, which contains 1 for
successful scrapes and 0 for failed ones. See
https://prometheus.io/docs/concepts/jobs_instances/#automatically-generated-labels-and-time-series
> I saw the 'absent()' function but it's not clear to me how to alert on a
> time threshold using absent(). How can I alert on stale values in
> Prometheus?
`absent` is indeed the right function to detect if a metric is
missing. (However, as said above, it sounds like your use case is a
different one.) Alerting rules have a `FOR` clause which allows you to
define for how long an alerting condition (e.g. absence of a metric)
has to be true before firing the alert. See
https://prometheus.io/docs/alerting/rules/
> Related, does Prometheus have the concept of null values, i.e. if a metric
> does not report in a given timeframe does it register a null value, and
> could I query on that?
A metric can have any IEEE 754 float value, which includes NaN and
such. But the Prometheus collection semantics doesn't really work in
the way your question suggests. Prometheus scrapes the targets at
(ideally regular but in principle) arbitrary intervals. Any given
metric always has the value of the last scrape (modulo what we call a
staleness limit). The monitored targets in turn expose all the metrics
all the time. They don't usually disappear or come back. If a metric
doesn't change, it simply stays at the same value.
--
Björn Rabenstein, Engineer
http://soundcloud.com/brabenstein
SoundCloud Ltd. | Rheinsberger Str. 76/77, 10115 Berlin, Germany
Managing Director: Alexander Ljung | Incorporated in England & Wales
with Company No. 6343600 | Local Branch Office | AG Charlottenburg |
HRB 110657B