Skip to content

Commit

Permalink
GROUNDWORK-2556 k8s: mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavlo Sumkin committed Oct 11, 2023
1 parent 08f3935 commit 3dbd724
Show file tree
Hide file tree
Showing 6 changed files with 439 additions and 83 deletions.
12 changes: 6 additions & 6 deletions connectors/events-connector/helpers/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ func ParsePrometheusData(data template.Data, cfg *ExtConfig) ([]ParseResult, err
tags[k] = v
}

hostGroupName, err := cfg.HostGroupMappings.Apply(tags)
hostGroupName, err := cfg.MapHostgroup.ApplyOR(tags)
if err != nil {
log.Debug().Err(err).Interface("tags", tags).Send()
log.Debug().Err(err).Interface("tags", tags).Interface("mappings", cfg.MapHostgroup).Send()
continue
}
hostName, err := cfg.HostMappings.Apply(tags)
hostName, err := cfg.MapHostname.ApplyOR(tags)
if err != nil || hostName == "" {
log.Debug().Err(err).Interface("tags", tags).Send()
log.Debug().Err(err).Interface("tags", tags).Interface("mappings", cfg.MapHostname).Send()
continue
}
serviceName, err := cfg.ServiceMappings.Apply(tags)
serviceName, err := cfg.MapService.ApplyOR(tags)
if err != nil || serviceName == "" {
log.Debug().Err(err).Interface("tags", tags).Send()
log.Debug().Err(err).Interface("tags", tags).Interface("mappings", cfg.MapService).Send()
continue
}

Expand Down
16 changes: 8 additions & 8 deletions connectors/events-connector/helpers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ var (
)

type ExtConfig struct {
HostMappings mapping.Mappings `json:"hostMappings"`
HostGroupMappings mapping.Mappings `json:"hostGroupMappings"`
ServiceMappings mapping.Mappings `json:"serviceMappings"`
MapHostgroup mapping.Mappings `json:"mapHostgroup"`
MapHostname mapping.Mappings `json:"mapHostname"`
MapService mapping.Mappings `json:"mapService"`
}

func GetExtConfig() *ExtConfig {
Expand Down Expand Up @@ -54,15 +54,15 @@ func ConfigHandler(data []byte) {
}
/* Update config with received values */
extConfig, metricsProfile, monitorConnection = tExt, tMetProf, tMonConn
if err := extConfig.HostMappings.Compile(); err != nil {
log.Err(err).Msg("failed to compile host mappings")
if err := extConfig.MapHostgroup.Compile(); err != nil {
log.Err(err).Msg("failed to compile host group mappings")
return
}
if err := extConfig.HostGroupMappings.Compile(); err != nil {
log.Err(err).Msg("failed to compile host group mappings")
if err := extConfig.MapHostname.Compile(); err != nil {
log.Err(err).Msg("failed to compile host mappings")
return
}
if err := extConfig.ServiceMappings.Compile(); err != nil {
if err := extConfig.MapService.Compile(); err != nil {
log.Err(err).Msg("failed to compile service mappings")
return
}
Expand Down
Loading

0 comments on commit 3dbd724

Please sign in to comment.