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

Code before:
                    ],
                ),
                panels.timeseries_bytes(
                    "Executor Cache Memory Usage",
                    "",
                    [
                        panels.target(
                            executor_cache_usage_expr,
                            "fragment {{fragment_id}}",
                        ),
                    ],
                ),
                panels.timeseries_bytes(
                    "Shared Buffer Memory Usage",
                    "",
                    [
                        panels.target(
                            shared_buffer_usage_expr,
                            "fragment {{fragment_id}}",
                        ),
                    ],
                ),
                panels.subheader("Backpressure by Fragment"),
                panels.timeseries_percentage(
                    "Actor Output Blocking Rate (Downstream Backpressure)",
                    "The rate that an actor is blocked by its downstream.",
                    [
                        # The metrics might be pre-aggregated locally on each compute node when `actor_id` is masked due to metrics level settings.
                        # Thus to calculate the average, we need to manually divide the actor count.
                        #
                        # Note: actor_count is equal to the number of dispatchers for a given downstream fragment,
                        # this holds true as long as we don't support multiple edges between two fragments.
                        panels.target(
                            f"sum(rate({metric('stream_actor_output_buffer_blocking_duration_ns')}[$__rate_interval])) by (fragment_id, downstream_fragment_id) \
                                / ignoring (downstream_fragment_id) group_left sum({metric('stream_actor_count')}) by (fragment_id) \
                                / 1000000000",
                            "fragment {{fragment_id}}->{{downstream_fragment_id}}",
                        ),
                    ],
                ),
                panels.timeseries_percentage(
                    "Actor Input Blocking Rate (Upstream Backpressure)",
                    "The rate that an actor is blocked by its upstream.",
                    [
                        # The metrics might be pre-aggregated locally on each compute node when `actor_id` is masked due to metrics level settings.
                        # Thus to calculate the average, we need to manually divide the actor count.
                        panels.target(
                            f"sum(rate({metric('stream_actor_input_buffer_blocking_duration_ns')}[$__rate_interval])) by (fragment_id, upstream_fragment_id) \
                                / ignoring (upstream_fragment_id) group_left sum({metric('stream_actor_count')}) by (fragment_id) \
                                / 1000000000",
                            "fragment {{fragment_id}}<-{{upstream_fragment_id}}",

Review comment (suggestion):
The description for 'Shared Buffer Memory Usage' panel is empty. Add a meaningful description similar to other panels (e.g., 'Shared buffer imm size aggregated by fragment').
```suggestion
                    "Shared buffer imm size aggregated by fragment",
```

Code after:
                    ],
                ),
                panels.subheader("Memory Usage by Fragment"),
                panels.timeseries_bytes(
                    "Total Memory Usage",
                    "Sum of executor cache memory and shared buffer imm size",
                    [
                        panels.target(
                            total_memory_usage_expr,
                            "fragment {{fragment_id}}",
                        ),
                    ],
                ),
                panels.timeseries_bytes(
                    "Executor Cache Memory Usage",
                    "",
                    [
                        panels.target(
                            executor_cache_usage_expr,
                            "fragment {{fragment_id}}",
                        ),
                    ],
                ),
                panels.timeseries_bytes(
                    "Shared Buffer Memory Usage",
                    "",
                    [
                        panels.target(
                            shared_buffer_usage_expr,
                            "fragment {{fragment_id}}",
                        ),
                    ],
                ),
                panels.subheader("Backpressure by Fragment"),
                panels.timeseries_percentage(
                    "Actor Output Blocking Rate (Downstream Backpressure)",
                    "The rate that an actor is blocked by its downstream.",
                    [
                        # The metrics might be pre-aggregated locally on each compute node when `actor_id` is masked due to metrics level settings.
                        # Thus to calculate the average, we need to manually divide the actor count.
                        #
                        # Note: actor_count is equal to the number of dispatchers for a given downstream fragment,
                        # this holds true as long as we don't support multiple edges between two fragments.
                        panels.target(
                            f"sum(rate({metric('stream_actor_output_buffer_blocking_duration_ns')}[$__rate_interval])) by (fragment_id, downstream_fragment_id) \
                                / ignoring (downstream_fragment_id) group_left sum({metric('stream_actor_count')}) by (fragment_id) \
                                / 1000000000",
                            "fragment {{fragment_id}}->{{downstream_fragment_id}}",
                        ),
                    ],
                ),