-
Notifications
You must be signed in to change notification settings - Fork 12.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySQL/Postgres/MSSQL: Add parsing for day, weeks and year intervals in macros #13086
MySQL/Postgres/MSSQL: Add parsing for day, weeks and year intervals in macros #13086
Conversation
|
@bergquist might be relevant for prometheus, graphite & influxdb as well? maybe even the alert scheduler as well (so we can support 1d in more places) |
As Carl wrote in #11431 (comment), there's a reason go doesn't support this. As long as it's very clear that this support is simple and don't adjust for daylight savings I guess it's a useful feature. |
Sure, but Grafana already does support it in a bunch of other places. All this is doing is bringing a few macro functions in line with the rest of the system in terms of that support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we define day as 24 hours we could easily support at least week here aswell and maybe even month as e.g. 31 days
I'm happy to add other periods - week, month etc, if you like but initially I was just aiming for parity with the existing interval types that were used by |
I agree that we need to add support for I'm not sure how it would be implemented but I think it should be placed in another package and return a |
I've been thinking about this and I think we should use the https://github.com/karrick/tparse library. Any chance you can update this PR to use |
c036652
to
1ad21de
Compare
So I've done this, but I can't for the life of me figure out how to get the dependency auto pulled into the vendor subdirectory. This is my first time playing with either go or Grafana so if someone can point me in the right direction, I'd appreciate it. The code itself is a little bit of a hack because |
@svenklemm what do you think about this? In this solution month's depends on the length of the current month. This is far from optimal since the result when aggregating on month's period over year's will get skewed. |
I think month should either calculate months properly by basing the calculation on selected timerange or be a fixed interval like 28days (for symmetry with 4 weeks) or 30 or 31 days |
What's needed/left to do for getting this into a merge:able state? |
I have no idea - happy to make any required changes if someone tells me what they are. |
I would also like to see this PR merged and will help to apply the required changes. Maybe, we can ask to review this PR once more? |
Is there any news about this PR? |
I do understand the frustration in this PR's and I've been glancing back to it from time to times but I can't get over the fact that parsing months with this solution will be problematic since it will be based on the current month. Which I dont think is a good solution. If we restricted this PR to only support I'm not sure what to do here... |
The only reason it supports anything other than days is that you explicitly asked me to alter it to use the |
I know. That's my mistake I didn't consider months when I wrote that. I'm sorry about that. If you want to do that I'm happy to make this my highest prio to review it. If not I'll fix this myself once I have spare time. And once again sorry. |
54ca81a
to
5a859b5
Compare
No worries.
I've coded this up, but looking back at the original ticket the initial change was to include days and years, since years are also apparently potentially an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for your patience! :)
LGTM
…-grafanaui * grafana/master: Annotations: Improve annotation option tooltips (grafana#17384) InfluxDB: Fixes single quotes are not escaped (grafana#17398) Chore: Bump axios to 0.19.0 (grafana#17403) Alerting: golint fixes for alerting (grafana#17246) Batch disable users (grafana#17254) Chore: Remove unused properties in explore (grafana#17359) MySQL/Postgres/MSSQL: Add parsing for day, weeks and year intervals in macros (grafana#13086) Security: Prevent csv formula injection attack (grafana#17363)
* grafana/master: (73 commits) docs: configuring custom headers in the dataproxy (grafana#17367) Explore: Queries the datasource once per run query and uses DataStreamObserver (grafana#17263) Feature: Adds redux action logging toggle from url params (grafana#17368) Build: Adds e2e tests back to master workflow with better error messages and with artifacts (grafana#17374) Explore: Handle datasources with long names better in ds picker (grafana#17393) Annotations: Improve annotation option tooltips (grafana#17384) InfluxDB: Fixes single quotes are not escaped (grafana#17398) Chore: Bump axios to 0.19.0 (grafana#17403) Alerting: golint fixes for alerting (grafana#17246) Batch disable users (grafana#17254) Chore: Remove unused properties in explore (grafana#17359) MySQL/Postgres/MSSQL: Add parsing for day, weeks and year intervals in macros (grafana#13086) Security: Prevent csv formula injection attack (grafana#17363) LDAP: remove unused function (grafana#17351) Enterprise: remove gofakeit dep (grafana#17344) Explore: Update time range before running queries (grafana#17349) Build(package.json): improve npm commands (grafana#17022) Chore: upgrade webpack analyser (grafana#17340) NewDataSourcePage: Add Grafana Cloud link (grafana#17324) CloudWatch: Avoid exception while accessing results (grafana#17283) ...
* grafana/master: (49 commits) Build: specify build flag for `docker-compose up` (grafana#17411) Add a @grafana/runtime package with backendSrv interface (grafana#16533) Database: Initialize xorm with an empty schema for postgres (grafana#17357) docs: configuring custom headers in the dataproxy (grafana#17367) Explore: Queries the datasource once per run query and uses DataStreamObserver (grafana#17263) Feature: Adds redux action logging toggle from url params (grafana#17368) Build: Adds e2e tests back to master workflow with better error messages and with artifacts (grafana#17374) Explore: Handle datasources with long names better in ds picker (grafana#17393) Annotations: Improve annotation option tooltips (grafana#17384) InfluxDB: Fixes single quotes are not escaped (grafana#17398) Chore: Bump axios to 0.19.0 (grafana#17403) Alerting: golint fixes for alerting (grafana#17246) Batch disable users (grafana#17254) Chore: Remove unused properties in explore (grafana#17359) MySQL/Postgres/MSSQL: Add parsing for day, weeks and year intervals in macros (grafana#13086) Security: Prevent csv formula injection attack (grafana#17363) LDAP: remove unused function (grafana#17351) Enterprise: remove gofakeit dep (grafana#17344) Explore: Update time range before running queries (grafana#17349) Build(package.json): improve npm commands (grafana#17022) ...
* grafana/master: (108 commits) Build: specify build flag for `docker-compose up` (grafana#17411) Add a @grafana/runtime package with backendSrv interface (grafana#16533) Database: Initialize xorm with an empty schema for postgres (grafana#17357) docs: configuring custom headers in the dataproxy (grafana#17367) Explore: Queries the datasource once per run query and uses DataStreamObserver (grafana#17263) Feature: Adds redux action logging toggle from url params (grafana#17368) Build: Adds e2e tests back to master workflow with better error messages and with artifacts (grafana#17374) Explore: Handle datasources with long names better in ds picker (grafana#17393) Annotations: Improve annotation option tooltips (grafana#17384) InfluxDB: Fixes single quotes are not escaped (grafana#17398) Chore: Bump axios to 0.19.0 (grafana#17403) Alerting: golint fixes for alerting (grafana#17246) Batch disable users (grafana#17254) Chore: Remove unused properties in explore (grafana#17359) MySQL/Postgres/MSSQL: Add parsing for day, weeks and year intervals in macros (grafana#13086) Security: Prevent csv formula injection attack (grafana#17363) LDAP: remove unused function (grafana#17351) Enterprise: remove gofakeit dep (grafana#17344) Explore: Update time range before running queries (grafana#17349) Build(package.json): improve npm commands (grafana#17022) ...
* grafana/master: (142 commits) Build: specify build flag for `docker-compose up` (grafana#17411) Add a @grafana/runtime package with backendSrv interface (grafana#16533) Database: Initialize xorm with an empty schema for postgres (grafana#17357) docs: configuring custom headers in the dataproxy (grafana#17367) Explore: Queries the datasource once per run query and uses DataStreamObserver (grafana#17263) Feature: Adds redux action logging toggle from url params (grafana#17368) Build: Adds e2e tests back to master workflow with better error messages and with artifacts (grafana#17374) Explore: Handle datasources with long names better in ds picker (grafana#17393) Annotations: Improve annotation option tooltips (grafana#17384) InfluxDB: Fixes single quotes are not escaped (grafana#17398) Chore: Bump axios to 0.19.0 (grafana#17403) Alerting: golint fixes for alerting (grafana#17246) Batch disable users (grafana#17254) Chore: Remove unused properties in explore (grafana#17359) MySQL/Postgres/MSSQL: Add parsing for day, weeks and year intervals in macros (grafana#13086) Security: Prevent csv formula injection attack (grafana#17363) LDAP: remove unused function (grafana#17351) Enterprise: remove gofakeit dep (grafana#17344) Explore: Update time range before running queries (grafana#17349) Build(package.json): improve npm commands (grafana#17022) ...
This should resolve #11431 by converting day and year intervals into hours before they're passed to
time.ParseDuration
. Any other intervals, including invalid ones, are passed through unchanged so that the error result remains the same.