Skip to content

Commit

Permalink
Extend summary view (fetches and replication queue info)
Browse files Browse the repository at this point in the history
  • Loading branch information
azat committed Nov 1, 2023
1 parent 4b2c5fa commit 34f3dd2
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/interpreter/clickhouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ pub struct ClickHouseServerStorages {
pub struct ClickHouseServerSummary {
pub processes: u64,
pub merges: u64,
pub replication_queue: u64,
pub replication_queue_tries: u64,
pub fetches: u64,
pub servers: u64,
pub storages: ClickHouseServerStorages,
pub uptime: ClickHouseServerUptime,
Expand Down Expand Up @@ -362,7 +365,10 @@ impl ClickHouse {
(SELECT sum(bytes_allocated) FROM {dictionaries}) AS memory_dictionaries_,
(SELECT sum(primary_key_bytes_in_memory_allocated) FROM {parts}) AS memory_primary_keys_,
(SELECT count() FROM {one}) AS servers_,
(SELECT count() FROM {merges}) AS merges_
(SELECT count() FROM {merges}) AS merges_,
(SELECT count() FROM {replication_queue}) AS replication_queue_,
(SELECT sum(num_tries) FROM {replication_queue}) AS replication_queue_tries_,
(SELECT count() FROM {fetches}) AS fetches_
SELECT
assumeNotNull(servers_) AS servers,
assumeNotNull(memory_tracked_) AS memory_tracked,
Expand All @@ -372,6 +378,9 @@ impl ClickHouse {
assumeNotNull(processes_) AS processes,
assumeNotNull(memory_merges_) AS memory_merges,
assumeNotNull(merges_) AS merges,
assumeNotNull(replication_queue_) AS replication_queue,
assumeNotNull(replication_queue_tries_) AS replication_queue_tries,
assumeNotNull(fetches_) AS fetches,
assumeNotNull(memory_dictionaries_) AS memory_dictionaries,
assumeNotNull(memory_primary_keys_) AS memory_primary_keys,
Expand Down Expand Up @@ -451,6 +460,8 @@ impl ClickHouse {
tables=self.get_table_name("system.tables"),
processes=self.get_table_name("system.processes"),
merges=self.get_table_name("system.merges"),
replication_queue=self.get_table_name("system.replication_queue"),
fetches=self.get_table_name("system.replicated_fetches"),
dictionaries=self.get_table_name("system.dictionaries"),
parts=self.get_table_name("system.parts"),
asynchronous_metrics=self.get_table_name("system.asynchronous_metrics"),
Expand All @@ -464,6 +475,9 @@ impl ClickHouse {
return Ok(ClickHouseServerSummary {
processes: get("processes"),
merges: get("merges"),
replication_queue: get("replication_queue"),
replication_queue_tries: get("replication_queue_tries"),
fetches: get("fetches"),
servers: get("servers"),

uptime: ClickHouseServerUptime {
Expand Down
41 changes: 41 additions & 0 deletions src/view/summary_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ impl SummaryView {
.child(views::DummyView.fixed_width(1))
.child(views::TextView::new("").with_name("merges"))
.child(views::DummyView.fixed_width(1))
.child(views::TextView::new(StyledString::styled(
"Fetches:",
BaseColor::Cyan.dark(),
)))
.child(views::DummyView.fixed_width(1))
.child(views::TextView::new("").with_name("fetches"))
.child(views::DummyView.fixed_width(1))
.child(views::TextView::new(StyledString::styled(
"RepQueue:",
BaseColor::Cyan.dark(),
)))
.child(views::DummyView.fixed_width(1))
.child(views::TextView::new("").with_name("replication_queue"))
.child(views::DummyView.fixed_width(1))
.child(views::TextView::new(StyledString::styled(
"Buffers:",
BaseColor::Cyan.dark(),
Expand Down Expand Up @@ -308,6 +322,33 @@ impl SummaryView {
self.set_view_content("merges", content);
}

{
let mut content = StyledString::plain("");
content.append_styled(
summary.replication_queue.to_string(),
get_color_for_ratio(summary.replication_queue, summary.servers * 20),
);
content.append(" (");
content.append_styled(
summary.replication_queue_tries.to_string(),
get_color_for_ratio(
summary.replication_queue_tries,
summary.replication_queue * 2,
),
);
content.append(")");
self.set_view_content("replication_queue", content);
}

{
let mut content = StyledString::plain("");
content.append_styled(
summary.fetches.to_string(),
get_color_for_ratio(summary.fetches, summary.servers * 20),
);
self.set_view_content("fetches", content);
}

{
let mut content = StyledString::plain("");
content.append_styled(
Expand Down

0 comments on commit 34f3dd2

Please sign in to comment.