Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I find the timestamp of the last value change

Tags:

prometheus

Given a time series, is it possible to find the timestamp of the last value change?

For example, a cron job runs every night. It first runs an rsync job, and later computes the size of the target directory. The actual metric value is not all that significant, but I would like to verify that it actually changes every night.

Is it possible to create a query that return a scalar value with the timestamp of the last value change?

like image 765
Eirik Lygre Avatar asked Feb 02 '17 23:02

Eirik Lygre


People also ask

How do I get the latest timestamp record in SQL?

To get the last updated record in SQL Server: We can write trigger (which automatically fires) i.e. whenever there is a change (update) that occurs on a row, the “lastupdatedby” column value should get updated by the current timestamp.

How do I do a timestamp in SQL?

The basic syntax of “timestamp” data type in SQL is as follows : Timestamp 'date_expression time_expression'; A valid timestamp data expression consists of a date and a time, followed by an optional BC or AD.


1 Answers

The standard way to handle this is to push a metric whose value is the unix timestamp that the batch jobs succeeded at. You can then alert on that value being recent enough.

https://www.robustperception.io/monitoring-batch-jobs-in-python/ has a Python example.

like image 112
brian-brazil Avatar answered Sep 21 '22 16:09

brian-brazil