Skip to content
New issue

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

Remove fluent-style kingpin #1186

Merged
merged 1 commit into from
Apr 17, 2023

Conversation

jkroepke
Copy link
Member

This PR remove the fluent-style usage of kingpin by an dedicated instance of kingpin. This allow programs to embed windows_exporter and pass a customized kingpin instance to all collectors.

At the moment, its hard to embedded windows_exporter in an other application. While its possible to feed the kingpin.CommandLine instance outside from windows_exporter, there are conflicts with other exporters do the same.

PR tested in a Windows 10 client machine.

Example Code for injected collector configuration into the embedded windows_exporter instance:

// toExporterConfig converts integration Configs into windows_exporter configs.
func (c *Config) toExporterConfig(app *kingpin.Application) {
	app.GetFlag(collector.FlagDfsrEnabledCollectors).StringVar(&c.Dfsr.SourcesEnabled)
	app.GetFlag(collector.FlagExchangeCollectorsEnabled).StringVar(&c.Exchange.EnabledList)
	app.GetFlag(collector.FlagISSSiteBlacklist).StringVar(&c.IIS.SiteBlackList)
	app.GetFlag(collector.FlagISSSiteWhitelist).StringVar(&c.IIS.SiteWhiteList)
	app.GetFlag(collector.FlagISSAppBlacklist).StringVar(&c.IIS.AppBlackList)
	app.GetFlag(collector.FlagISSAppWhitelist).StringVar(&c.IIS.AppWhiteList)
	app.GetFlag(collector.FlagLogicalDiskVolumeBlacklist).StringVar(&c.LogicalDisk.BlackList)
	app.GetFlag(collector.FlagLogicalDiskVolumeWhitelist).StringVar(&c.LogicalDisk.WhiteList)
	app.GetFlag(collector.FlagMsmqWhereClause).StringVar(&c.MSMQ.Where)
	app.GetFlag(collector.FlagMssqlEnabledCollectors).StringVar(&c.MSSQL.EnabledClasses)
	app.GetFlag(collector.FlagNicBlacklist).StringVar(&c.Network.BlackList)
	app.GetFlag(collector.FlagNicWhitelist).StringVar(&c.Network.WhiteList)
	app.GetFlag(collector.FlagProcessBlacklist).StringVar(&c.Process.BlackList)
	app.GetFlag(collector.FlagProcessWhitelist).StringVar(&c.Process.WhiteList)
	app.GetFlag(collector.FlagScheduledTaskBlacklist).StringVar(&c.Process.BlackList)
	app.GetFlag(collector.FlagScheduledTaskWhitelist).StringVar(&c.Process.WhiteList)
	app.GetFlag(collector.FlagServiceWhereClause).StringVar(&c.Service.Where)
	app.GetFlag(collector.FlagServiceUseAPI).StringVar(&c.Service.UseApi)
	app.GetFlag(collector.FlagSmtpServerBlacklist).StringVar(&c.SMTP.BlackList)
	app.GetFlag(collector.FlagNicWhitelist).StringVar(&c.SMTP.WhiteList)
	app.GetFlag(collector.FlagTextFileDirectory).StringVar(&c.TextFile.TextFileDirectory)
}

@jkroepke jkroepke requested a review from a team as a code owner April 17, 2023 11:22
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
Copy link
Contributor

@breed808 breed808 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for submitting this! I really like the code changes in this PR, it's very tidy and easy to follow 👍

@breed808 breed808 merged commit 3627520 into prometheus-community:master Apr 17, 2023
5 checks passed
@jkroepke jkroepke deleted the custom-kingpin branch April 18, 2023 06:13
@jkroepke
Copy link
Member Author

That was fast! Thanks a lot @breed808 for merging this.

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.

None yet

2 participants