Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Make metrictank/publish/kafka instantiable with parameters #1938

Closed
D3luxee opened this issue Nov 3, 2020 · 2 comments
Closed

Make metrictank/publish/kafka instantiable with parameters #1938

D3luxee opened this issue Nov 3, 2020 · 2 comments

Comments

@D3luxee
Copy link
Contributor

D3luxee commented Nov 3, 2020

Hi @Dieterbe ,
i've started to look into grafana/carbon-relay-ng#442 and the first issue i've found was that the publisher is configured via flags.
carbon-relay-ng has to instantiate multiple instances of the publisher (one per route) with different configs, since flags are globally this is no option here.

I would suggest to implement a second "New" function which allows passing the parameters:

func NewWithOptions(brokers []string, topic, codecOption, partitionSchemes, schemaFile, kafkaVersionString string, onlyOrgIdsOption []int64, flushFrequency, clearInterval time.Duration, producerMaxMessages int, useV2, encodeOrgID, autoInterval bool) *mtPublisher {
	enabled = true                         // enable metric publishing
	topicsStr = topic                      // set topic
	onlyOrgIds = onlyOrgIdsOption          // restrict publishing data belonging to org id; 0 means no restriction (may be given multiple times, once per topic specified in 'metrics-topic', as a comma-separated list)
	codec = codecOption                    // "compression: none|gzip|snappy"
	partitionSchemesStr = partitionSchemes // method used for partitioning metrics. (byOrg|bySeries|bySeriesWithTags|bySeriesWithTagsFnv) (may be given multiple times, once per topic, as a comma-separated list)
	flushFreq = flushFrequency             // The best-effort frequency of flushes to kafka
	maxMessages = producerMaxMessages      // The maximum number of messages the producer will send in a single request
	schemasConf = schemaFile               // path to carbon storage-schemas.conf file
	v2 = useV2                             // enable optimized MetricPoint payload
	v2Org = encodeOrgID                    // encode org-id in messages
	v2ClearInterval = clearInterval        // interval after which we always resend a full MetricData
	kafkaVersionStr = kafkaVersionString   // Kafka version in semver format. All brokers must be this version or newer.
	return New(brokers, autoInterval)
}

https://github.com/grafana/metrictank/blob/master/publish/kafka/publish.go

What is your opinion on this?

@D3luxee D3luxee added the feature label Nov 3, 2020
@Dieterbe
Copy link
Contributor

Dieterbe commented Nov 4, 2020

have a look at some of the other plugins, for example store/cassandra/config.go. note how it has a config struct, you can create a cliconfig and register flags on it, but also build a config however you like (e.g. externally)

@stale
Copy link

stale bot commented Feb 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 2, 2021
@stale stale bot closed this as completed Feb 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants