Skip to content

Commit

Permalink
Add DRE tool command to fetch "untrusted" metrics from metrics-canist…
Browse files Browse the repository at this point in the history
…er (#640)

Co-authored-by: sa-github-api <[email protected]>
  • Loading branch information
pietrodimarco-dfinity and sa-github-api authored Jul 18, 2024
1 parent 734e609 commit 553ef7d
Show file tree
Hide file tree
Showing 18 changed files with 349 additions and 98 deletions.
28 changes: 23 additions & 5 deletions Cargo.Bazel.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "f3c6195e6654db56b4c772ec401cc5689f9b0fa6466d7c0fc6543302e0774321",
"checksum": "21560a1c6cf60a5df7d6ab8a9c786242587fcc03a6171df0fc1574fc13c8911c",
"crates": {
"actix-codec 0.5.2": {
"name": "actix-codec",
Expand Down Expand Up @@ -28369,29 +28369,35 @@
],
"crate_features": {
"common": [
"elf",
"errno",
"general",
"ioctl",
"no_std"
],
"selects": {
"aarch64-unknown-linux-gnu": [
"elf",
"errno",
"prctl",
"std",
"system"
],
"arm-unknown-linux-gnueabi": [
"elf",
"errno",
"prctl",
"std",
"system"
],
"armv7-unknown-linux-gnueabi": [
"elf",
"errno",
"prctl",
"std",
"system"
],
"i686-unknown-linux-gnu": [
"elf",
"errno",
"prctl",
"std",
"system"
Expand All @@ -28407,6 +28413,8 @@
"system"
],
"x86_64-unknown-linux-gnu": [
"elf",
"errno",
"prctl",
"std",
"system"
Expand Down Expand Up @@ -45604,8 +45612,18 @@
"name": "trustworthy-node-metrics",
"version": "0.4.3",
"repository": null,
"targets": [],
"library_target_name": null,
"targets": [
{
"Library": {
"crate_name": "trustworthy_node_metrics",
"crate_root": "src/lib.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "trustworthy_node_metrics",
"common_attrs": {
"compile_data_glob": [
"**"
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ cryptoki = "0.3.1"
csv = "1.3.0"
custom_error = "1.9.2"
decentralization = { path = "rs/decentralization" }
trustworthy-node-metrics = { path = "rs/dre-canisters/trustworthy-node-metrics/src/trustworthy-node-metrics" }
derive_builder = "0.20.0"
derive_more = "0.99.18"
dialoguer = "0.11.0"
Expand Down
6 changes: 3 additions & 3 deletions docs/trustworthy-metrics/trustworthy-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ You can obtain the DRE tool by following the instructions from [getting started]
To test out the command you can run the following command

```bash
dre <auth-params> trustworthy-metrics <wallet-canister-id> <start-at-timestamp> [<subnet-id>...]
dre <auth-params> node-metrics --trustworthy --wallet <wallet-canister-id> <start-at-timestamp> [<subnet-id>...]
```

??? tip "Explanation of the arguments"
Expand Down Expand Up @@ -149,12 +149,12 @@ Authentication with a private key is recommended, since it allows for more paral
Here are some real-world examples of how metrics can be retrieved:

```bash
dre --private-key-pem identity.pem trustworthy-metrics nanx4-baaaa-aaaap-qb4sq-cai 0 > data.json
dre --private-key-pem identity.pem node-metrics --trustworthy --wallet nanx4-baaaa-aaaap-qb4sq-cai 0 > data.json
```

Or with an HSM:
```bash
dre --hsm-slot 0 --hsm-key-id 0 --hsm-pin "<pin>" trustworthy-metrics nanx4-baaaa-aaaap-qb4sq-cai 0 > data.json
dre --hsm-slot 0 --hsm-key-id 0 --hsm-pin "<pin>" node-metrics --trustworthy --wallet nanx4-baaaa-aaaap-qb4sq-cai 0 > data.json
```

You can check some examples of the analytics possible with the IC Mainnet data in the following [Jupyter Notebook](./TrustworthyMetricsAnalytics.ipynb)
Expand Down
62 changes: 62 additions & 0 deletions docs/trustworthy-metrics/untrusted-metrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

# Get untrusted metrics from Node Metrics canister

## Introduction

Untrusted Node Metrics retrieval offers an alternative approach to accessing node performance data, relying on a canister that collects these metrics instead of quering the management canister of each subnet directly.

This method allows users to fetch node metrics dating back to May 18, 2024, providing an historical view compared to the trustworthy method, which only offers data from the past month.

The key drawback of quering untrusted metrics is that it introduces an intermediary, the canister responsible for data aggregation, which should NOT be considered trustworthy.

Despite these concerns, the extended temporal coverage can be valuable for certain analytical purposes. Additionally, querying the node metrics canister is cheaper because it allows for a query call instead of an update call and does not require a wallet canister.

This entire process is shown in the following diagram:

```mermaid
%%{init: {'theme':'forest'}}%%
graph TD
subgraph "Subnet 1"
S1["Consensus"] -->|Produces Trustworthy Data| M1["Management Canister 1"] --> M4["Node Metrics Canister"]
end
subgraph "Subnet 2"
S2["Consensus"] -->|Produces Trustworthy Data| M2["Management Canister 2"]
end
subgraph "Subnet 3"
S3["Consensus"] -->|Produces Trustworthy Data| M3["Management Canister 3"]
end
M2 --> M4
M3 --> M4
M4 --> DRE["DRE tool (open source)"]
DRE --> User
User --> |Analyze & Process Data| F["Node Metrics"]
style S1 fill:#f9f,stroke:#333,stroke-width:2px
style S2 fill:#f9f,stroke:#333,stroke-width:2px
style S3 fill:#f9f,stroke:#333,stroke-width:2px
style DRE fill:#ff9,stroke:#333,stroke-width:2px
style F fill:#9ff,stroke:#333,stroke-width:2px
```

### Using the cli

You can obtain the DRE tool by following the instructions from [getting started](../getting-started.md)

To test out the command you can run the following command

```bash
dre node-metrics <start-at-timestamp> [<subnet-id>...]
```

??? tip "Explanation of the arguments"
3. `start-at-timestamp` - used for filtering the output. To get all metrics, provide 0
4. `subnet-id` - subnets to query, if empty will provide metrics for all subnets

# Example use

Here are some real-world examples of how metrics can be retrieved:

```bash
dre node-metrics 0 > data.json
```
1 change: 1 addition & 0 deletions rs/cli/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ DEPS = [
"//rs/decentralization",
"//rs/ic-management-types",
"//rs/ic-management-backend:ic-management-backend-lib",
"//rs/dre-canisters/trustworthy-node-metrics/src/trustworthy-node-metrics:trustworthy_node_metrics"
]

package(default_visibility = ["//visibility:public"])
Expand Down
16 changes: 8 additions & 8 deletions rs/cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use get::Get;
use heal::Heal;
use hostos::HostOsCmd;
use ic_management_types::{MinNakamotoCoefficients, Network, NodeFeature};
use node_metrics::NodeMetrics;
use nodes::Nodes;
use proposals::Proposals;
use propose::Propose;
use registry::Registry;
use trustworthy_metrics::TrustworthyMetrics;
use update_unassigned_nodes::UpdateUnassignedNodes;
use upgrade::Upgrade;
use url::Url;
Expand All @@ -30,12 +30,12 @@ mod firewall;
mod get;
mod heal;
pub mod hostos;
mod node_metrics;
mod nodes;
mod proposals;
mod propose;
mod registry;
mod subnet;
mod trustworthy_metrics;
mod update_unassigned_nodes;
pub mod upgrade;
mod version;
Expand Down Expand Up @@ -123,6 +123,9 @@ pub enum Subcommands {
/// Manage versions
Version(VersionCmd),

/// Fetch node metrics stats
NodeMetrics(NodeMetrics),

/// Manage hostos versions
HostOs(HostOsCmd),

Expand All @@ -135,9 +138,6 @@ pub enum Subcommands {
/// Vote on our proposals
Vote(Vote),

/// Trustworthy Metrics
TrustworthyMetrics(TrustworthyMetrics),

/// Registry inspection (dump) operations
Registry(Registry),

Expand Down Expand Up @@ -251,12 +251,12 @@ impl ExecutableCommand for Args {
Subcommands::Nodes(c) => c.require_ic_admin(),
Subcommands::ApiBoundaryNodes(c) => c.require_ic_admin(),
Subcommands::Vote(c) => c.require_ic_admin(),
Subcommands::TrustworthyMetrics(c) => c.require_ic_admin(),
Subcommands::Registry(c) => c.require_ic_admin(),
Subcommands::Firewall(c) => c.require_ic_admin(),
Subcommands::Upgrade(c) => c.require_ic_admin(),
Subcommands::Proposals(c) => c.require_ic_admin(),
Subcommands::Completions(c) => c.require_ic_admin(),
Subcommands::NodeMetrics(c) => c.require_ic_admin(),
}
}

Expand All @@ -273,12 +273,12 @@ impl ExecutableCommand for Args {
Subcommands::Nodes(c) => c.execute(ctx).await,
Subcommands::ApiBoundaryNodes(c) => c.execute(ctx).await,
Subcommands::Vote(c) => c.execute(ctx).await,
Subcommands::TrustworthyMetrics(c) => c.execute(ctx).await,
Subcommands::Registry(c) => c.execute(ctx).await,
Subcommands::Firewall(c) => c.execute(ctx).await,
Subcommands::Upgrade(c) => c.execute(ctx).await,
Subcommands::Proposals(c) => c.execute(ctx).await,
Subcommands::Completions(c) => c.execute(ctx).await,
Subcommands::NodeMetrics(c) => c.execute(ctx).await,
}
}

Expand All @@ -295,12 +295,12 @@ impl ExecutableCommand for Args {
Subcommands::Nodes(c) => c.validate(cmd),
Subcommands::ApiBoundaryNodes(c) => c.validate(cmd),
Subcommands::Vote(c) => c.validate(cmd),
Subcommands::TrustworthyMetrics(c) => c.validate(cmd),
Subcommands::Registry(c) => c.validate(cmd),
Subcommands::Firewall(c) => c.validate(cmd),
Subcommands::Upgrade(c) => c.validate(cmd),
Subcommands::Proposals(c) => c.validate(cmd),
Subcommands::Completions(c) => c.validate(cmd),
Subcommands::NodeMetrics(c) => c.validate(cmd),
}
}
}
Loading

0 comments on commit 553ef7d

Please sign in to comment.