{
  "title": "Topic Metrics",
  "description": "Generated from AutoMQ opsbox Grafana dashboard topic-metrics.json. Complex PromQL expressions are tracked in dashboard-mapping.json.\n\nRendered as Datadog ordered/fixed sections. The matching free-layout backup is kept as topic-metrics-free-bak.json.",
  "notify_list": null,
  "layout_type": "ordered",
  "template_variables": [
    {
      "name": "cluster_id",
      "prefix": "service",
      "default": "*"
    },
    {
      "name": "topic",
      "prefix": "topic",
      "default": "*"
    },
    {
      "name": "automq_instance_id",
      "prefix": "instance_id",
      "default": "*"
    },
    {
      "name": "automq_env_id",
      "prefix": "env_id",
      "default": "*"
    }
  ],
  "reflow_type": "fixed",
  "widgets": [
    {
      "definition": {
        "type": "group",
        "title": "Topic Summary",
        "layout_type": "ordered",
        "show_title": true,
        "widgets": [
          {
            "definition": {
              "type": "query_value",
              "title": "Bytes In",
              "requests": [
                {
                  "response_format": "scalar",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "sum:automq_topic_network_io_bytes_total{$automq_env_id,$automq_instance_id,$cluster_id,$topic,direction:in}.as_rate()",
                      "aggregator": "last"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "Bytes In",
                      "number_format": {
                        "unit": {
                          "type": "canonical_unit",
                          "unit_name": "byte",
                          "per_unit_name": "second"
                        }
                      }
                    }
                  ]
                }
              ],
              "autoscale": true,
              "precision": 2
            },
            "layout": {
              "x": 0,
              "y": 0,
              "width": 3,
              "height": 3
            }
          },
          {
            "definition": {
              "type": "query_value",
              "title": "Bytes Out",
              "requests": [
                {
                  "response_format": "scalar",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "sum:automq_topic_network_io_bytes_total{$automq_env_id,$automq_instance_id,$cluster_id,$topic,direction:out}.as_rate()",
                      "aggregator": "last"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "Bytes Out",
                      "number_format": {
                        "unit": {
                          "type": "canonical_unit",
                          "unit_name": "byte",
                          "per_unit_name": "second"
                        }
                      }
                    }
                  ]
                }
              ],
              "autoscale": true,
              "precision": 2
            },
            "layout": {
              "x": 3,
              "y": 0,
              "width": 3,
              "height": 3
            }
          },
          {
            "definition": {
              "type": "query_value",
              "title": "Size",
              "requests": [
                {
                  "response_format": "scalar",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "sum:automq_topic_log_size{$automq_env_id,$automq_instance_id,$cluster_id,$topic}",
                      "aggregator": "last"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "Size",
                      "number_format": {
                        "unit": {
                          "type": "canonical_unit",
                          "unit_name": "byte"
                        }
                      }
                    }
                  ]
                }
              ],
              "autoscale": true,
              "precision": 2
            },
            "layout": {
              "x": 6,
              "y": 0,
              "width": 3,
              "height": 3
            }
          },
          {
            "definition": {
              "type": "query_value",
              "title": "Partition Count",
              "requests": [
                {
                  "response_format": "scalar",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "sum:automq_topic_partition_count{$automq_env_id,$automq_instance_id,$cluster_id,$topic,!topic:_*}",
                      "aggregator": "last"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "Partition Count"
                    }
                  ]
                }
              ],
              "autoscale": true,
              "precision": 0
            },
            "layout": {
              "x": 9,
              "y": 0,
              "width": 3,
              "height": 3
            }
          }
        ]
      }
    },
    {
      "definition": {
        "type": "group",
        "title": "Topic Traffic",
        "layout_type": "ordered",
        "show_title": true,
        "widgets": [
          {
            "definition": {
              "type": "timeseries",
              "title": "Topic Bytes In / Out",
              "requests": [
                {
                  "response_format": "timeseries",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "sum:automq_topic_network_io_bytes_total{$automq_env_id,$automq_instance_id,$cluster_id,$topic,direction:in} by {topic}.as_rate()"
                    },
                    {
                      "data_source": "metrics",
                      "name": "query2",
                      "query": "sum:automq_topic_network_io_bytes_total{$automq_env_id,$automq_instance_id,$cluster_id,$topic,direction:out} by {topic}.as_rate()"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "in",
                      "number_format": {
                        "unit": {
                          "type": "canonical_unit",
                          "unit_name": "byte",
                          "per_unit_name": "second"
                        }
                      }
                    },
                    {
                      "formula": "query2 * -1",
                      "alias": "out",
                      "number_format": {
                        "unit": {
                          "type": "canonical_unit",
                          "unit_name": "byte",
                          "per_unit_name": "second"
                        }
                      }
                    }
                  ]
                }
              ],
              "show_legend": true,
              "legend_layout": "horizontal",
              "legend_size": "auto",
              "legend_columns": [
                "min",
                "max",
                "avg",
                "value"
              ]
            },
            "layout": {
              "x": 0,
              "y": 0,
              "width": 6,
              "height": 4
            }
          },
          {
            "definition": {
              "type": "timeseries",
              "title": "Topic Request QPS",
              "requests": [
                {
                  "response_format": "timeseries",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "sum:automq_topic_request_count_total{$automq_env_id,$automq_instance_id,$cluster_id,$topic,type:produce} by {topic}.as_rate()"
                    },
                    {
                      "data_source": "metrics",
                      "name": "query2",
                      "query": "sum:automq_topic_request_count_total{$automq_env_id,$automq_instance_id,$cluster_id,$topic,type:fetch} by {topic}.as_rate()"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "produce",
                      "number_format": {
                        "unit": {
                          "type": "custom_unit_label",
                          "label": "req/s"
                        }
                      }
                    },
                    {
                      "formula": "query2 * -1",
                      "alias": "fetch",
                      "number_format": {
                        "unit": {
                          "type": "custom_unit_label",
                          "label": "req/s"
                        }
                      }
                    }
                  ]
                }
              ],
              "show_legend": true,
              "legend_layout": "horizontal",
              "legend_size": "auto",
              "legend_columns": [
                "min",
                "max",
                "avg",
                "value"
              ]
            },
            "layout": {
              "x": 6,
              "y": 0,
              "width": 6,
              "height": 4
            }
          },
          {
            "definition": {
              "type": "timeseries",
              "title": "Topic Messages In",
              "requests": [
                {
                  "response_format": "timeseries",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "sum:automq_topic_message_count_total{$automq_env_id,$automq_instance_id,$cluster_id,$topic,direction:in} by {topic}.as_rate()"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "Topic Messages In",
                      "number_format": {
                        "unit": {
                          "type": "custom_unit_label",
                          "label": "msg/s"
                        }
                      }
                    }
                  ]
                }
              ],
              "show_legend": true,
              "legend_layout": "horizontal",
              "legend_size": "auto",
              "legend_columns": [
                "min",
                "max",
                "avg",
                "value"
              ]
            },
            "layout": {
              "x": 0,
              "y": 4,
              "width": 6,
              "height": 4
            }
          },
          {
            "definition": {
              "type": "timeseries",
              "title": "Topic Size",
              "requests": [
                {
                  "response_format": "timeseries",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "sum:automq_topic_log_size{$automq_env_id,$automq_instance_id,$cluster_id,$topic} by {topic}"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "Topic Size",
                      "number_format": {
                        "unit": {
                          "type": "canonical_unit",
                          "unit_name": "byte"
                        }
                      }
                    }
                  ]
                }
              ],
              "show_legend": true,
              "legend_layout": "horizontal",
              "legend_size": "auto",
              "legend_columns": [
                "min",
                "max",
                "avg",
                "value"
              ]
            },
            "layout": {
              "x": 6,
              "y": 4,
              "width": 6,
              "height": 4
            }
          }
        ]
      }
    },
    {
      "definition": {
        "type": "group",
        "title": "Consume Statistics",
        "layout_type": "ordered",
        "show_title": true,
        "widgets": [
          {
            "definition": {
              "type": "query_table",
              "title": "Consume Statistics",
              "requests": [
                {
                  "response_format": "scalar",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "sum:automq_consumer_group_topic_commit_offset{$automq_env_id,$automq_instance_id,$cluster_id,$topic,consumer_group:*} by {topic,consumer_group}"
                    },
                    {
                      "data_source": "metrics",
                      "name": "query2",
                      "query": "sum:automq_group_topic_offset_lag{$automq_env_id,$automq_instance_id,$cluster_id,$topic,consumer_group:*} by {topic,consumer_group}"
                    },
                    {
                      "data_source": "metrics",
                      "name": "query3",
                      "query": "sum:automq_consumer_group_topic_commit_offset{$automq_env_id,$automq_instance_id,$cluster_id,$topic,consumer_group:*} by {topic,consumer_group}"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "per_second(query3)",
                      "alias": "Consume Throughput",
                      "number_format": {
                        "unit": {
                          "type": "custom_unit_label",
                          "label": "msg/s"
                        }
                      }
                    },
                    {
                      "formula": "query2",
                      "alias": "Consumer Lag"
                    }
                  ]
                }
              ]
            },
            "layout": {
              "x": 0,
              "y": 0,
              "width": 12,
              "height": 8
            }
          }
        ]
      }
    },
    {
      "definition": {
        "type": "group",
        "title": "Partition and Table Metrics",
        "layout_type": "ordered",
        "show_title": true,
        "widgets": [
          {
            "definition": {
              "type": "timeseries",
              "title": "Topic Partition Count Per Rack",
              "requests": [
                {
                  "response_format": "timeseries",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "sum:automq_topic_rack_partition_count{$automq_env_id,$automq_instance_id,$cluster_id,$topic} by {rack,topic}"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "Rack"
                    }
                  ]
                }
              ],
              "show_legend": true,
              "legend_layout": "horizontal",
              "legend_size": "auto",
              "legend_columns": [
                "value"
              ]
            },
            "layout": {
              "x": 0,
              "y": 0,
              "width": 6,
              "height": 5
            }
          },
          {
            "definition": {
              "type": "timeseries",
              "title": "Table Fields Per Seconds",
              "requests": [
                {
                  "response_format": "timeseries",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "avg:kafka_tabletopic_fps_fields_per_second{$automq_env_id,$automq_instance_id,$cluster_id,$topic}"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "Table Fields Per Seconds",
                      "number_format": {
                        "unit": {
                          "type": "custom_unit_label",
                          "label": "req/s"
                        }
                      }
                    }
                  ]
                }
              ],
              "show_legend": true,
              "legend_layout": "horizontal",
              "legend_size": "auto",
              "legend_columns": [
                "min",
                "max",
                "avg"
              ]
            },
            "layout": {
              "x": 0,
              "y": 5,
              "width": 6,
              "height": 5
            }
          },
          {
            "definition": {
              "type": "timeseries",
              "title": "Table Watermark",
              "requests": [
                {
                  "response_format": "timeseries",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "avg:kafka_tabletopic_delay_milliseconds{$automq_env_id,$automq_instance_id,$cluster_id,$topic}"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "Table Watermark",
                      "number_format": {
                        "unit": {
                          "type": "canonical_unit",
                          "unit_name": "millisecond"
                        }
                      }
                    }
                  ]
                }
              ],
              "show_legend": true,
              "legend_layout": "horizontal",
              "legend_size": "auto",
              "legend_columns": [
                "min",
                "max",
                "avg"
              ]
            },
            "layout": {
              "x": 6,
              "y": 5,
              "width": 6,
              "height": 5
            }
          }
        ]
      }
    }
  ]
}
