Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDay/month functions #1545
Comments
brian-brazil
added
the
feature-request
label
Apr 18, 2016
brian-brazil
changed the title
time functions
Day/month functions
Apr 18, 2016
This comment has been minimized.
This comment has been minimized.
|
The question is what timezone would these answers be in? |
This comment has been minimized.
This comment has been minimized.
|
As with all dates in Prometheus: UTC? |
This comment has been minimized.
This comment has been minimized.
|
Obviously, once you talk about days of the week, you are probably fishing for things like "if this happens during the weekend" and such, which often refers to the timezone the user is in... with Definitely more implications here… |
This comment has been minimized.
This comment has been minimized.
|
Ugh... would we want that functionality in the query language though? I thought that would conceptually better fit into AM. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
The alerting expressions are all on the Prometheus side. Alertmanager receives the alerts, de-dups them, and decides where to send them. If the "day of the week" use-case is to send alert here or there depending on the time, it would be more an Alertmanager thing. |
This comment has been minimized.
This comment has been minimized.
|
IMHO this could be just a function you can use in the query, that way you can use those function to make other queries/calculations as well and I think it's simple enough to implement as well (just add a fuction) where adding this to alert manager can me more work and time as there is no such concepts there - but this is only my view on that case. |
This comment has been minimized.
This comment has been minimized.
|
@spinus Perhaps explain your workflows in more detail? The Prometheus community is very use-case driven, i.e. we want to keep Prometheus components as lean as possible, and the features we do have should encourage best practices and not be prone to be used in an anti-pattern. A number of good use-cases is usually the best start to add a feature. |
This comment has been minimized.
This comment has been minimized.
barkerd427
commented
Apr 21, 2016
|
I'll share mine. We're a financial company, so we only have most batch jobs
|
This comment has been minimized.
This comment has been minimized.
|
@beorn7 sure thing. I want to monitor some batch jobs.
I need to be notified on all failures and as well when the task won't start at all. This has some downsides as if the job fails on Tuesday and somebody will rerun it on Wednesday, first alert condition is not true anymore. Any other ideas how this can be configured? (for now I'm asking people to implement service level checks to return which means alert logic is shifted into a check/script but would be nice to be able to do that in prometheus) |
fabxc
added
kind/enhancement
and removed
feature request
labels
Apr 28, 2016
This comment has been minimized.
This comment has been minimized.
SypleMatt
commented
Jun 27, 2016
|
In my opinion - at least in the scenarios I have encountered directly - these time based situations are almost always specific to the TZ that the server targets. At least in the case of batch/background jobs. In the example from @barkerd427 the timezone is defined by the business (the timezone used by the stock exchange). So I think it usually makes sense to calculate these TZ sensitive values based on the local timezone of the server. Maybe two versions of each method, one based on local time of the server being monitored and another based on UTC, would provide a lot of flexibility. Not sure what implications that'd have internally though if the time series is aggregated across multiple servers in multiple timezones. |
This comment has been minimized.
This comment has been minimized.
|
I would expect that the local timezone of the server would tend to be UTC in many cases, which is not the timezone in which the server is located. If we were to offer timezone functions we'd need to open it up to all timezones which I think is a bit much complexity. |
This comment has been minimized.
This comment has been minimized.
barkerd427
commented
Jun 28, 2016
|
I would think UTC would be acceptable. Timezones can get very complicated.
|
This comment has been minimized.
This comment has been minimized.
|
Implementing the function(s) just for UTC is fairly straight forward, and it will help many people already. For their local timezone, they could work with a fixed offset, which is just a minor annoyance in the syntax. |
This comment has been minimized.
This comment has been minimized.
|
I'm for these functions with just UTC. |
This comment has been minimized.
This comment has been minimized.
jkemp101
commented
Jul 24, 2016
•
|
In my use case I need to have different alert thresholds for the size of queues on the weekend versus during the work week. UTC would be fine, I can convert as necessary and don't really care about DST because I don't need that fine of designation for my current use case. I would also like to add a request for hour_of_day() so I can determine if its during the day or at night. |
This comment has been minimized.
This comment has been minimized.
|
For queues it's generally best to monitor how long things are taking to get through, rather than the size of the queue which changes hour to hour and month to month. |
This comment has been minimized.
This comment has been minimized.
|
I gave a talk on faking UTC calculations with recording rules. It's never going to be super accurate, but there's room for improvement, and it's workable for 'month end calculations. |
This comment has been minimized.
This comment has been minimized.
|
Thanks @tcolgate . About the leap-second issue we shortly discussed in the meetup: http://www.madore.org/~david/computers/unix-leap-seconds.html https://en.wikipedia.org/wiki/Unix_time#Leap_seconds I guess whatever |
This comment has been minimized.
This comment has been minimized.
|
Thanks, I'll try and get my head around that lot. In truth, the biggest On Fri, 19 Aug 2016 at 10:29 Björn Rabenstein notifications@github.com
|
This comment has been minimized.
This comment has been minimized.
|
golang/go#8728 - upstream doesn't support leap seconds. |
This comment has been minimized.
This comment has been minimized.
|
That's about parsing. It doesn't answer the question if the numbers of seconds elapsed since 01-01-1970 returned by |
This comment has been minimized.
This comment has been minimized.
|
It you look at the linked bugs you'll see that it doesn't include leap seconds. |
This comment has been minimized.
This comment has been minimized.
|
Could you point out where that is written? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
That one is more stating the opposite: "Barring that, it seems to me that we should document that when we say UTC we actually mean TAI, and document that time.Now automatically adds the appropriate number of leap seconds." |
This comment has been minimized.
This comment has been minimized.
|
I've managed to make the start of year calculation accurate up to 2099, which will do for me. I think, I can probably get it accurate beyond that too, using a similar approach. |
fabxc
closed this
in
#1908
Aug 30, 2016
This comment has been minimized.
This comment has been minimized.
|
Thank you! |
This comment has been minimized.
This comment has been minimized.
lock
bot
commented
Mar 24, 2019
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
spinus commentedApr 11, 2016
I have few workflows when I need to check metrics over specific days.
It would be nice to have few functions which return a day of the week, day of the year, month etc.
examples: