Repository: risingwavelabs/risingwave
File: grafana/dashboard/dev/cluster_essential.py (Python)

Code before:
        f"/ 1000000000"
    )
    input_blocking_rate_expr = (
        f"max("
        f"    {input_blocking_rate_per_edge_expr}"
        f") by (fragment_id)"
    )
    busy_rate_expr = (
        f"1 - ("
        f"  ({output_blocking_rate_expr}) > ({input_blocking_rate_expr}) or"
        f"  ({input_blocking_rate_expr})"
        f")"
    )
    return busy_rate_expr

def _actor_busy_rate_target(panels: Panels, rate_interval: str):
    actor_busy_rate_expr = _actor_busy_rate_expr(rate_interval)
    return panels.target(
        f"({actor_busy_rate_expr})",
        "fragment {{fragment_id}}",
    )

def _relation_busy_rate_expr(rate_interval: str):
    actor_busy_rate_expr = _actor_busy_rate_expr(rate_interval)
    relation_busy_rate_expr = (
        f"topk (1,"
        f"  ({actor_busy_rate_expr}) * on (fragment_id) group_right {metric('table_info')}"
        f") by (materialized_view_id)"
    )
    relation_busy_rate_with_metadata_expr = (
        f"label_replace(({relation_busy_rate_expr}), 'id', '$1', 'materialized_view_id', '(.*)')"
        f"* on (id) group_left (name, type) {metric('relation_info')}"
    )
    return relation_busy_rate_with_metadata_expr

def _relation_busy_rate_target(panels: Panels, rate_interval: str):
    return panels.target(
        _relation_busy_rate_expr(rate_interval),
        "name {{name}} id {{id}} type {{type}} fragment {{fragment_id}}",
    )

@section
def _(outer_panels: Panels):
    panels = outer_panels
    return [
        outer_panels.row("Cluster Essential Information"),
        *[
            panels.subheader("Node Status"),
            panels.timeseries_count(
                "Node Count",
                "The number of each type of RisingWave components alive.",

Review comment (suggestion):
The space between `topk` and the opening parenthesis is inconsistent with the rest of the codebase. It should be `topk(1,` instead of `topk (1,` to match the pattern used for all other function calls in this file (e.g., `sum(`, `max(`, `rate(`).
```suggestion
        f"topk(1,"
```

Code after:
        f"/ 1000000000"
    )
    input_blocking_rate_expr = (
        f"max("
        f"    {input_blocking_rate_per_edge_expr}"
        f") by (fragment_id)"
    )
    busy_rate_expr = (
        f"clamp_min("
        f"  1 - ("
        f"    ({output_blocking_rate_expr}) + ({input_blocking_rate_expr}) or"
        f"    ({input_blocking_rate_expr})"
        f"  ), 0"
        f")"
    )
    return busy_rate_expr

def _actor_busy_rate_target(panels: Panels, rate_interval: str):
    actor_busy_rate_expr = _actor_busy_rate_expr(rate_interval)
    return panels.target(
        f"({actor_busy_rate_expr})",
        "fragment {{fragment_id}}",
    )

def _relation_busy_rate_expr(rate_interval: str):
    actor_busy_rate_expr = _actor_busy_rate_expr(rate_interval)
    relation_busy_rate_expr = (
        f"topk(1,"
        f"  ({actor_busy_rate_expr}) * on (fragment_id) group_right {metric('table_info')}"
        f") by (materialized_view_id)"
    )
    relation_busy_rate_with_metadata_expr = (
        f"label_replace(({relation_busy_rate_expr}), 'id', '$1', 'materialized_view_id', '(.*)')"
        f"* on (id) group_left (name, type) {metric('relation_info')}"
    )
    return relation_busy_rate_with_metadata_expr

def _relation_busy_rate_target(panels: Panels, rate_interval: str):
    return panels.target(
        _relation_busy_rate_expr(rate_interval),
        "name {{name}} id {{id}} type {{type}} fragment {{fragment_id}}",
    )

@section
def _(outer_panels: Panels):
    panels = outer_panels
    return [
        outer_panels.row("Cluster Essential Information"),
        *[
            panels.subheader("Node Status"),
            panels.timeseries_count(