Skip to content

Commit

Permalink
[release-5.8]LOG-5043: No input.type httpreceiver in log_forwarder_in…
Browse files Browse the repository at this point in the history
…put_info
  • Loading branch information
Clee2691 authored and openshift-merge-bot[bot] committed Feb 16, 2024
1 parent 1378e2c commit 694c925
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
12 changes: 9 additions & 3 deletions internal/metrics/telemetry/cloteleminfo.go
Expand Up @@ -15,6 +15,7 @@ const (
InputNameApplication = v1.InputNameApplication
InputNameAudit = v1.InputNameAudit
InputNameInfrastructure = v1.InputNameInfrastructure
InputNameHttpReceiver = "http"

OutputTypeDefault = "default"
OutputTypeElasticsearch = v1.OutputTypeElasticsearch
Expand Down Expand Up @@ -52,7 +53,11 @@ func NewTD() *TData {
CLLogStoreType: utils.InitStringMap(map[string]string{OutputTypeElasticsearch: IsNotPresent, OutputTypeLoki: IsNotPresent}),
CollectorErrorCount: utils.InitFloat64Map(map[string]float64{"CollectorErrorCount": 0}),
CLFInfo: utils.InitStringMap(map[string]string{HealthStatus: IsNotPresent, PipelineNo: IsNotPresent}),
CLFInputType: utils.InitStringMap(map[string]string{InputNameApplication: IsNotPresent, InputNameAudit: IsNotPresent, InputNameInfrastructure: IsNotPresent}),
CLFInputType: utils.InitStringMap(map[string]string{
InputNameApplication: IsNotPresent,
InputNameAudit: IsNotPresent,
InputNameInfrastructure: IsNotPresent,
InputNameHttpReceiver: IsNotPresent}),
CLFOutputType: utils.InitStringMap(map[string]string{
OutputTypeDefault: IsNotPresent,
OutputTypeElasticsearch: IsNotPresent,
Expand Down Expand Up @@ -90,7 +95,7 @@ var (
mCLFInputType = NewInfoVec(
"log_forwarder_input_info",
"Clf input type specific metric",
[]string{InputNameApplication, InputNameAudit, InputNameInfrastructure},
[]string{InputNameApplication, InputNameAudit, InputNameInfrastructure, InputNameHttpReceiver},
)

mCLFOutputType = NewInfoVec(
Expand Down Expand Up @@ -185,7 +190,8 @@ func SetCLFMetrics(value float64) {
mCLFInputType.With(prometheus.Labels{
InputNameApplication: CLFInputType.Get(InputNameApplication),
InputNameAudit: CLFInputType.Get(InputNameAudit),
InputNameInfrastructure: CLFInputType.Get(InputNameInfrastructure)}).Set(value)
InputNameInfrastructure: CLFInputType.Get(InputNameInfrastructure),
InputNameHttpReceiver: CLFInputType.Get(InputNameHttpReceiver)}).Set(value)

mCLFOutputType.With(prometheus.Labels{
OutputTypeDefault: CLFOutputType.Get(OutputTypeDefault),
Expand Down
15 changes: 14 additions & 1 deletion internal/metrics/telemetry/cluster_log_forwarder.go
@@ -1,10 +1,11 @@
package telemetry

import (
"strconv"

log "github.com/ViaQ/logerr/v2/log/static"
logging "github.com/openshift/cluster-logging-operator/apis/logging/v1"
"github.com/openshift/cluster-logging-operator/internal/constants"
"strconv"
)

func UpdateInfofromCLF(forwarder logging.ClusterLogForwarder) {
Expand All @@ -17,6 +18,7 @@ func UpdateInfofromCLF(forwarder logging.ClusterLogForwarder) {

//CLO CLF pipelines and set of output specs
lgpipeline := forwarder.Spec.Pipelines
inputs := forwarder.Spec.InputMap()
outputs := forwarder.Spec.OutputMap()
log.V(1).Info("OutputMap", "outputs", outputs)

Expand All @@ -30,8 +32,19 @@ func UpdateInfofromCLF(forwarder logging.ClusterLogForwarder) {
log.V(1).Info("iter over labelnames", "labelname", labelname)
Data.CLFInputType.Set(labelname.(string), constants.IsNotPresent) //reset to zero
for _, inputtype := range inref {
hasInput := false
log.V(1).Info("iter over inputtype", "inputtype", inputtype)
if inputtype == labelname {
hasInput = true
} else {
// Checking HTTP input receiver
if in, ok := inputs[inputtype]; ok {
if labelname == InputNameHttpReceiver && in.Receiver != nil && in.Receiver.HTTP != nil {
hasInput = true
}
}
}
if hasInput {
log.V(1).Info("labelname and inputtype", "labelname", labelname, "inputtype", inputtype) //when matched print matched labelname with input type stated in CLF spec
Data.CLFInputType.Set(labelname.(string), constants.IsPresent) //input type present in CLF spec
}
Expand Down

0 comments on commit 694c925

Please sign in to comment.