Skip to content

Commit

Permalink
Add changelog entry, return early when only one kafka instance is set
Browse files Browse the repository at this point in the history
Signed-off-by: Paschalis Tsilias <[email protected]>
  • Loading branch information
tpaschalis committed Jan 10, 2024
1 parent 6d10b2a commit d6598c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Main (unreleased)
- Fix an issue in `remote.s3` where the exported content of an object would be an empty string if `remote.s3` failed to fully retrieve
the file in a single read call. (@grafana/agent-squad)

- Utilize the `instance` Argument of `prometheus.exporter.kafka` when set. (@akhmatov-s)

### Other changes

- Removed support for Windows 2012 in line with Microsoft end of life. (@mattdurham)
Expand Down
6 changes: 5 additions & 1 deletion pkg/integrations/kafka_exporter/kafka_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,19 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
func (c *Config) Name() string {
return "kafka_exporter"
}

// InstanceKey returns the hostname:port of the first Kafka node, if any. If
// there is not exactly one Kafka node, the user must manually provide
// their own value for instance key in the common config.
func (c *Config) InstanceKey(agentKey string) (string, error) {
if len(c.KafkaURIs) == 1 {
return c.KafkaURIs[0], nil
}
if c.Instance == "" && len(c.KafkaURIs) > 1 {
return "", fmt.Errorf("an automatic value for `instance` cannot be determined from %d kafka servers, manually provide one for this integration", len(c.KafkaURIs))
}

return c.KafkaURIs[0], nil
return c.Instance, nil
}

// NewIntegration creates a new elasticsearch_exporter
Expand Down

0 comments on commit d6598c1

Please sign in to comment.