{
  "title": "Group Metrics",
  "description": "Generated from AutoMQ opsbox Grafana dashboard group-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 group-metrics-free-bak.json.",
  "notify_list": null,
  "layout_type": "ordered",
  "template_variables": [
    {
      "name": "cluster_id",
      "prefix": "service",
      "default": "*"
    },
    {
      "name": "group_id",
      "prefix": "group",
      "default": "*"
    },
    {
      "name": "consumer_group_id",
      "prefix": "consumer_group",
      "default": "*"
    },
    {
      "name": "topic",
      "prefix": "topic",
      "default": "*"
    },
    {
      "name": "automq_env_id",
      "prefix": "env_id",
      "default": "*"
    },
    {
      "name": "automq_instance_id",
      "prefix": "instance_id",
      "default": "*"
    }
  ],
  "reflow_type": "fixed",
  "widgets": [
    {
      "definition": {
        "type": "group",
        "title": "Group Statistics",
        "layout_type": "ordered",
        "show_title": true,
        "widgets": [
          {
            "definition": {
              "type": "query_table",
              "title": "Group 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,$group_id,$topic,group:*} by {group,topic}"
                    },
                    {
                      "data_source": "metrics",
                      "name": "query2",
                      "query": "sum:automq_group_topic_offset_lag{$automq_env_id,$automq_instance_id,$cluster_id,$group_id,$topic,group:*} by {group,topic}"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "per_second(query1)",
                      "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": 6
            }
          }
        ]
      }
    },
    {
      "definition": {
        "type": "group",
        "title": "Consumer Lag and Throughput",
        "layout_type": "ordered",
        "show_title": true,
        "widgets": [
          {
            "definition": {
              "type": "timeseries",
              "title": "Consumer Throughput",
              "requests": [
                {
                  "response_format": "timeseries",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "per_second(sum:automq_consumer_group_topic_commit_offset{$automq_env_id,$automq_instance_id,$cluster_id,$consumer_group_id,$topic} by {consumer_group,topic})"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "Consumer Throughput",
                      "number_format": {
                        "unit": {
                          "type": "custom_unit_label",
                          "label": "msg/s"
                        }
                      }
                    }
                  ]
                }
              ],
              "show_legend": true,
              "legend_layout": "horizontal",
              "legend_size": "auto",
              "legend_columns": [
                "min",
                "max",
                "avg"
              ]
            },
            "layout": {
              "x": 0,
              "y": 0,
              "width": 4,
              "height": 4
            }
          },
          {
            "definition": {
              "type": "timeseries",
              "title": "Consumer Lag",
              "requests": [
                {
                  "response_format": "timeseries",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "sum:automq_group_topic_offset_lag{$automq_env_id,$automq_instance_id,$cluster_id,$group_id,$topic} by {group,topic}"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "Consumer Lag"
                    }
                  ]
                }
              ],
              "show_legend": true,
              "legend_layout": "horizontal",
              "legend_size": "auto",
              "legend_columns": [
                "min",
                "max",
                "value"
              ]
            },
            "layout": {
              "x": 4,
              "y": 0,
              "width": 4,
              "height": 4
            }
          },
          {
            "definition": {
              "type": "timeseries",
              "title": "Consumer Estimated Time Lag",
              "requests": [
                {
                  "response_format": "timeseries",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "max:automq_group_topic_estimated_time_lag_milliseconds{$automq_env_id,$automq_instance_id,$cluster_id,$group_id,$topic} by {group,topic}"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "Consumer Estimated Time Lag",
                      "number_format": {
                        "unit": {
                          "type": "canonical_unit",
                          "unit_name": "millisecond"
                        }
                      }
                    }
                  ]
                }
              ],
              "show_legend": true,
              "legend_layout": "horizontal",
              "legend_size": "auto",
              "legend_columns": [
                "min",
                "max",
                "value"
              ]
            },
            "layout": {
              "x": 8,
              "y": 0,
              "width": 4,
              "height": 4
            }
          }
        ]
      }
    },
    {
      "definition": {
        "type": "group",
        "title": "Group Status",
        "layout_type": "ordered",
        "show_title": true,
        "widgets": [
          {
            "definition": {
              "type": "timeseries",
              "title": "Status",
              "requests": [
                {
                  "response_format": "timeseries",
                  "queries": [
                    {
                      "data_source": "metrics",
                      "name": "query1",
                      "query": "sum:automq_group_count{$automq_env_id,$automq_instance_id,$cluster_id}"
                    },
                    {
                      "data_source": "metrics",
                      "name": "query2",
                      "query": "sum:automq_group_stable_count{$automq_env_id,$automq_instance_id,$cluster_id}"
                    },
                    {
                      "data_source": "metrics",
                      "name": "query3",
                      "query": "sum:automq_group_empty_count{$automq_env_id,$automq_instance_id,$cluster_id}"
                    },
                    {
                      "data_source": "metrics",
                      "name": "query4",
                      "query": "sum:automq_group_dead_count{$automq_env_id,$automq_instance_id,$cluster_id}"
                    },
                    {
                      "data_source": "metrics",
                      "name": "query5",
                      "query": "sum:automq_group_preparing_rebalance_count{$automq_env_id,$automq_instance_id,$cluster_id}"
                    },
                    {
                      "data_source": "metrics",
                      "name": "query6",
                      "query": "sum:automq_group_completing_rebalance_count{$automq_env_id,$automq_instance_id,$cluster_id}"
                    }
                  ],
                  "formulas": [
                    {
                      "formula": "query1",
                      "alias": "Total Groups"
                    },
                    {
                      "formula": "query2",
                      "alias": "Stable Groups"
                    },
                    {
                      "formula": "query3",
                      "alias": "Empty Groups"
                    },
                    {
                      "formula": "query4",
                      "alias": "Dead Groups"
                    },
                    {
                      "formula": "query5",
                      "alias": "Preparing Rebalance Groups"
                    },
                    {
                      "formula": "query6",
                      "alias": "Completing Rebalance Groups"
                    }
                  ]
                }
              ],
              "show_legend": true,
              "legend_layout": "horizontal",
              "legend_size": "auto",
              "legend_columns": [
                "value"
              ]
            },
            "layout": {
              "x": 0,
              "y": 0,
              "width": 8,
              "height": 4
            }
          }
        ]
      }
    }
  ]
}
