We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There are five states, which you can see in kafka's source code. The details are:
Use different numbers to represent the state, such as:
0:Empty 1:Stable 2:PreparingRebalance 3:CompletingRebalance 4:Dead
The code to obtain the status can be referred to:
package main import ( "fmt" "log" "github.com/IBM/sarama" ) func main() { // Kafka broker list brokers := []string{"10.100.1.1:9092"} // Create a new Sarama config config := sarama.NewConfig() config.Version = sarama.V2_0_0_0 // Create a new Sarama admin client admin, err := sarama.NewClusterAdmin(brokers, config) if err != nil { log.Fatalf("Error creating cluster admin: %v", err) } defer admin.Close() // Get all Consumer Groups groups, err := admin.ListConsumerGroups() if err != nil { log.Printf("Error listing consumer groups: %v", err) return } for group := range groups { // describe consumer group description, err := admin.DescribeConsumerGroups([]string{group}) if err != nil { log.Printf("Error describing consumer group %s: %v", group, err) continue } for _, desc := range description { var stateValue float64 switch desc.State { case "Stable": stateValue = 1 case "PreparingRebalance": stateValue = 2 case "CompletingRebalance": stateValue = 3 case "Dead": stateValue = 4 default: stateValue = 0 } fmt.Printf("Consumer Group: %s, State: %s, State Value: %f\n", group, desc.State, stateValue) } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
There are five states, which you can see in kafka's source code. The details are:
Use different numbers to represent the state, such as:
The code to obtain the status can be referred to:
The text was updated successfully, but these errors were encountered: