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

Include stats api to provide upload metrics #64

Merged
merged 10 commits into from
May 25, 2022

Conversation

VijayanB
Copy link
Member

@VijayanB VijayanB commented May 12, 2022

Description

Added stats api "_plugins/geospatial/_upload/stats", to retrieve statistics for uploads
in cluster. By default all stats are returned, user can filter the response using
filter query parameter similar to other cluster response.

Scenario 1: No upload is processed

curl -X GET "localhost:9200/_plugins/geospatial/_upload/stats?pretty"
{
  "total" : {
    "request_count" : 0,
    "upload" : 0,
    "success" : 0,
    "failed" : 0,
    "duration" : 0
  },
  "metrics" : [ ]
}

Scenario 2: After 1 successful upload is processed

 curl -X GET "localhost:9200/_plugins/geospatial/_upload/stats?pretty"
{
  "total" : {
    "request_count" : 1,
    "upload" : 5,
    "success" : 5,
    "failed" : 0,
    "duration" : 881
  },
  "metrics" : [
    {
      "node_id" : "VCkDk5YdQKWuwnfrTkNTNQ",
      "id" : "tIOSz4t4Rz2pt6rO4UybXg",
      "type" : "geojson",
      "upload" : 5,
      "success" : 5,
      "failed" : 0,
      "duration" : 881
    }
  ]
}

Scenario 3: After 1 partial upload is processed

 curl -X GET "localhost:9200/_plugins/geospatial/_upload/stats?pretty"
{
  "total" : {
    "request_count" : 2,
    "upload" : 62,
    "success" : 60,
    "failed" : 2,
    "duration" : 1814
  },
  "metrics" : [
    {
      "node_id" : "VCkDk5YdQKWuwnfrTkNTNQ",
      "id" : "tIOSz4t4Rz2pt6rO4UybXg",
      "type" : "geojson",
      "upload" : 5,
      "success" : 5,
      "failed" : 0,
      "duration" : 881
    },
    {
      "node_id" : "VCkDk5YdQKWuwnfrTkNTNQ",
      "id" : "fHHlz4iWQ4uJgoN5dZeEwA",
      "type" : "geojson",
      "upload" : 57,
      "success" : 55,
      "failed" : 2,
      "duration" : 933
    }
  ]
}

Issues Resolved

Check List

  • 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.

@VijayanB VijayanB requested a review from a team May 12, 2022 16:53
@VijayanB VijayanB force-pushed the add-stats-rest branch 4 times, most recently from 1131224 to 078d59a Compare May 12, 2022 22:09
Use short copyright header.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
@@ -7,6 +7,7 @@

import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.opensearch.geospatial.GeospatialTestHelper.buildFieldNameValuePair;
import static org.opensearch.geospatial.GeospatialTestHelper.removeStartAndEndObject;

Choose a reason for hiding this comment

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

I think this is an unused import. Did we add checkstyle to the repo?

Copy link
Member Author

Choose a reason for hiding this comment

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

This method used to be part of this test, i moved it to Helper class, hence, you see change in import

Copy link
Member

@jmazanec15 jmazanec15 left a comment

Choose a reason for hiding this comment

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

@VijayanB I think using filter_path to filter breaks pattern for a lot of other stats APIs, including node stats. Typically, its .../stats/{metric}


@Override
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient nodeClient) {
return channel -> nodeClient.execute(StatsAction.INSTANCE, new StatsRequest(), new RestToXContentListener<>(channel));
Copy link
Member

Choose a reason for hiding this comment

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

Can we add option to limit nodes request gets routed to?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry i couldn't understand. Do you mean to add support to include node_id parameter?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, assuming that the response contains node specific stats? Say I have a 100 node cluster and only want info for 1 node.

@VijayanB
Copy link
Member Author

@VijayanB I think using filter_path to filter breaks pattern for a lot of other stats APIs, including node stats. Typically, its .../stats/{metric}

I see. It looks like anti-pattern based on REST spec. Nevertheless, let me create an issue to see whether we need to support that format since node stats api follow this format.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
Added Request,NodeRequest,ResponseNodeResponse,Action classes with
boilerplate code and method.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
Added stats api "_plugins/geospatial/stats", to retrieve statistics for uploads
in cluster. By default all stats are returned, user can filter the response using
filter query parameter similar to other cluster response.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
private StatsRequest request;

public StatsNodeRequest() {
super();
Copy link
Member

Choose a reason for hiding this comment

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

This would make request null. Is there a reason for this constructor? I remember somewhere there may have been a required no-arg constructor but I cant remember if it was 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.

Good catch. I removed the default constructor. The one that needs default constructor is TransportAction

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
@codecov-commenter
Copy link

codecov-commenter commented May 25, 2022

Codecov Report

Merging #64 (89a554c) into main (f2360e5) will decrease coverage by 4.48%.
The diff coverage is 45.31%.

❗ Current head 89a554c differs from pull request most recent head 722ab09. Consider uploading reports for the commit 722ab09 to get more accurate results

@@             Coverage Diff              @@
##               main      #64      +/-   ##
============================================
- Coverage     90.69%   86.20%   -4.49%     
- Complexity      146      159      +13     
============================================
  Files            21       28       +7     
  Lines           548      609      +61     
  Branches         39       41       +2     
============================================
+ Hits            497      525      +28     
- Misses           47       78      +31     
- Partials          4        6       +2     
Impacted Files Coverage Δ
...eospatial/stats/upload/UploadStatsNodeRequest.java 0.00% <0.00%> (ø)
...ch/geospatial/stats/upload/UploadStatsRequest.java 0.00% <0.00%> (ø)
...atial/stats/upload/UploadStatsTransportAction.java 0.00% <0.00%> (ø)
...geospatial/stats/upload/RestUploadStatsAction.java 20.00% <20.00%> (ø)
...h/geospatial/stats/upload/UploadStatsResponse.java 62.50% <62.50%> (ø)
...opensearch/geospatial/plugin/GeospatialPlugin.java 88.88% <75.00%> (-11.12%) ⬇️
...ospatial/stats/upload/UploadStatsNodeResponse.java 76.92% <76.92%> (ø)
...pensearch/geospatial/stats/upload/UploadStats.java 100.00% <100.00%> (ø)
...rch/geospatial/stats/upload/UploadStatsAction.java 100.00% <100.00%> (ø)
...ch/geospatial/stats/upload/UploadStatsService.java 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2360e5...722ab09. Read the comment docs.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
@VijayanB VijayanB requested a review from jmazanec15 May 25, 2022 02:04
@VijayanB VijayanB force-pushed the add-stats-rest branch 3 times, most recently from 216f301 to e9f466f Compare May 25, 2022 18:35
Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
@VijayanB VijayanB merged commit 0b21de6 into opensearch-project:main May 25, 2022
@VijayanB VijayanB deleted the add-stats-rest branch May 25, 2022 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants