influxdata / influxdata/influxdb
Query specific time window over several days
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
### Feature Request
__Proposal:__ Allow where clause to filter on time window (without date)
__Current behavior:__ Absolute and relative timestamps can be selected as a whole (date + time)
__Desired behavior:__ Query specific time window over several days
__Use case:__ Calculating sum or average of metric in specific hours over several days, for example average cpu usage in working hours (9 to 17) throughout a week. Or sum of web server requests in morning hours (9 to 12) in a month.
This can be currently achieved using external scripts for filtering, to generate absolute time window for desired period, execute query and aggregate the results. But it would be usefull if it could be done internally.
Example usage:
`SELECT "filed" FROM "measure" WHERE $timeFilter AND hour(time) >= 9 AND hour(time) <= 17 GROUP BY time(1h)`
Similar functionality (although through lambda functions) is implemented in Kapacitor: https://docs.influxdata.com/kapacitor/v1.2/tick/expr/#time-functions
Contributor guide
Research direction
Start by locating the query-language implementation and the handling for absolute and relative timestamp filters; the issue does not name files or tests. Compare the requested hour(time) predicates with Kapacitor's time functions and existing aggregation behavior. Done means a time-of-day window can be applied across multiple dates, with coverage for the stated hourly examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100