Skip to content

Report the admin API error when collecting group lags - #349

Open
omlahore wants to merge 1 commit into
redpanda-data:masterfrom
omlahore:fix/admin-api-offsets-error
Open

Report the admin API error when collecting group lags#349
omlahore wants to merge 1 commit into
redpanda-data:masterfrom
omlahore:fix/admin-api-offsets-error

Conversation

@omlahore

Copy link
Copy Markdown

collectConsumerGroupLagsAdminAPI drops the error from ListAllConsumerGroupOffsetsAdminAPI:

groupOffsets, err := e.minionSvc.ListAllConsumerGroupOffsetsAdminAPI(ctx)
for groupName, offsetRes := range groupOffsets {

ListAllConsumerGroupOffsetsAdminAPI returns nil, fmt.Errorf("failed to list groupsRes: %w", err) when listConsumerGroupsCached fails (minion/consumer_group_offsets.go:22). Ranging over that nil map is a no-op, so the function falls through to return isOk with isOk still true.

The effect is that a failed admin call is reported as a successful scrape that happens to contain no consumer group lag metrics, rather than as a failure. For an exporter that is the wrong way round: alerts built on kafka_consumergroup_group_lag stop firing instead of the scrape going unhealthy.

err is also reassigned a few lines down inside the loop (err = kerr.ErrorForCode(...)), so the original value could not have been checked later even in principle. staticcheck flags it as SA4006.

The fix follows the shape already used in collect_broker_info.go:12: log with zap.Error and return false.

Verified: go build ./... passes, gofmt -l clean, and SA4006 is gone under both GOOS=linux and GOOS=darwin. prometheus/ has no test files, so there was nothing to extend.

collectConsumerGroupLagsAdminAPI ignored the error from
ListAllConsumerGroupOffsetsAdminAPI, which returns a nil map alongside
it. The range over that nil map is a no-op, so a failed admin call
returned isOk true and simply emitted no consumer group lag metrics
rather than reporting the failure.

err was also reassigned inside the loop, so the original value could not
have been checked later.

Follows the same shape as collect_broker_info.go: log with zap.Error and
return false.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant