Skip to content

Conversation

@HiDAl
Copy link

@HiDAl HiDAl commented May 17, 2023

This PR adds a new endpoint under _info/http. This endpoint summarises the HTTP stats of all the nodes into one big response, at cluster level. Compared with _nodes/_stats, it lacks the nodes dimension.

Response example:

{ "cluster_name": "runTask", "http": { "current_open": 1, "total_opened": 53, "clients": [ { "id": 1556275969, "local_address": "127.0.0.1:9200", "remote_address": "127.0.0.1:50883", "last_uri": "/_http_stats", "opened_time_millis": 1684319173046, "closed_time_millis": 1684319173046, "last_request_time_millis": 1684319173046, "request_count": 1, "request_size_bytes": 0 }, { "id": 414091317, "local_address": "127.0.0.1:9200", "remote_address": "127.0.0.1:50884", "last_uri": "/_http_stats", "opened_time_millis": 1684319173855, "closed_time_millis": 1684319173855, "last_request_time_millis": 1684319173855, "request_count": 1, "request_size_bytes": 0 }, ... ] } }

It also introduces a new AbstractInfoAction class which will be used to implement the next work about the extraction of stats

Closes #95391

Pablo Alcantar Morales added 4 commits May 17, 2023 15:01
@github-actions
Copy link
Contributor

Documentation preview:

@elasticsearchmachine elasticsearchmachine added v8.9.0 needs:triage Requires assignment of a team area label labels May 17, 2023
@HiDAl HiDAl added >feature :Data Management/Stats Statistics tracking and retrieval APIs Team:Data Management Meta label for data/management team and removed needs:triage Requires assignment of a team area label labels May 17, 2023
@HiDAl HiDAl requested a review from masseyke May 17, 2023 13:22
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@elasticsearchmachine
Copy link
Collaborator

Hi @HiDAl, I've created a changelog YAML for you.

@elasticsearchmachine
Copy link
Collaborator

Hi @HiDAl, I've updated the changelog YAML for you.

Copy link
Member

@masseyke masseyke left a comment

Choose a reason for hiding this comment

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

Looks pretty good to me. I left a few comments.


import static org.elasticsearch.xcontent.ToXContent.EMPTY_PARAMS;

public abstract class AbstractStatsAction extends BaseRestHandler {
Copy link
Member

Choose a reason for hiding this comment

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

Are you anticipating more stats like this, and that's why there is an abstract class with just one class that extends it?

Copy link
Author

Choose a reason for hiding this comment

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

yes, I'll update the tickets with extra information about this.


@Override
public ChunkedToXContent xContentChunks(NodesStatsResponse nodesStatsResponse) {
return nodesStatsResponse.getNodes().stream().map(NodeStats::getHttp).reduce(new HttpStats(List.of(), 0, 0), HttpStats::merge);
Copy link
Member

Choose a reason for hiding this comment

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

Also straightforward but maybe worth a unit test


`local_address`::
(string)
Local address for the HTTP client.
Copy link
Member

Choose a reason for hiding this comment

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

We probably ought to use the word "connection" instead of "client" in this section, right? The reason I think this is that (for example) this is the local address for the connection (it's the one on the elasticsearch server), but it's the remote connection for the client. Or maybe we ought to change this to client_address and elasticsearch_address or something?

Copy link
Author

Choose a reason for hiding this comment

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

I just copied the same existent doc of _nodes/_stats/http, but I will update both

Copy link
Author

Choose a reason for hiding this comment

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

Just checking out the whole section is called clients and provides information about them. For instance:

`opened_time_millis`:: (integer) Time at which the client opened the connection. 

so, changing to connection would imply deeper changes.

About changing the fields, I think it's not possible because this is using the old nodeStats API, which already has these names.

Copy link
Member

Choose a reason for hiding this comment

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

It makes sense that we can't change the fields. But we shouldn't just reuse documentation that's wrong, right? local_address is not the Local address for the HTTP client. It's the address that's local to the machine gathering the information, right? For example in the description for request_size_bytes we say Cumulative size in bytes of all requests from this client. So in that case we're using client to mean the thing making the requests. When we say Local address for the HTTP client., are we also using the word client to mean "the thing receiving the connection from the other client"? I think at a minimum we ought to improve the descriptions for local_address and remote_address (and probably as a followup fix the documentation for the _nodes API, too).

Copy link
Author

Choose a reason for hiding this comment

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

oooh now got it, I didn't fully understand what you said. Will update

Copy link
Author

Choose a reason for hiding this comment

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

@masseyke both updated. Thanks!


import java.util.List;

public class HttpStatsAction extends AbstractStatsAction {
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if the convention is documented anywhere, but almost all rest handlers start with Rest and end with Action, like RestHttpStatsAction. Probably worth doing here -- it makes it easier to find the right rest handler.

Copy link
Author

Choose a reason for hiding this comment

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

mmm right. will update!

@HiDAl HiDAl requested a review from masseyke May 18, 2023 10:21
Copy link
Member

@masseyke masseyke left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@HiDAl HiDAl changed the title New HTTP stats endpoint New HTTP info (/_info/http) endpoint May 22, 2023
@HiDAl HiDAl merged commit dc5d054 into elastic:main May 22, 2023
@HiDAl HiDAl deleted the new-http-stats branch May 22, 2023 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Data Management/Stats Statistics tracking and retrieval APIs >feature Team:Data Management Meta label for data/management team v8.9.0

3 participants