Skip to content

Commit

Permalink
Use lookupString instead of lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
ph committed Jun 18, 2021
1 parent 6d23fb7 commit 8d82e08
Showing 1 changed file with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,14 @@ func InjectMonitoring(agentInfo *info.AgentInfo, outputGroup string, rootAst *tr
}

// get monitoring output name to be used
monitoringOutputName := defaultOutputName
useOutputNode, found := transpiler.Lookup(rootAst, monitoringUseOutputKey)
if found {
monitoringOutputNameKey, ok := useOutputNode.Value().(*transpiler.StrVal)
if !ok {
return programsToRun, nil
}

monitoringOutputName = monitoringOutputNameKey.String()
monitoringOutputName, found := transpiler.LookupString(rootAst, monitoringUseOutputKey)
if !found {
monitoringOutputName = defaultOutputName
}

typeValue := elasticsearchKey
t, found := transpiler.Lookup(rootAst, fmt.Sprintf("%s.%s.type", outputsKey, monitoringOutputName))
if found {
v, ok := t.Value().(*transpiler.StrVal)
if !ok {
return programsToRun, nil
}
typeValue = v.String()
} else {
typeValue, found := transpiler.LookupString(rootAst, fmt.Sprintf("%s.%s.type", outputsKey, monitoringOutputName))
if !found {
typeValue = elasticsearchKey

}

ast := rootAst.Clone()
Expand Down

0 comments on commit 8d82e08

Please sign in to comment.