" traffic quota exceeded in current month"
That's different to what you asked for first time ("for last 30 days"). PromQL by itself isn't very good for things like "current calendar month".
You could write an external program which talks to the
API: it can calculate the timestamp that it wants the query to be evaluated at, and specify that in the API call (or using the
@ modifier)
Your program could:
- find the current value of the traffic volume counter
- find the traffic volume counter's value at the 1st of the month
- subtract them
- compare to the expected value at this point in the month: (day of month / days in month * monthly quota)
But TBH, I think it would be both easier and more useful to alert on the most recent 24 hour's usage, i.e. the rate of consumption. If you are burning more than 1/30th of the monthly quota every day then you need to find out why, and keep a careful eye on it.
increase(foo[24h]) > (1000000000000 / 30)