Skip to content

Commit

Permalink
Merge branch 'main' into diffus
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjstone committed Dec 20, 2024
2 parents adaeacb + b1978e2 commit 3aafc3f
Show file tree
Hide file tree
Showing 89 changed files with 9,958 additions and 1,460 deletions.
41 changes: 41 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ members = [
"cockroach-admin/types",
"common",
"dev-tools/cert-dev",
"dev-tools/clickana",
"dev-tools/clickhouse-cluster-dev",
"dev-tools/ch-dev",
"dev-tools/crdb-seed",
Expand Down Expand Up @@ -78,6 +79,7 @@ members = [
"nexus/macros-common",
"nexus/metrics-producer-gc",
"nexus/networking",
"nexus/reconfigurator/blippy",
"nexus/reconfigurator/execution",
"nexus/reconfigurator/planning",
"nexus/reconfigurator/preparation",
Expand Down Expand Up @@ -158,6 +160,7 @@ default-members = [
"cockroach-admin/types",
"common",
"dev-tools/cert-dev",
"dev-tools/clickana",
"dev-tools/clickhouse-cluster-dev",
"dev-tools/ch-dev",
"dev-tools/crdb-seed",
Expand Down Expand Up @@ -211,6 +214,7 @@ default-members = [
"nexus/macros-common",
"nexus/metrics-producer-gc",
"nexus/networking",
"nexus/reconfigurator/blippy",
"nexus/reconfigurator/execution",
"nexus/reconfigurator/planning",
"nexus/reconfigurator/preparation",
Expand Down Expand Up @@ -332,6 +336,7 @@ chrono = { version = "0.4", features = [ "serde" ] }
chrono-tz = "0.10.0"
ciborium = "0.2.2"
clap = { version = "4.5", features = ["cargo", "derive", "env", "wrap_help"] }
clickana = { path = "dev-tools/clickana" }
clickhouse-admin-api = { path = "clickhouse-admin/api" }
clickhouse-admin-keeper-client = { path = "clients/clickhouse-admin-keeper-client" }
clickhouse-admin-server-client = { path = "clients/clickhouse-admin-server-client" }
Expand Down Expand Up @@ -466,6 +471,7 @@ nexus-internal-api = { path = "nexus/internal-api" }
nexus-macros-common = { path = "nexus/macros-common" }
nexus-metrics-producer-gc = { path = "nexus/metrics-producer-gc" }
nexus-networking = { path = "nexus/networking" }
nexus-reconfigurator-blippy = { path = "nexus/reconfigurator/blippy" }
nexus-reconfigurator-execution = { path = "nexus/reconfigurator/execution" }
nexus-reconfigurator-planning = { path = "nexus/reconfigurator/planning" }
nexus-reconfigurator-preparation = { path = "nexus/reconfigurator/preparation" }
Expand Down
2 changes: 2 additions & 0 deletions clickhouse-admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ slog.workspace = true
slog-async.workspace = true
slog-dtrace.workspace = true
slog-error-chain.workspace = true
slog-term.workspace = true
serde.workspace = true
serde_json.workspace = true
thiserror.workspace = true
tokio.workspace = true
tokio-postgres.workspace = true
Expand Down
22 changes: 8 additions & 14 deletions clickhouse-admin/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ pub enum Timestamp {
#[derive(Debug, Serialize, Deserialize, JsonSchema, PartialEq)]
#[serde(rename_all = "snake_case")]
pub struct SystemTimeSeries {
pub time: Timestamp,
pub time: String,
pub value: f64,
// TODO: Would be really nice to have an enum with possible units (s, ms, bytes)
// Not sure if I can even add this, the system tables don't mention units at all.
Expand Down Expand Up @@ -2102,15 +2102,15 @@ snapshot_storage_disk=LocalSnapshotDisk

let expected = vec![
SystemTimeSeries {
time: crate::Timestamp::Unix("1732494720".to_string()),
time: "1732494720".to_string(),
value: 110220450825.75238,
},
SystemTimeSeries {
time: crate::Timestamp::Unix("1732494840".to_string()),
time: "1732494840".to_string(),
value: 110339992917.33331,
},
SystemTimeSeries {
time: crate::Timestamp::Unix("1732494960".to_string()),
time: "1732494960".to_string(),
value: 110421854037.33331,
},
];
Expand All @@ -2130,21 +2130,15 @@ snapshot_storage_disk=LocalSnapshotDisk

let expected = vec![
SystemTimeSeries {
time: crate::Timestamp::Utc(
"2024-11-25T00:34:00Z".parse::<DateTime<Utc>>().unwrap(),
),
time: "2024-11-25T00:34:00Z".to_string(),
value: 110220450825.75238,
},
SystemTimeSeries {
time: crate::Timestamp::Utc(
"2024-11-25T00:35:00Z".parse::<DateTime<Utc>>().unwrap(),
),
time: "2024-11-25T00:35:00Z".to_string(),
value: 110339992917.33331,
},
SystemTimeSeries {
time: crate::Timestamp::Utc(
"2024-11-25T00:36:00Z".parse::<DateTime<Utc>>().unwrap(),
),
time: "2024-11-25T00:36:00Z".to_string(),
value: 110421854037.33331,
},
];
Expand Down Expand Up @@ -2179,7 +2173,7 @@ snapshot_storage_disk=LocalSnapshotDisk

assert_eq!(
format!("{}", root_cause),
"data did not match any variant of untagged enum Timestamp at line 1 column 12",
"invalid type: integer `2024`, expected a string at line 1 column 12",
);
}
}
2 changes: 2 additions & 0 deletions common/src/api/external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,8 @@ impl JsonSchema for L4PortRange {
DeserializeFromStr,
PartialEq,
Eq,
PartialOrd,
Ord,
SerializeDisplay,
Hash,
)]
Expand Down
14 changes: 13 additions & 1 deletion common/src/api/internal/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ pub enum NetworkInterfaceKind {
JsonSchema,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Diffus,
)]
Expand All @@ -79,7 +81,17 @@ pub struct NetworkInterface {
// Note that `Deserialize` is manually implemented; if you make any changes to
// the fields of this structure, you must make them to that implementation too.
#[derive(
Debug, Clone, Copy, Serialize, JsonSchema, PartialEq, Eq, Hash, Diffus,
Debug,
Clone,
Copy,
Serialize,
JsonSchema,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Diffus,
)]
pub struct SourceNatConfig {
/// The external address provided to the instance or service.
Expand Down
31 changes: 31 additions & 0 deletions dev-tools/clickana/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "clickana"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[dependencies]
anyhow.workspace = true
camino.workspace = true
chrono.workspace = true
clap.workspace = true
clickhouse-admin-types.workspace = true
clickhouse-admin-server-client.workspace = true
dropshot.workspace = true
futures.workspace = true
omicron-common.workspace = true
ratatui.workspace = true
schemars.workspace = true
slog.workspace = true
slog-async.workspace = true
slog-dtrace.workspace = true
slog-error-chain.workspace = true
slog-term.workspace = true
serde_json.workspace = true
tokio.workspace = true
tokio-postgres.workspace = true

omicron-workspace-hack.workspace = true

[lints]
workspace = true
57 changes: 57 additions & 0 deletions dev-tools/clickana/src/bin/clickana.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use anyhow::Result;
use camino::Utf8PathBuf;
use clap::Parser;
use clickana::Clickana;
use std::net::SocketAddr;

const CLICKANA_LOG_FILE: &str = "/tmp/clickana.log";

#[tokio::main]
async fn main() -> Result<()> {
let args = Cli::parse();

let terminal = ratatui::init();
let result = Clickana::new(
args.clickhouse_addr,
args.log_path,
args.sampling_interval,
args.time_range,
args.refresh_interval,
)
.run(terminal)
.await;
ratatui::restore();
result
}

#[derive(Debug, Parser)]
struct Cli {
/// Path to the log file
#[arg(
long,
short,
env = "CLICKANA_LOG_PATH",
default_value = CLICKANA_LOG_FILE,
)]
log_path: Utf8PathBuf,

/// Address where a clickhouse admin server is listening on
#[arg(long, short = 'a')]
clickhouse_addr: SocketAddr,

/// The interval to collect monitoring data in seconds
#[arg(long, short, default_value_t = 60)]
sampling_interval: u64,

/// Range of time to collect monitoring data in seconds
#[arg(long, short, default_value_t = 3600)]
time_range: u64,

/// The interval at which the dashboards will refresh
#[arg(long, short, default_value_t = 60)]
refresh_interval: u64,
}
Loading

0 comments on commit 3aafc3f

Please sign in to comment.