Skip to content

Add from and to to default dashboards#87823

Merged
Felixoid merged 5 commits intomasterfrom
dashboards-from-to
Oct 1, 2025
Merged

Add from and to to default dashboards#87823
Felixoid merged 5 commits intomasterfrom
dashboards-from-to

Conversation

@Felixoid
Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Add from and to values to the system dashboards to facilitate historical investigations.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Sep 29, 2025

Workflow [PR], commit [3b63e42]

Summary:

job_name test_name status info comment
Integration tests (amd_binary, 3/5) failure
test_quorum_inserts/test.py::test_insert_quorum_with_drop_partition[False] FAIL
Integration tests (amd_binary, 4/5) failure
test_trace_log_memory_context/test.py::test_memory_context_in_trace_log FAIL

@clickhouse-gh clickhouse-gh bot added the pr-improvement Pull request with some product improvements label Sep 29, 2025
@vdimir vdimir self-assigned this Sep 29, 2025
Copy link
Copy Markdown
Member

@vdimir vdimir left a comment

Choose a reason for hiding this comment

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

Overall looks great! What do you think about making it a bit more user-friendly by adding placeholders and hover text? It's not really clear what format to use for entering data until you see the actual queries. Something like this:

diff --git a/programs/server/dashboard.html b/programs/server/dashboard.html
index 727d65316a7..0a01a9df6f8 100644
--- a/programs/server/dashboard.html
+++ b/programs/server/dashboard.html
@@ -548,8 +548,18 @@ let queries = [];
 /// All other parameters will be automatically found in the queries.
 let default_params = {
     'rounding': '60',
-    'seconds': '86400'
+    'seconds': '86400',
+    // If unset, the `seconds` is used
+    'from': '',
+    'to': '',
 };
+
+let default_params_desc = {
+    'from': {'placeholder': '2023-01-01 00:00:00', 'title': 'Enter date in 2023-01-01 00:00:00 format. If empty, it is calculated as current time minus "seconds" parameter.'},
+    'to': {'placeholder': '2023-01-02 00:00:00', 'title': 'Enter date in 2023-01-01 00:00:00 format. If empty, it is current time.'},
+    'seconds': {'placeholder': '86400', 'title': 'Number of seconds to look back from current time. Default is 86400 (1 day).'},
+}
+
 let params = default_params;
 
 /// Palette generation for charts
@@ -667,6 +677,14 @@ function insertParam(name, value) {
     param_value.name = `${name}`;
     param_value.type = 'text';
     param_value.value = value;
+    if (name in default_params_desc) {
+        if ('placeholder' in default_params_desc[name]) {
+            param_value.placeholder = default_params_desc[name]['placeholder'];
+        }
+        if ('title' in default_params_desc[name]) {
+            param_value.title = default_params_desc[name]['title'];
+        }
+    }
     param_value.spellcheck = false;
 
     let setWidth = e => { e.style.width = (e.value.length + 1) + 'ch' };

Also, the current parameter order is a bit confusing (from, seconds, to). It would probably be better to force it to from, to, seconds, but that would require some additional changes since we currently just iterate over object keys.

@Felixoid
Copy link
Copy Markdown
Member Author

Hinting is a good idea, I'll add it.

Regarding sorting, it's not so tricky. Added it.

@Felixoid
Copy link
Copy Markdown
Member Author

Integration tests failed. I'll fix them.

BTW, I wonder if we can use {to:DateTime} and {from:DateTime} conveniently. Will play with it a little bit

@Felixoid
Copy link
Copy Markdown
Member Author

No, the {from:DateTime} works pretty badly.

To see how it works, here's the data to try:

{
  "params": {
    "rounding": "60",
    "seconds": "86400",
    "from": "",
    "to": ""
  },
  "queries": [
    {
      "title": "Queries/second",
      "query": "WITH toDateTimeOrDefault({from:DateTime}, '', now() - {seconds:UInt32}) AS from,\n    toDateTimeOrDefault({to:DateTime}, '', now()) AS to\nSELECT toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t, avg(ProfileEvent_Query)\nFROM merge('system', '^metric_log')\nWHERE event_date BETWEEN toDate(from) AND toDate(to) AND event_time BETWEEN from AND to\nGROUP BY t\nORDER BY t WITH FILL STEP {rounding:UInt32}"
    },
    {
      "title": "CPU Usage (cores)",
      "query": "WITH toDateTimeOrDefault({from:DateTime}, '', now() - {seconds:UInt32}) AS from,\n    toDateTimeOrDefault({to:DateTime}, '', now()) AS to\nSELECT toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t, avg(ProfileEvent_OSCPUVirtualTimeMicroseconds) / 1000000\nFROM merge('system', '^metric_log')\nWHERE event_date BETWEEN toDate(from) AND toDate(to) AND event_time BETWEEN from AND to\nGROUP BY t\nORDER BY t WITH FILL STEP {rounding:UInt32}"
    },
    {
      "title": "Queries Running",
      "query": "WITH toDateTimeOrDefault({from:DateTime}, '', now() - {seconds:UInt32}) AS from,\n    toDateTimeOrDefault({to:DateTime}, '', now()) AS to\nSELECT toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t, avg(CurrentMetric_Query)\nFROM merge('system', '^metric_log')\nWHERE event_date BETWEEN toDate(from) AND toDate(to) AND event_time BETWEEN from AND to\nGROUP BY t\nORDER BY t WITH FILL STEP {rounding:UInt32}"
    },
    {
      "title": "Merges Running",
      "query": "WITH toDateTimeOrDefault({from:DateTime}, '', now() - {seconds:UInt32}) AS from,\n    toDateTimeOrDefault({to:DateTime}, '', now()) AS to\nSELECT toStartOfInterval(event_time, INTERVAL {rounding:UInt32} SECOND)::INT AS t, avg(CurrentMetric_Merge)\nFROM merge('system', '^metric_log')\nWHERE event_date BETWEEN toDate(from) AND toDate(to) AND event_time BETWEEN from AND to\nGROUP BY t\nORDER BY t WITH FILL STEP {rounding:UInt32}"
    }
  ]
}

@Felixoid Felixoid force-pushed the dashboards-from-to branch from c2561c6 to 3b63e42 Compare October 1, 2025 11:45
@Felixoid
Copy link
Copy Markdown
Member Author

Felixoid commented Oct 1, 2025

test_trace_log_memory_context/test.py::test_memory_context_in_trace_log is broken

test_quorum_inserts/test.py::test_insert_quorum_with_drop_partition has the same failure in master yesterday.

If nothing else is broken, I merge it.

@Felixoid Felixoid added this pull request to the merge queue Oct 1, 2025
Merged via the queue into master with commit f96e97d Oct 1, 2025
120 of 123 checks passed
@Felixoid Felixoid deleted the dashboards-from-to branch October 1, 2025 16:36
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants