0

我需要一些帮助来查找所有主题的消息总数。

下面的文档有超过百万个主题、分区和偏移量。

我需要获得偏移总数:

"kafka": {
  "partition": {
    "topic": {
      "name": "testTopic20181206"
    },
    "broker": {
      "id": 4,
      "address": "localhost:9092"
    },
    "partition": {
      "insync_replica": true,
      "id": 0,
      "leader": 3,
      "replica": 1
    },
    "offset": {
      "newest": 17330676,
      "oldest": 0
   }
  }

我正在使用的查询是:

  GET metricbeat-6*/_search
  {
    "size": 0,
    "aggs": {
      "Topic": {
        "terms": {
          "field": "kafka.partition.topic.name",
          "size": 10000
        },
        "aggregations": {
          "Partition": {
            "terms": {
              "field": "kafka.partition.partition.id"
            },
            "aggregations": {
            "Partition": {
              "max": {
                "field": "kafka.partition.offset.newest"
              }
            }
            }

          }
        }
      }
  }

}

4

0 回答 0