diff --git a/internal/config/fetch.go b/internal/config/fetch.go index 24a6aa19..586d18ea 100644 --- a/internal/config/fetch.go +++ b/internal/config/fetch.go @@ -136,7 +136,9 @@ func FetchLookups(cfg *load.Config, i int) bool { loopNo := -1 combinations := [][]string{} - loopLookups(loopNo, sliceIndexes, sliceKeys, sliceLookups, &combinations) + if len(sliceLookups) > 0 { + loopLookups(loopNo, sliceIndexes, sliceKeys, sliceLookups, &combinations) + } load.Logrus.WithFields(logrus.Fields{ "name": cfg.Name, @@ -145,10 +147,16 @@ func FetchLookups(cfg *load.Config, i int) bool { newAPIs := []string{} for _, combo := range combinations { tmpConfigWithLookupReplace := tmpCfgStr - for i, key := range lookupDimensions { - tmpConfigWithLookupReplace = strings.ReplaceAll(tmpConfigWithLookupReplace, fmt.Sprintf("${lookup:%v}", key), combo[i]) + if len(combo) == len(lookupDimensions) { + for i, key := range lookupDimensions { + tmpConfigWithLookupReplace = strings.ReplaceAll(tmpConfigWithLookupReplace, fmt.Sprintf("${lookup:%v}", key), combo[i]) + } + newAPIs = append(newAPIs, tmpConfigWithLookupReplace) + } else { + load.Logrus.WithFields(logrus.Fields{ + "name": cfg.Name, + }).Debug("fetch: invalid lookup, missing a replace") } - newAPIs = append(newAPIs, tmpConfigWithLookupReplace) } lookupConfig := load.Config{ diff --git a/internal/load/load.go b/internal/load/load.go index 6723e933..ffb17e3a 100644 --- a/internal/load/load.go +++ b/internal/load/load.go @@ -296,6 +296,7 @@ type API struct { RemoveKeys []string `yaml:"remove_keys"` KeepKeys []string `yaml:"keep_keys"` // inverse of removing keys SampleFilter []map[string]string `yaml:"sample_filter"` // sample filter key pair values with regex + IgnoreOutput bool `yaml:"ignore_output"` // ignore the output completely, useful when creating lookups // Debug Options Debug bool `yaml:"debug"` // logs out additional data, should not be enabled for production use! diff --git a/internal/processor/create.go b/internal/processor/create.go index 57c138ff..44691996 100644 --- a/internal/processor/create.go +++ b/internal/processor/create.go @@ -83,9 +83,15 @@ func CreateMetricSets(samples []interface{}, config *load.Config, i int) { RunSampleRenamer(api.RenameSamples, ¤tSample, key, &eventType) } - // check if this contains any key pair values to filter out createSample := true - RunSampleFilter(currentSample, api.SampleFilter, &createSample) + // check if we should ignore this output completely + // useful when requests are made to generate a lookup, but the data is not needed + if api.IgnoreOutput { + createSample = false + } else { + // check if this contains any key pair values to filter out + RunSampleFilter(currentSample, api.SampleFilter, &createSample) + } if createSample { // remove keys from sample