Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-5.8] LOG-5043: No input.type httpreceiver in log_forwarder_input_info #2357

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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