Skip to content

Commit

Permalink
chore(dashboard): Update the version of prometheus-http-client (#178)
Browse files Browse the repository at this point in the history
- no functional change
- I've tested that the new version works as expected with a local run of `yarn dev`
  • Loading branch information
sasa-tomic committed Feb 9, 2024
1 parent 350bd58 commit 989ca8d
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 45 deletions.
115 changes: 96 additions & 19 deletions Cargo.Bazel.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "9911caa648b8619f3b434bb29fac026c8711419ff79e05c956d0ed4cb5e151a4",
"checksum": "33a7792c0242d506d6be14d79c6146ea57bd5f73b4092afc33864713df44d83a",
"crates": {
"actix-codec 0.5.2": {
"name": "actix-codec",
Expand Down Expand Up @@ -10064,6 +10064,7 @@
"common": [
"alloc",
"powerfmt",
"serde",
"std"
],
"selects": {}
Expand All @@ -10073,6 +10074,10 @@
{
"id": "powerfmt 0.2.0",
"target": "powerfmt"
},
{
"id": "serde 1.0.196",
"target": "serde"
}
],
"selects": {}
Expand Down Expand Up @@ -12174,6 +12179,57 @@
},
"license": "(Apache-2.0 OR MIT) AND BSD-3-Clause"
},
"enum-as-inner 0.6.0": {
"name": "enum-as-inner",
"version": "0.6.0",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/enum-as-inner/0.6.0/download",
"sha256": "5ffccbb6966c05b32ef8fbac435df276c4ae4d3dc55a8cd0eb9745e6c12f546a"
}
},
"targets": [
{
"ProcMacro": {
"crate_name": "enum_as_inner",
"crate_root": "src/lib.rs",
"srcs": [
"**/*.rs"
]
}
}
],
"library_target_name": "enum_as_inner",
"common_attrs": {
"compile_data_glob": [
"**"
],
"deps": {
"common": [
{
"id": "heck 0.4.1",
"target": "heck"
},
{
"id": "proc-macro2 1.0.78",
"target": "proc_macro2"
},
{
"id": "quote 1.0.35",
"target": "quote"
},
{
"id": "syn 2.0.48",
"target": "syn"
}
],
"selects": {}
},
"edition": "2018",
"version": "0.6.0"
},
"license": "MIT/Apache-2.0"
},
"enumflags2 0.7.8": {
"name": "enumflags2",
"version": "0.7.8",
Expand Down Expand Up @@ -21648,7 +21704,7 @@
"target": "log"
},
{
"id": "prometheus-http-query 0.4.2",
"id": "prometheus-http-query 0.8.2",
"target": "prometheus_http_query"
},
{
Expand Down Expand Up @@ -34621,13 +34677,13 @@
},
"license": null
},
"prometheus-http-query 0.4.2": {
"prometheus-http-query 0.6.7": {
"name": "prometheus-http-query",
"version": "0.4.2",
"version": "0.6.7",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/prometheus-http-query/0.4.2/download",
"sha256": "6886b96a7a96d2a7cc0a1d69b20fa083cf5792982afe799dcdd05468bc51f351"
"url": "https://crates.io/api/v1/crates/prometheus-http-query/0.6.7/download",
"sha256": "6704e3a7a78545b1496524d518658005a6cc308abc90ce5fccf01891ecdc298b"
}
},
"targets": [
Expand All @@ -34646,8 +34702,18 @@
"compile_data_glob": [
"**"
],
"crate_features": {
"common": [
"rustls-tls-webpki-roots"
],
"selects": {}
},
"deps": {
"common": [
{
"id": "mime 0.3.17",
"target": "mime"
},
{
"id": "reqwest 0.11.24",
"target": "reqwest"
Expand All @@ -34671,18 +34737,18 @@
],
"selects": {}
},
"edition": "2018",
"version": "0.4.2"
"edition": "2021",
"version": "0.6.7"
},
"license": "MIT"
},
"prometheus-http-query 0.6.7": {
"prometheus-http-query 0.8.2": {
"name": "prometheus-http-query",
"version": "0.6.7",
"version": "0.8.2",
"repository": {
"Http": {
"url": "https://crates.io/api/v1/crates/prometheus-http-query/0.6.7/download",
"sha256": "6704e3a7a78545b1496524d518658005a6cc308abc90ce5fccf01891ecdc298b"
"url": "https://crates.io/api/v1/crates/prometheus-http-query/0.8.2/download",
"sha256": "e0de773a6ba25c9164ed9d86d653a92fac759a6f0e683fd141d56bb96e80fd8b"
}
},
"targets": [
Expand All @@ -34703,7 +34769,7 @@
],
"crate_features": {
"common": [
"rustls-tls-webpki-roots"
"default"
],
"selects": {}
},
Expand All @@ -34721,10 +34787,6 @@
"id": "serde 1.0.196",
"target": "serde"
},
{
"id": "serde_json 1.0.113",
"target": "serde_json"
},
{
"id": "time 0.3.34",
"target": "time"
Expand All @@ -34737,7 +34799,16 @@
"selects": {}
},
"edition": "2021",
"version": "0.6.7"
"proc_macro_deps": {
"common": [
{
"id": "enum-as-inner 0.6.0",
"target": "enum_as_inner"
}
],
"selects": {}
},
"version": "0.8.2"
},
"license": "MIT"
},
Expand Down Expand Up @@ -42511,6 +42582,7 @@
"local-offset",
"macros",
"parsing",
"serde",
"std"
],
"selects": {}
Expand All @@ -42533,6 +42605,10 @@
"id": "powerfmt 0.2.0",
"target": "powerfmt"
},
{
"id": "serde 1.0.196",
"target": "serde"
},
{
"id": "time-core 0.1.2",
"target": "time_core"
Expand Down Expand Up @@ -42623,7 +42699,8 @@
"crate_features": {
"common": [
"formatting",
"parsing"
"parsing",
"serde"
],
"selects": {}
},
Expand Down
26 changes: 20 additions & 6 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ lru = "0.12.1"
phantom_newtype = { git = "https://github.com/dfinity/ic.git", rev = "4b3b2ce76c4bde0c1c60fb80b0915931003b7eca" }
pkcs11 = "0.5.0"
pretty_env_logger = "0.5.0"
prometheus-http-query = "0.4.0"
prometheus-http-query = "0.8.2"
prometheus = { version = "0.13.3", features = ["process"] }
prost = "0.12.1"
rand = { version = "0.8.5", features = ["std_rng"] }
Expand Down
30 changes: 15 additions & 15 deletions rs/ic-management-backend/src/health.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use std::{
collections::{BTreeMap, HashSet},
convert::TryInto,
str::FromStr,
};

use ic_base_types::PrincipalId;
use ic_management_types::{Network, Status};
use prometheus_http_query::{Client, InstantVector, Selector};
use prometheus_http_query::{Client, Selector};

use crate::prometheus;

Expand All @@ -24,15 +23,16 @@ impl HealthClient {
}

pub async fn subnet(&self, subnet: PrincipalId) -> anyhow::Result<BTreeMap<PrincipalId, Status>> {
let query_up: InstantVector = Selector::new()
let ic_name = self.network.legacy_name();
let subnet_name = subnet.to_string();
let query_up = Selector::new()
.metric("up")
.with("ic", &self.network.legacy_name())
.with("job", "replica")
.with("ic_subnet", subnet.to_string().as_str())
.try_into()?;
.eq("ic", ic_name.as_str())
.eq("job", "replica")
.eq("ic_subnet", subnet_name.as_str());

let response_up = self.client.query(query_up, None, None).await?;
let instant_up = response_up.as_instant().expect("Expected instant vector");
let response_up = self.client.query(query_up).get().await?;
let instant_up = response_up.data().as_vector().expect("Expected instant vector");

// Alerts are synthetic time series and cannot be queries as regular metrics
// https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/#inspecting-alerts-during-runtime
Expand All @@ -41,8 +41,8 @@ impl HealthClient {
self.network.legacy_name(),
subnet
);
let response_alert = self.client.query(query_alert, None, None).await?;
let instant_alert = response_alert.as_instant().expect("Expected instant vector");
let response_alert = self.client.query(query_alert).get().await?;
let instant_alert = response_alert.data().as_vector().expect("Expected instant vector");
let node_ids_with_alerts: HashSet<PrincipalId> = instant_alert
.iter()
.filter_map(|r| r.metric().get("ic_node").and_then(|id| PrincipalId::from_str(id).ok()))
Expand Down Expand Up @@ -71,12 +71,12 @@ impl HealthClient {
}

pub async fn nodes(&self) -> anyhow::Result<BTreeMap<PrincipalId, Status>> {
let query: InstantVector = InstantVector(format!(
let query = format!(
r#"ic_replica_orchestrator:health_state:bottomk_1{{ic="{network}"}}"#,
network = self.network.legacy_name(),
));
let response = self.client.query(query, None, None).await?;
let results = response.as_instant().expect("Expected instant vector");
);
let response = self.client.query(query).get().await?;
let results = response.data().as_vector().expect("Expected instant vector");
Ok(results
.iter()
.filter_map(|r| {
Expand Down
8 changes: 4 additions & 4 deletions rs/ic-management-backend/src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ impl RolloutState {
// Limit the stage size to the number of
MAX_ROLLOUT_STAGE_SIZE,
current_day_first_stage_size + i
// Add 1 if not first stage of the day
// Add 1 if not first stage of the day
+ std::cmp::min(self.rollout_days.iter().find(|rd| rd.date == day.date).expect("rollout day should exist").rollout_stages_subnets.len() + rollout_stages_sizes[i].len(), 1),
),
// Limit the stage size to the number of available subnets
Expand Down Expand Up @@ -589,7 +589,7 @@ async fn get_update_states(
count by (ic_subnet) (ic_replica_info{{ic="{network}", ic_active_version!="{version}"}})
/
max by (ic_subnet) (consensus_dkg_current_committee_size{{ic="{network}"}})
,
,
"{state_field}", "{preparing_state}", "", ""
)
or ignoring({state_field})
Expand Down Expand Up @@ -645,8 +645,8 @@ async fn get_update_states(
period = Utc::now().timestamp() - since.timestamp(),
);
info!("release ({}) query: {}", release.commit_hash, query);
let response = prometheus_client.query(query, None, None).await?;
let results = response.as_instant().expect("Expected instant vector");
let response = prometheus_client.query(query).get().await?;
let results = response.data().as_vector().expect("Expected instant vector");
Ok(results
.iter()
.filter_map(|r| {
Expand Down

0 comments on commit 989ca8d

Please sign in to comment.