Skip to content

Commit 665de17

Browse files
authored
add config parameter to suppress go metrics (#394)
* suppress Go metrics and document metrics settings * changed metrics-settings back to metricsSettings
1 parent 9ad743f commit 665de17

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,6 @@ parameters:
757757
encode:
758758
type: prom
759759
prom:
760-
address: 0.0.0.0
761-
port: 9103
762760
prefix: test_
763761
metrics:
764762
- name: Bytes
@@ -852,6 +850,25 @@ The object header contains the following fields: `version`, `capture_start_time`
852850
If no flow logs arrive within the `writeTimeout` period, then an object is created with no flows.
853851
An object is created either when we have accumulated `batchSize` flow logs or when `writeTimeout` has passed.
854852

853+
### Metrics Settings
854+
855+
Some global metrics settings may be set in the configuration file.
856+
A sample is the following:
857+
858+
```
859+
metricsSettings:
860+
suppressGoMetrics: true
861+
prefix: flp_operational_
862+
port: 9102
863+
864+
```
865+
866+
FLP metrics are reported to a prometheus client interface.
867+
In addition, there are default metrics reported by `Go`, which are also directed to the prometheus client interface.
868+
The port to which these metrics are made available is specified in the `port` configuration parameter.
869+
If a `prefix` is specified, then the specified prefix is prepended to each of the operational metrics generated by FLP.
870+
A different `prefix` may be specified on an `encode prom` stage to be prepended to the prometheus metrics defined in that stage.
871+
The `suppressGoMetrics` parameter may be set to `true` in order to suppress the reporting of the `Go` and process metrics in the prometheus client interface.
855872

856873
# Development
857874

cmd/flowlogs-pipeline/main.go

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/netobserv/flowlogs-pipeline/pkg/operational"
3636
"github.com/netobserv/flowlogs-pipeline/pkg/pipeline"
3737
"github.com/netobserv/flowlogs-pipeline/pkg/pipeline/utils"
38+
"github.com/prometheus/client_golang/prometheus"
3839
log "github.com/sirupsen/logrus"
3940
"github.com/spf13/cobra"
4041
"github.com/spf13/pflag"
@@ -179,6 +180,13 @@ func run() {
179180
// Setup (threads) exit manager
180181
utils.SetupElegantExit()
181182

183+
// set up private prometheus registry
184+
if cfg.MetricsSettings.SuppressGoMetrics {
185+
reg := prometheus.NewRegistry()
186+
prometheus.DefaultRegisterer = reg
187+
prometheus.DefaultGatherer = reg
188+
}
189+
182190
// create prometheus server for operational metrics
183191
// if value of address is empty, then by default it will take 0.0.0.0
184192
addr := fmt.Sprintf("%s:%v", cfg.MetricsSettings.Address, cfg.MetricsSettings.Port)

pkg/config/config.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ type Profile struct {
5555
// Also, currently FLP doesn't support defining more than one PromEncode stage. If this feature is added later, these global settings
5656
// will help configuring common setting for all PromEncode stages - PromEncode settings would then act as overrides.
5757
type MetricsSettings struct {
58-
Address string `yaml:"address,omitempty" json:"address,omitempty" doc:"address to expose \"/metrics\" endpoint"`
59-
Port int `yaml:"port,omitempty" json:"port,omitempty" doc:"port number to expose \"/metrics\" endpoint"`
60-
TLS *api.PromTLSConf `yaml:"tls,omitempty" json:"tls,omitempty" doc:"TLS configuration for the prometheus endpoint"`
61-
Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty"`
62-
NoPanic bool `yaml:"noPanic,omitempty" json:"noPanic,omitempty"`
58+
Address string `yaml:"address,omitempty" json:"address,omitempty" doc:"address to expose \"/metrics\" endpoint"`
59+
Port int `yaml:"port,omitempty" json:"port,omitempty" doc:"port number to expose \"/metrics\" endpoint"`
60+
TLS *api.PromTLSConf `yaml:"tls,omitempty" json:"tls,omitempty" doc:"TLS configuration for the prometheus endpoint"`
61+
Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty" doc:"prefix for names of the operational metrics"`
62+
NoPanic bool `yaml:"noPanic,omitempty" json:"noPanic,omitempty"`
63+
SuppressGoMetrics bool `yaml:"suppressGoMetrics,omitempty" json:"suppressGoMetrics,omitempty" doc:"filter out Go and process metrics"`
6364
}
6465

6566
// PerfSettings allows setting some internal configuration parameters

0 commit comments

Comments
 (0)