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

Prometheus select metric and stats queries. #956

Merged
merged 3 commits into from
Nov 3, 2022

Conversation

vamsimanohar
Copy link
Member

@vamsimanohar vamsimanohar commented Oct 23, 2022

Description

[Describe what this change achieves]

Issues Resolved

#622

(ITs and doctests are followed)

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.68%. Comparing base (c230532) to head (e0d6be4).
Report is 472 commits behind head on 2.x.

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x     #956      +/-   ##
============================================
- Coverage     98.20%   95.68%   -2.52%     
- Complexity     3244     3325      +81     
============================================
  Files           313      334      +21     
  Lines          8119     9057     +938     
  Branches        532      672     +140     
============================================
+ Hits           7973     8666     +693     
- Misses          142      334     +192     
- Partials          4       57      +53     
Flag Coverage Δ
query-workbench 62.76% <ø> (?)
sql-engine 98.26% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@vamsimanohar vamsimanohar force-pushed the prom-select-stats branch 13 times, most recently from 8f7f0fd to f39f5c4 Compare October 25, 2022 08:44
@vamsimanohar vamsimanohar changed the title Prom select stats Prometheus select metric and stats queries. Oct 25, 2022
@vamsimanohar vamsimanohar linked an issue Oct 25, 2022 that may be closed by this pull request
@vamsimanohar vamsimanohar force-pushed the prom-select-stats branch 2 times, most recently from 688f640 to 716d188 Compare October 28, 2022 21:35
@vamsimanohar vamsimanohar added enhancement New feature or request v2.4.0 'Issues and PRs related to version v2.4.0' labels Oct 28, 2022
@vamsimanohar vamsimanohar force-pushed the prom-select-stats branch 2 times, most recently from 5d13fea to 4a79875 Compare November 1, 2022 05:27
@vamsimanohar vamsimanohar force-pushed the prom-select-stats branch 2 times, most recently from 4a190d5 to 619a06b Compare November 1, 2022 10:07
@vamsimanohar vamsimanohar force-pushed the prom-select-stats branch 4 times, most recently from 141a018 to a43d827 Compare November 1, 2022 18:29
@vamsimanohar vamsimanohar force-pushed the prom-select-stats branch 8 times, most recently from e3e74a4 to e86f7f5 Compare November 2, 2022 16:44
@vamsimanohar vamsimanohar marked this pull request as ready for review November 2, 2022 16:46
@vamsimanohar vamsimanohar requested a review from a team as a code owner November 2, 2022 16:46
Signed-off-by: Vamsi Manohar <[email protected]>

@Getter
@Setter
public class PrometheusResponseFieldNames {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As I understand, this carries the metadata of Prometheus response, right? If so, because we represent dynamic Prometheus query as a Table, I think this should be removed and the logic should be moved to PrometheusMetricTable.getFieldTypes() ?

Copy link
Member Author

Choose a reason for hiding this comment

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

The above code is specifically to handle stats output field names which cannot be decided using getFieldTypes.

In the current state.
Logical project decides the field names in the response schema. It analyzes stat expressions and other expressions to come up with the field names in output response. In case of opensearch, the field name matches with the output response from the opensearch. But prometheus doesn't have any field names associated.

For eg:
source = x | stats avg(@value) by handler;
Opensearch produces output with avg(@value) as field name for average.
Prometheus we need to map the output to the corresponding key.

Also for dynamic prometheus query, there is no easy way to figure out the output structure in prior without running the query.

So prometheusMetricTable.getFieldTypes() doesn't work in case of stats and dynamic queries. [Will try to address this after 2.4]

Comment on lines +125 to +128
if (spanExpression.isEmpty()) {
throw new RuntimeException(
"Prometheus Catalog doesn't support aggregations without span expression");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

If span is required, the exception should be thrown at logical -> physical stage, instead of here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, but that would cause issues with opensearch catalog,,,since it would be allowed for them. Don't want to distinguish catalogs in Analyzer component.

Can I do somewhere else?

Introduce validation of logical plan?

@vamsimanohar vamsimanohar force-pushed the prom-select-stats branch 5 times, most recently from ea4a107 to b030c32 Compare November 3, 2022 08:26
Signed-off-by: Vamsi Manohar <[email protected]>
@vamsimanohar vamsimanohar merged commit be4512e into opensearch-project:2.x Nov 3, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Nov 3, 2022
* Prometheus select metric and stats queries.

Signed-off-by: reddyvam-amazon <[email protected]>
(cherry picked from commit be4512e)
vamsimanohar pushed a commit that referenced this pull request Nov 3, 2022
* Prometheus select metric and stats queries.

Signed-off-by: vamsi-amazon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.4 enhancement New feature or request v2.4.0 'Issues and PRs related to version v2.4.0'
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement PPL grammar for Prometheus
5 participants