Skip to content

Introduce Endpoint#messages_received_per_type #10387

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

Al2Klimov
Copy link
Member

Counts incoming messages per type and endpoint. Queryable via API:

Test

> GET /v1/objects/endpoints?pretty=1 HTTP/1.1
> Host: 127.0.0.1:5665
> Authorization: Basic cm9vdDoxMjM0NTY=
> User-Agent: curl/8.7.1
> Accept: application/json
> Content-Length: 40
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 40 bytes
< HTTP/1.1 200 OK
< Server: Icinga/v2.14.0-488-gbf0a2d4c3
< Content-Type: application/json
< Content-Length: 317
<
{
    "results": [
        {
            "attrs": {
                "messages_received_per_type": {
                    "icinga::Hello": 1
                }
            },
            "joins": {},
            "meta": {},
            "name": "ws-aklimov7777777.local",
            "type": "Endpoint"
        }
    ]
}

👍

@Al2Klimov Al2Klimov added enhancement New feature or request area/distributed Distributed monitoring (master, satellites, clients) area/api REST API labels Mar 21, 2025
@Al2Klimov Al2Klimov requested a review from lippserd March 21, 2025 09:58
@cla-bot cla-bot bot added the cla/signed label Mar 21, 2025
@Al2Klimov Al2Klimov force-pushed the cnt-msg branch 2 times, most recently from c305d1b to c60c58d Compare April 1, 2025 13:43
Endpoint::Endpoint()
{
for (auto& [name, afunc] : ApiFunctionRegistry::GetInstance()->GetItems()) {
m_MessageCounters.emplace(afunc, 0);
Copy link
Member Author

Choose a reason for hiding this comment

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

Idea

  1. std::unordered_map#reserve() twice as many as needed
  2. std::hash collisions will be even less likely at lookup
  3. Lookup gets even faster 😎

@lippserd lippserd removed their request for review May 6, 2025 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api REST API area/distributed Distributed monitoring (master, satellites, clients) cla/signed enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants