Skip to content
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

Add support for selectors in TimeSeriesMetricsService #79691

Merged
merged 11 commits into from
Nov 11, 2021

Conversation

imotov
Copy link
Contributor

@imotov imotov commented Oct 24, 2021

Adds basic support for selectors in TimeSeriesMetricsService

Relates to #74660

@imotov
Copy link
Contributor Author

imotov commented Oct 24, 2021

@costin, @nik9000 I think it is functional and does what's needed, but it needs way more tests to be sure.

@costin
Copy link
Member

costin commented Oct 26, 2021

👍 LGTM

if (capabilities.isDimension()) {
dimensions.add(fieldName);
if (capabilities.getMetricType() != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A field can't be a metric and a dimension at the same time, right?

@imotov imotov removed the WIP label Nov 3, 2021
@imotov imotov marked this pull request as ready for review November 3, 2021 03:40
@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Nov 3, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a small request, mostly the javadoc stuff. I think it does what we need. And it's as scary to run as we'd worried it would be.


@TestLogging(value = "org.elasticsearch.search.tsdb:debug", reason = "test")
@TestLogging(value = "org.elasticsearch.timeseries.support:debug", reason = "test")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍. Not sure if we actually need to keep it though. But it helped me at first, that's for sure.

RE_EQUAL {
@Override
protected Predicate<String> matcher(String expression) {
return Pattern.compile(expression, 0).asMatchPredicate();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/, 0//?

* @param metrics metrics selectors
* @param dimensions dimension selectors
* @param time time
* @param callback callback
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you nuke the empty @param annotations?

/**
* Get the latest value for all time series in many ranges.
* Return the latest metrics before time within staleness period
* @param metrics metrics selectors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you mention that these are ORed together.

}
DocumentField metricField = hit.field(metric);
if (metricField == null) {
// TODO skip in query?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to stay forever I think. You are filtering out documents that don't have any of the fields, but we still have to skip those that have only one.

FilterAggregationBuilder[] filters = new FilterAggregationBuilder[(int) (last - first)];
for (int i = 0; i < filters.length; i++) {
metricAgg.subAggregation(
new FilterAggregationBuilder(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filters is pretty much built for this.

}
return metricAgg;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole thing is going to be really fun to run. I get it, I think, but wow. I guess this is what we need.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might be able to improve things by having top_metrics have a better behavior when the field is missing. But that might be a thing for another time.

@nik9000
Copy link
Member

nik9000 commented Nov 10, 2021

WIP

Probably wants a PR description.

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's get it in and build on it some more.

@imotov imotov merged commit 838dc0d into elastic:master Nov 11, 2021
@imotov imotov deleted the add-tsdb-selectors-to-metrics-interface branch December 10, 2021 02:30
@wchaparro wchaparro assigned imotov and unassigned imotov Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :StorageEngine/TSDB You know, for Metrics Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.0.0-rc1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants