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 Query Exemplars #1782

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

vmmusings
Copy link
Member

@vmmusings vmmusings commented Jun 26, 2023

Description

This PR introduces new capability of querying exemplars in prometheus connectors.

Documentation Link with sample request and response: https://github.com/vamsi-amazon/sql/blob/query_exemplars/docs/user/ppl/admin/prometheus_connector.rst#prometheus-connector-table-functions
Sample Request:

####
POST http://localhost:9200/_plugins/_ppl
content-type: application/json

{
    "query" : "source=my_prometheus.query_exemplars(query='prometheus_http_requests_total', starttime=1686694425, endtime=1686700130)"  
}

Sample Response

{
  "schema": [
    {
      "name": "seriesLabels",
      "type": "struct"
    },
    {
      "name": "exemplars",
      "type": "array"
    }
  ],
  "datarows": [
    [
      {
        "telemetry_sdk_language": "java",
        "instance": "otelcol:9464",
        "telemetry_sdk_version": "1.24.0",
        "service_name": "adservice",
        "os_description": "Linux 5.15.49-linuxkit-pr",
        "process_command_line": "/opt/java/openjdk/bin/java -javaagent:/usr/src/app/opentelemetry-javaagent.jar",
        "service_namespace": "opentelemetry-demo",
        "process_pid": "1",
        "app_ads_ad_request_type": "NOT_TARGETED",
        "process_runtime_version": "17.0.6+10",
        "telemetry_auto_version": "1.24.0",
        "process_runtime_description": "Eclipse Adoptium OpenJDK 64-Bit Server VM 17.0.6+10",
        "telemetry_sdk_name": "opentelemetry",
        "app_ads_ad_response_type": "RANDOM",
        "__name__": "app_ads_ad_requests_total",
        "os_type": "linux",
        "process_executable_path": "/opt/java/openjdk/bin/java",
        "process_runtime_name": "OpenJDK Runtime Environment",
        "host_arch": "aarch64",
        "job": "opentelemetry-demo/adservice",
        "container_id": "95cd785d0ce6c3867bf134b5f6d09b2a93f639c397a5f3dafaa6a10821345416",
        "host_name": "95cd785d0ce6"
      },
      [
        {
          "labels": {
            "trace_id": "ff1c56eeeb2cb52b8ef41f35238f3e8c",
            "span_id": "a6f169d1b34ae518"
          },
          "timestamp": "2023-07-13 06:14:34.929",
          "value": 1.0
        },
        {
          "labels": {
            "trace_id": "6dbff827314088960dec20a2a4426131",
            "span_id": "d1f86d293d5a0dd0"
          },
          "timestamp": "2023-07-13 06:15:04.977",
          "value": 1.0
        },
        {
          "labels": {
            "trace_id": "701f7039860aedc2658feb27090169d5",
            "span_id": "9281016f3f6abeb6"
          },
          "timestamp": "2023-07-13 06:16:14.241",
          "value": 1.0
        } ]
    ]
}

Issues Resolved

#1750
BWC failures are unrelated. WIll get fixed with the below PRs
#1876
#1868

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
Copy link

codecov bot commented Jun 26, 2023

Codecov Report

Merging #1782 (d73c3cc) into main (1a7134b) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##               main    #1782      +/-   ##
============================================
+ Coverage     97.39%   97.42%   +0.02%     
- Complexity     4603     4647      +44     
============================================
  Files           401      408       +7     
  Lines         11397    11526     +129     
  Branches        835      839       +4     
============================================
+ Hits          11100    11229     +129     
  Misses          290      290              
  Partials          7        7              
Flag Coverage Δ
sql-engine 97.42% <100.00%> (+0.02%) ⬆️

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

Files Changed Coverage Δ
...theus/data/constants/PrometheusFieldConstants.java 0.00% <ø> (ø)
...ch/sql/prometheus/client/PrometheusClientImpl.java 100.00% <100.00%> (ø)
...mentation/QueryExemplarFunctionImplementation.java 100.00% <100.00%> (ø)
.../resolver/QueryExemplarsTableFunctionResolver.java 100.00% <100.00%> (ø)
...ions/resolver/QueryRangeTableFunctionResolver.java 100.00% <100.00%> (ø)
...response/QueryExemplarsFunctionResponseHandle.java 100.00% <100.00%> (ø)
...ons/response/QueryRangeFunctionResponseHandle.java 100.00% <100.00%> (ø)
...s/scan/QueryExemplarsFunctionTableScanBuilder.java 100.00% <100.00%> (ø)
.../scan/QueryExemplarsFunctionTableScanOperator.java 100.00% <100.00%> (ø)
...ions/scan/QueryRangeFunctionTableScanOperator.java 100.00% <100.00%> (ø)
... and 4 more

@vmmusings vmmusings force-pushed the query_exemplars branch 14 times, most recently from e72bd26 to f4fde6d Compare June 27, 2023 00:20
@vmmusings vmmusings self-assigned this Jun 27, 2023
@vmmusings vmmusings added enhancement New feature or request v2.9.0 v2.9.0 backport 2.x labels Jun 27, 2023
@vmmusings vmmusings marked this pull request as ready for review June 27, 2023 00:49
pjfitzgibbons
pjfitzgibbons previously approved these changes Jul 17, 2023
@vmmusings
Copy link
Member Author

vmmusings commented Jul 18, 2023

BWC failures are unrelated. WIll get fixed with the below PRs
#1876
#1868

penghuo
penghuo previously approved these changes Jul 24, 2023
@vmmusings vmmusings force-pushed the query_exemplars branch 5 times, most recently from 7d297a1 to 213a3c7 Compare July 26, 2023 20:25
Signed-off-by: Vamsi Manohar <[email protected]>
@vmmusings vmmusings merged commit 430d7a9 into opensearch-project:main Jul 27, 2023
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-1782-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 430d7a9e60a7cace25784d569ff48f30ec47b150
# Push it to GitHub
git push --set-upstream origin backport/backport-1782-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-1782-to-2.x.

vmmusings added a commit that referenced this pull request Jul 27, 2023
Signed-off-by: Vamsi Manohar <[email protected]>
(cherry picked from commit 430d7a9)
vmmusings added a commit that referenced this pull request Jul 27, 2023
Signed-off-by: Vamsi Manohar <[email protected]>
(cherry picked from commit 430d7a9)
vmmusings added a commit that referenced this pull request Jul 27, 2023
Signed-off-by: Vamsi Manohar <[email protected]>
(cherry picked from commit 430d7a9)
MitchellGale added a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jul 27, 2023
MitchellGale pushed a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jul 27, 2023
… (opensearch-project#1897)

Signed-off-by: Yury-Fridlyand <[email protected]>

Added support of timestamp/date/time using curly brackets (opensearch-project#1894)

* Added support of timestamp/date/time using curly brackets (#297)

* added bracketed time/date/timestamp input, tests, and documentation

Signed-off-by: Matthew Wells <[email protected]>

* improved failing tests

Signed-off-by: Matthew Wells <[email protected]>

* simplified tests for checking for failure

Signed-off-by: Matthew Wells <[email protected]>

* fixed redundant tests and improved tests that should fail

Signed-off-by: Matthew Wells <[email protected]>

---------

Signed-off-by: Matthew Wells <[email protected]>

Bump bwc version (opensearch-project#1876)

Signed-off-by: Vamsi Manohar <[email protected]>

Prometheus Query Exemplars (opensearch-project#1782)

Signed-off-by: Vamsi Manohar <[email protected]>

Adding google code changes for core/src/main/java/org/opensearch/sql/analysis  core/src/main/java/org/opensearch/sql/ast  core/src/main/java/org/opensearch/sql/data
 core/src/main/java/org/opensearch/sql/datasource

Signed-off-by: Mitchell Gale <[email protected]>

Disable checkstyle fore core module and enable spotless check for the files being checked.

Signed-off-by: Mitchell Gale <[email protected]>

Added back core checkstyle test in sql-test-workflow.yml

Signed-off-by: Mitchell Gale <[email protected]>

Revert "Prometheus Query Exemplars (opensearch-project#1782)"

This reverts commit 430d7a9.

Revert "Bump bwc version (opensearch-project#1876)"

This reverts commit 501392e.

Revert "Added support of timestamp/date/time using curly brackets (opensearch-project#1894)"

This reverts commit 1a7134b.

Revert "Statically init `typeActionMap` in `OpenSearchExprValueFactory`. (#310) (opensearch-project#1897)"

This reverts commit c8d42a7.

Revert "Fix create_index/create_index_with_IOException issue caused by OpenSearch PR change (opensearch-project#1899)"

This reverts commit 7b932a7.
MitchellGale pushed a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jul 27, 2023
Signed-off-by: Vamsi Manohar <[email protected]>
Signed-off-by: Mitchell Gale <[email protected]>
MitchellGale pushed a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jul 28, 2023
… (opensearch-project#1897)

Signed-off-by: Yury-Fridlyand <[email protected]>

Added support of timestamp/date/time using curly brackets (opensearch-project#1894)

* Added support of timestamp/date/time using curly brackets (#297)

* added bracketed time/date/timestamp input, tests, and documentation

Signed-off-by: Matthew Wells <[email protected]>

* improved failing tests

Signed-off-by: Matthew Wells <[email protected]>

* simplified tests for checking for failure

Signed-off-by: Matthew Wells <[email protected]>

* fixed redundant tests and improved tests that should fail

Signed-off-by: Matthew Wells <[email protected]>

---------

Signed-off-by: Matthew Wells <[email protected]>

Bump bwc version (opensearch-project#1876)

Signed-off-by: Vamsi Manohar <[email protected]>

Prometheus Query Exemplars (opensearch-project#1782)

Signed-off-by: Vamsi Manohar <[email protected]>

Adding google code changes for core/src/main/java/org/opensearch/sql/analysis  core/src/main/java/org/opensearch/sql/ast  core/src/main/java/org/opensearch/sql/data
 core/src/main/java/org/opensearch/sql/datasource

Signed-off-by: Mitchell Gale <[email protected]>

Disable checkstyle fore core module and enable spotless check for the files being checked.

Signed-off-by: Mitchell Gale <[email protected]>

Added back core checkstyle test in sql-test-workflow.yml

Signed-off-by: Mitchell Gale <[email protected]>

Revert "Prometheus Query Exemplars (opensearch-project#1782)"

This reverts commit 430d7a9.

Revert "Bump bwc version (opensearch-project#1876)"

This reverts commit 501392e.

Revert "Added support of timestamp/date/time using curly brackets (opensearch-project#1894)"

This reverts commit 1a7134b.

Revert "Statically init `typeActionMap` in `OpenSearchExprValueFactory`. (#310) (opensearch-project#1897)"

This reverts commit c8d42a7.

Revert "Fix create_index/create_index_with_IOException issue caused by OpenSearch PR change (opensearch-project#1899)"

This reverts commit 7b932a7.

Signed-off-by: Mitchell Gale <[email protected]>
MitchellGale pushed a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jul 28, 2023
Signed-off-by: Vamsi Manohar <[email protected]>
Signed-off-by: Mitchell Gale <[email protected]>
MitchellGale pushed a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jul 28, 2023
Signed-off-by: Vamsi Manohar <[email protected]>
Signed-off-by: Mitchell Gale <[email protected]>
MitchellGale pushed a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jul 28, 2023
Signed-off-by: Vamsi Manohar <[email protected]>
Signed-off-by: Mitchell Gale <[email protected]>
MitchellGale pushed a commit to Bit-Quill/opensearch-project-sql that referenced this pull request Jul 31, 2023
… (opensearch-project#1897)

Signed-off-by: Yury-Fridlyand <[email protected]>

Added support of timestamp/date/time using curly brackets (opensearch-project#1894)

* Added support of timestamp/date/time using curly brackets (#297)

* added bracketed time/date/timestamp input, tests, and documentation

Signed-off-by: Matthew Wells <[email protected]>

* improved failing tests

Signed-off-by: Matthew Wells <[email protected]>

* simplified tests for checking for failure

Signed-off-by: Matthew Wells <[email protected]>

* fixed redundant tests and improved tests that should fail

Signed-off-by: Matthew Wells <[email protected]>

---------

Signed-off-by: Matthew Wells <[email protected]>

Bump bwc version (opensearch-project#1876)

Signed-off-by: Vamsi Manohar <[email protected]>

Prometheus Query Exemplars (opensearch-project#1782)

Signed-off-by: Vamsi Manohar <[email protected]>

Adding google code changes for core/src/main/java/org/opensearch/sql/analysis  core/src/main/java/org/opensearch/sql/ast  core/src/main/java/org/opensearch/sql/data
 core/src/main/java/org/opensearch/sql/datasource

Signed-off-by: Mitchell Gale <[email protected]>

Disable checkstyle fore core module and enable spotless check for the files being checked.

Signed-off-by: Mitchell Gale <[email protected]>

Added back core checkstyle test in sql-test-workflow.yml

Signed-off-by: Mitchell Gale <[email protected]>

Revert "Prometheus Query Exemplars (opensearch-project#1782)"

This reverts commit 430d7a9.

Revert "Bump bwc version (opensearch-project#1876)"

This reverts commit 501392e.

Revert "Added support of timestamp/date/time using curly brackets (opensearch-project#1894)"

This reverts commit 1a7134b.

Revert "Statically init `typeActionMap` in `OpenSearchExprValueFactory`. (#310) (opensearch-project#1897)"

This reverts commit c8d42a7.

Revert "Fix create_index/create_index_with_IOException issue caused by OpenSearch PR change (opensearch-project#1899)"

This reverts commit 7b932a7.

Signed-off-by: Mitchell Gale <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants