-
Notifications
You must be signed in to change notification settings - Fork 25.2k
TSDB: add a time_series_aggregation to support TSDB query and promQL #85798
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
Comments
Pinging @elastic/es-analytics-geo (Team:Analytics) |
hi, @nik9000 , can you help to review the issue, I implemented it in #86097. |
hi, @nik9000 , do you have any suggestions for this TSDB aggregation? |
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
Background
In the issue #66247, it represent the TSDB query plan.
The TSDB query alway like this:
The query can be explain as this:
But the query is very slow and cost so many memory. To speed up TSDB query, I create a new low-level aggregation, it don't used by user. It used by the new QL storage API.
Low-level time_series_aggregation
The aggregation like this:
time_series_aggregation contain below parameters:
The result like this:
Execute Flow
In the collect phase:
In the post collection phase:
In the buildAggregations phase:
In the reduce phase:
Special case
There is a special case where multiple indices may have the same tsid even though the tsid is routed in one index. So if the date_histogram covers multiple indices, we can't do the aggregator function in the datanode.
We can check if the date_histogram bucket will covers multiple indices by the settings index.time_series.start_time and index.time_series.end_time.
First we calculate the timestamp value to a rounding interval value.
Then we compare the rounding value with start_time and end_time.
If the rounding value is between the start_time and end_time, we can confirm that the date_histogram bucket is absolute in one index. So we can do aggregator function in the datanode.
But if the rounding is smaller than start_time or bigger than (end_time - interval). The date_histogram bucket may be have multiple indices. So we keep the original tsid downsampling results.And calculate the aggregator results in the reduce phase of the coordinate node.
How to Speed up
Compare time_series_aggregation and the first long query DSL, the reason why time_series_aggregation can speed up is:
Explain
This low-level aggregation is the MVP of TSDB queries. We can change the aggregation implementation with a new TSDB execution framework. Possibly the Distributed nested delayed execution framework have the same functionality as the time series aggregation.
With the help of time series aggregation, we can implement the promQL support.
The text was updated successfully, but these errors were encountered: