From 9dcc2b87189c1a4d7a6142922c6fd873e385c189 Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Mon, 21 Oct 2019 16:01:55 +0200 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20Allow=20selectively=20turn=20off=20p?= =?UTF-8?q?rometheus=20metrics=20and/or=20stats=E2=80=A6=20(#1532)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: Allow selectively turn off prometheus metrics and/or stats poller --- plugins/telemetry/config.go | 2 ++ plugins/telemetry/telemetry.conf | 3 ++ plugins/telemetry/telemetry.go | 54 +++++++++++++++++++------------- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/plugins/telemetry/config.go b/plugins/telemetry/config.go index f3796e51f9..0d98cac146 100644 --- a/plugins/telemetry/config.go +++ b/plugins/telemetry/config.go @@ -29,6 +29,8 @@ type Config struct { PollingInterval time.Duration `json:"polling-interval"` // Allows to disable plugin Disabled bool `json:"disabled"` + // Allows to export prometheus in telemetry plugin + PrometheusDisabled bool `json:"prometheus-disabled"` // Skip collecting some of the metrics: // runtime, memory, buffers, nodes, interfaces Skipped []string `json:"skipped"` diff --git a/plugins/telemetry/telemetry.conf b/plugins/telemetry/telemetry.conf index 3a05580371..ed0fc86ef8 100644 --- a/plugins/telemetry/telemetry.conf +++ b/plugins/telemetry/telemetry.conf @@ -4,6 +4,9 @@ polling-interval: 30000000000 # If set to true, telemetry plugin is disabled. disabled: false +# If set to true, prometheus in telemetry plugin is disabled. +prometheus-disabled: false + # Skip collecting some of the metrics. # runtime, memory, buffers, nodes, interfaces #skipped: [nodes] diff --git a/plugins/telemetry/telemetry.go b/plugins/telemetry/telemetry.go index 45e1f6e404..3973767429 100644 --- a/plugins/telemetry/telemetry.go +++ b/plugins/telemetry/telemetry.go @@ -49,9 +49,10 @@ type Plugin struct { prometheusMetrics // From config file - updatePeriod time.Duration - disabled bool - skipped map[string]bool + updatePeriod time.Duration + disabled bool + prometheusDisabled bool + skipped map[string]bool wg sync.WaitGroup quit chan struct{} @@ -83,29 +84,38 @@ func (p *Plugin) Init() error { p.disabled = true return nil } - // This prevents setting the update period to less than 5 seconds, - // which can have significant performance hit. - if config.PollingInterval > minimumUpdatePeriod { - p.updatePeriod = config.PollingInterval - p.Log.Infof("polling period changed to %v", p.updatePeriod) - } else if config.PollingInterval > 0 { - p.Log.Warnf("polling period has to be at least %s, using default: %v", - minimumUpdatePeriod, defaultUpdatePeriod) + // Disable prometheus metrics if set by config + if config.PrometheusDisabled { + p.Log.Info("Prometheus metrics disabled via config file") + p.prometheusDisabled = true + } else { + // This prevents setting the update period to less than 5 seconds, + // which can have significant performance hit. + if config.PollingInterval > minimumUpdatePeriod { + p.updatePeriod = config.PollingInterval + p.Log.Infof("polling period changed to %v", p.updatePeriod) + } else if config.PollingInterval > 0 { + p.Log.Warnf("polling period has to be at least %s, using default: %v", + minimumUpdatePeriod, defaultUpdatePeriod) + } + // Store map of skipped metrics + for _, skip := range config.Skipped { + p.skipped[skip] = true + } } - // Store map of skipped metrics - for _, skip := range config.Skipped { - p.skipped[skip] = true - } - } - // This serves as fallback if the config was not found or if the value is not set in config. - if p.updatePeriod == 0 { - p.updatePeriod = defaultUpdatePeriod } - if err := p.registerPrometheus(); err != nil { - return err + // Register prometheus + if !p.prometheusDisabled { + if p.updatePeriod == 0 { + p.updatePeriod = defaultUpdatePeriod + } + if err := p.registerPrometheus(); err != nil { + return err + } } + // Setup stats poller p.statsPollerServer.log = p.Log.NewLogger("stats-poller") if err := p.setupStatsPoller(); err != nil { return err @@ -117,7 +127,7 @@ func (p *Plugin) Init() error { // AfterInit executes after initializion of Telemetry Plugin func (p *Plugin) AfterInit() error { // Do not start polling if telemetry is disabled - if p.disabled { + if p.disabled || p.prometheusDisabled { return nil } From 851b39657a2791e6ff66f95bc7350adf272dae7e Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Mon, 21 Oct 2019 17:53:21 +0200 Subject: [PATCH 2/2] chore: Update CHANGELOG for release 2.4.0 Signed-off-by: Ondrej Fabry --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0f99dfcf5..16d515e2f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ ## Release Notes +- [v2.4.0](#v2.4.0) - [v2.3.0](#v2.3.0) - - [v2.3.1](#v2.3.1) - [v2.2.0](#v2.2.0) - [v2.2.0-beta](#v2.2.0-beta) - [v2.1.0](#v2.1.0) @@ -47,8 +47,8 @@ RELEASE CHANGELOG TEMPLATE: ### Documentation --> - -# [2.3.1](https://github.com/ligato/vpp-agent/compare/v2.3.0...v2.3.1) (2019-10-18) + +# [2.3.1](https://github.com/ligato/vpp-agent/compare/v2.3.0...v2.4.0) (2019-10-21) - **VPP 20.01-379** (`20.01-rc0~379-ga6b93eac5`) - **VPP 20.01-324** (`20.01-rc0~324-g66a332cf1`) - **VPP 19.08.1** (default) @@ -56,7 +56,7 @@ RELEASE CHANGELOG TEMPLATE: - cn-infra v2.2 ### New Features -This minor release introduces compatibility with two different commits of the VPP 20.01. Previously compatible version was updated to commit `324-g66a332cf1`, and support for `379-ga6b93eac5` was added. Other previous versions remained. +This release introduces compatibility with two different commits of the VPP 20.01. Previously compatible version was updated to commit `324-g66a332cf1`, and support for `379-ga6b93eac5` was added. Other previous versions remained. * [Telemetry][vpp-telemetry] - Added `StatsPoller` service periodically retrieving VPP stats.