I have a postgresql database that stored 3 column. Time, value, feed_id. Feed_id column will serve as label. My goal is to alert feed_id that has data within last 30 days but no data within last 24 hours. How can I achieve this?
Qyery A: Now-30d
SELECT
time AS time,
value,
CASE
WHEN fid = 1040978 THEN '104'
WHEN fid = 1040910 THEN '158'
WHEN fid = 1040909 THEN '160'
WHEN fid = 1040903 THEN '161'
WHEN fid = 1040904 THEN '151'
WHEN fid = 1041102 THEN '113'
WHEN fid = 1124443 THEN '162'
WHEN fid = 1125512 THEN '163'
WHEN fid = 1125507 THEN '159'
WHEN fid = 1124470 THEN '183'
END AS dataset
FROM
feed_obs
WHERE
$__timeFilter(time)
AND fid IN (
1040978,
1040910,
1040909,
1040903,
1040904,
1041102,
1124443,
1125512,
1125507,
1124470
)
ORDER BY
1
Qyery B: Now-1d
Same query as above
Expression:
In this case, I want all labels shown alert is firing except dataset=158, 160 and 161
I use count. Maybe combine last with bool expression work? This might not be an elegant way to achieve. Can anyone give some help? Thanks a lot!