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

Feature: New Metrics endpoint for CRN & CNN #528

Merged
merged 7 commits into from
Dec 11, 2023
Merged

Feature: New Metrics endpoint for CRN & CNN #528

merged 7 commits into from
Dec 11, 2023

Conversation

1yam
Copy link
Collaborator

@1yam 1yam commented Dec 1, 2023

Problem:

The current approach for getting those information is to fetch the whole list of nodes using ranges of post messages, which means pulling a whole lot of needless information (35mb for a week of CRN metrics).

Solutions:

Implementing two API endpoints to query CRN & CNN metrics in the Pyaleph database.

  1. /api/v0/core/{node_id}/metrics
{
    "metrics": {
        "item_hash": [<string>, <string>, ...],
        "measured_at": [<UNIX timestamp>, <UNIX timestamp>, ...],
        "base_latency": [<float>, <float>, ...],
        "base_latency_ipv4": [<float>, <float>, ...],
        "metrics_latency": [<float>, <float>, ...],
        "aggregate_latency": [<float>, <float>, ...],
        "file_download_latency": [<float>, <float>, ...],
        "pending_messages": [<int>, <int>, ...],
        "eth_height_remaining": [<int>, <int>, ...],
    }
}

  1. /api/v0/compute/{node_id}/metrics
{
    metrics: {
        item_hash: [<string>, <string>, ...],
        measured_at: [<UNIX timestamp>, <UNIX timestamp>, ...],
        base_latency: [<float>, <float>, ... ],
        base_latency_ipv4: [<float>, <float>, ...],
        full_check_latency: [<float>, <float>, ...],
        diagnostic_vm_latency: [<float>, <float>, ...],
    }
}

Params:

  • start_date: float
  • end_date: float
  • sort: ASC or DESC

@hoh hoh requested review from hoh and nesitor December 5, 2023 12:19
Copy link
Member

@MHHukiewitz MHHukiewitz left a comment

Choose a reason for hiding this comment

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

One typo, otherwise LGTM

src/aleph/web/controllers/main.py Outdated Show resolved Hide resolved
@MHHukiewitz MHHukiewitz merged commit 19df1e4 into aleph-im:master Dec 11, 2023
2 checks passed
hoh pushed a commit that referenced this pull request Dec 11, 2023
* Feature: New metric endpoint for CRN & CNN

* Internal: Unit Test for metric endpoint

* Fix: Remove unused import

* Refactor: Unit Test & remove too big message content for unit

* Fix: mypy error

* Refactor: easier way to parse sql query

* Fix typo

---------

Co-authored-by: Mike Hukiewitz <[email protected]>
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.

2 participants