Skip to content

Commit

Permalink
Fix crash when metrics settings are unset (#537)
Browse files Browse the repository at this point in the history
It's panic'ing with:
panic: runtime error: invalid memory address or nil pointer dereference

Due to ConnectionInfo being a pointer
  • Loading branch information
jotak authored Nov 16, 2023
1 parent a9fc9ce commit 7c78d63
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/confgen/flowlogs2metrics_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (cg *ConfGen) GenerateFlowlogs2PipelineConfig() *config.ConfigFileStruct {
Pipeline: pipeline.GetStages(),
Parameters: pipeline.GetStageParams(),
MetricsSettings: config.MetricsSettings{
PromConnectionInfo: &api.PromConnectionInfo{Port: 9102},
PromConnectionInfo: api.PromConnectionInfo{Port: 9102},
Prefix: "flp_op_",
},
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type Profile struct {
// Also, currently FLP doesn't support defining more than one PromEncode stage. If this feature is added later, these global settings
// will help configuring common setting for all PromEncode stages - PromEncode settings would then act as overrides.
type MetricsSettings struct {
*api.PromConnectionInfo
api.PromConnectionInfo
Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty" doc:"prefix for names of the operational metrics"`
NoPanic bool `yaml:"noPanic,omitempty" json:"noPanic,omitempty"`
SuppressGoMetrics bool `yaml:"suppressGoMetrics,omitempty" json:"suppressGoMetrics,omitempty" doc:"filter out Go and process metrics"`
Expand Down Expand Up @@ -154,7 +154,7 @@ func ParseConfig(opts Options) (ConfigFileStruct, error) {
}
logrus.Debugf("metrics settings = %v ", out.MetricsSettings)
} else {
logrus.Errorf("metrics settings missing")
logrus.Infof("using default metrics settings")
}

return out, nil
Expand Down

0 comments on commit 7c78d63

Please sign in to comment.