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

feat(launchpad): read stats from metrics endpoint #1821

Merged
merged 8 commits into from
Jun 4, 2024

Conversation

RolandSherwin
Copy link
Member

  • provide option to start metrics server during safenode manager add
  • Run the metrics server on localhost instead of 0.0.0.0 for security.
  • Store and expose the forwarded balance via the metrics endpoint.
    • We already have wallet_balance via the metrics endpoint, but it will get to 0 if the reward has been forwarded. So we need to instead track the forwarded rewards separately.
    • Also, to retain the forwarded_balance across restarts, we need to cache is locally. Else, people would see a value of 0 after a restart.
  • Modify the device status pane in the launchpad to display the stats

eq(ServiceInstallCtx {
args: vec![
OsString::from("--rpc"),
OsString::from("127.0.0.1:8081"),

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note test

Do not leave debug code in production
@@ -19,8 +19,8 @@
const METRICS_CONTENT_TYPE: &str = "application/openmetrics-text;charset=utf-8;version=1.0.0";

pub(crate) fn run_metrics_server(registry: Registry, port: u16) {
// The server should not bind to localhost/127.0.0.1 as it will not accept connections from containers.
let addr = ([0, 0, 0, 0], port).into();
// todo: containers don't work with localhost.

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
async fn fetch_stat_per_node(metrics_port: u16, _data_dir: PathBuf) -> Result<NodeStats> {
let now = Instant::now();

let body = reqwest::get(&format!("http://localhost:{metrics_port}/metrics"))

Check notice

Code scanning / devskim

Accessing localhost could indicate debug code, or could hinder scaling. Note

Do not leave debug code in production
@joshuef
Copy link
Contributor

joshuef commented Jun 4, 2024

It's not clear to me if this alone will result in us not having metrics on new testnets.

If that's the case I don't want this in until we can have that (via checkbox or what have you at deploy time... default to yes in the workflow trigger)

Copy link
Contributor

@mazzi mazzi left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@joshuef joshuef removed the DoNotMerge label Jun 4, 2024
@joshuef joshuef added this pull request to the merge queue Jun 4, 2024
Merged via the queue into maidsafe:main with commit 07e1538 Jun 4, 2024
40 of 41 checks passed
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.

3 participants