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

Code before:
        f"sum(rate({metric('stream_actor_scheduled_duration')}[$__rate_interval])) by (fragment_id)"
        f"/ on(fragment_id) sum({metric('stream_actor_count')}) by (fragment_id)"
    )
    return [
        outer_panels.row_collapsed(
            "Streaming Fragments",
            [
                panels.subheader("Overview"),
                panels.table_info(
                    "Top Fragments by Busy Rate",
                    "Top 10 fragments with the highest busy rate (%).",
                    [
                        panels.table_target(
                            _fragment_topk_percent_expr(
                                _actor_busy_rate_expr("$__rate_interval")
                            )
                        )
                    ],
                    ["fragment_id", "Value"],
                    dict.fromkeys(["Time"], True),
                    {"Value": "rate"},
                    "",
                    {"rate": "percent"},
                ),
                panels.table_info(
                    "Top Fragments by CPU",
                    "Top 10 fragments with the highest CPU rate (%).",
                    [
                        panels.table_target(
                            _fragment_topk_percent_expr(
                                f"{poll_duration_expr} / 1000000000"
                            )
                        )
                    ],
                    ["fragment_id", "Value"],
                    dict.fromkeys(["Time"], True),
                    {"Value": "rate"},
                    "",
                    {"rate": "percent"},
                ),
                panels.table_info(
                    "Top Fragments by Idle Time",
                    "Top 10 fragments with the highest idle time rate (%).",
                    [
                        panels.table_target(
                            _fragment_topk_percent_expr(
                                f"{idle_duration_expr} / 1000000000"
                            )
                        )
                    ],
                    ["fragment_id", "Value"],

Review comment (suggestion):
The table title "Top Fragments by CPU" is incomplete. Consider renaming to "Top Fragments by CPU Rate" to match the description and be consistent with other table titles.
```suggestion
                    "Top Fragments by CPU Rate",
```

Code after:
        f"sum(rate({metric('stream_actor_poll_duration')}[$__rate_interval])) by (fragment_id)"
    )
    poll_duration_expr = (
        f"{poll_duration_rate_expr} / on(fragment_id) {actor_count_expr} / 1000000000"
    )
    idle_duration_rate_expr = (
        f"sum(rate({metric('stream_actor_idle_duration')}[$__rate_interval])) by (fragment_id)"
    )
    idle_duration_expr = (
        f"{idle_duration_rate_expr} / on(fragment_id) {actor_count_expr} / 1000000000"
    )
    scheduled_duration_rate_expr = (
        f"sum(rate({metric('stream_actor_scheduled_duration')}[$__rate_interval])) by (fragment_id)"
    )
    scheduled_duration_expr = (
        f"{scheduled_duration_rate_expr} / on(fragment_id) {actor_count_expr} / 1000000000"
    )
    return [
        outer_panels.row_collapsed(
            "Streaming Fragments",
            [
                panels.subheader("Overview"),
                panels.table_info(
                    "Top Fragments by Busy Rate",
                    "Top 10 fragments with the highest peak busy rate (%).",
                    [
                        panels.table_target(
                            topk_percent_expr(
                                _fragment_peak_rate_with_id_at_step(
                                    _actor_busy_rate_expr("$__rate_interval")
                                )
                            )
                        )
                    ],
                    ["id", "Value"],
                    dict.fromkeys(["Time", "fragment_id"], True),
                    {"Value": "rate"},
                    {"rate": "percent"},
                ),
                panels.table_info(
                    "Top Fragments by CPU Rate",
                    "Top 10 fragments with the highest peak CPU rate (%).",
                    [
                        panels.table_target(
                            topk_percent_expr(
                                _fragment_peak_rate_with_id_at_step(
                                    poll_duration_expr
                                )
                            )
                        )
                    ],