Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions internal/generator/vector/conf/complex.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ type = "remap"
inputs = ["input_infrastructure_container"]
source = '''
.log_source = "container"
.log_type = "infrastructure"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''

[sources.input_infrastructure_journal]
Expand Down Expand Up @@ -145,7 +150,12 @@ type = "remap"
inputs = ["input_mytestapp_container"]
source = '''
.log_source = "container"
.log_type = "application"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''

[transforms.pipeline_pipeline_viaqjournal_0]
Expand Down
14 changes: 12 additions & 2 deletions internal/generator/vector/conf/complex_http_receiver.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,12 @@ type = "remap"
inputs = ["input_infrastructure_container"]
source = '''
.log_source = "container"
.log_type = "infrastructure"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''

[sources.input_infrastructure_journal]
Expand Down Expand Up @@ -179,7 +184,12 @@ type = "remap"
inputs = ["input_mytestapp_container"]
source = '''
.log_source = "container"
.log_type = "application"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''

[transforms.pipeline_pipeline_viaqjournal_0]
Expand Down
14 changes: 12 additions & 2 deletions internal/generator/vector/conf/container.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ type = "remap"
inputs = ["input_myinfra_container"]
source = '''
.log_source = "container"
.log_type = "infrastructure"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''

# Logs from containers (including openshift containers)
Expand All @@ -57,7 +62,12 @@ type = "remap"
inputs = ["input_mytestapp_container"]
source = '''
.log_source = "container"
.log_type = "application"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''

[transforms.pipeline_mypipeline_viaq_0]
Expand Down
7 changes: 6 additions & 1 deletion internal/generator/vector/input/application.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@ type = "remap"
inputs = ["input_application_container"]
source = '''
.log_source = "container"
.log_type = "application"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ type = "remap"
inputs = ["input_my_app_container"]
source = '''
.log_source = "container"
.log_type = "application"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@ type = "remap"
inputs = ["input_my_app_container"]
source = '''
.log_source = "container"
.log_type = "application"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ type = "remap"
inputs = ["input_my_app_container"]
source = '''
.log_source = "container"
.log_type = "application"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ type = "remap"
inputs = ["input_my_app_container"]
source = '''
.log_source = "container"
.log_type = "application"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ type = "remap"
inputs = ["input_my_app_container"]
source = '''
.log_source = "container"
.log_type = "application"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ type = "remap"
inputs = ["input_my_app_container"]
source = '''
.log_source = "container"
.log_type = "application"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ type = "remap"
inputs = ["input_my_app_container"]
source = '''
.log_source = "container"
.log_type = "application"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ type = "remap"
inputs = ["input_my_app_container"]
source = '''
.log_source = "container"
.log_type = "application"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ type = "remap"
inputs = ["input_application_container"]
source = '''
.log_source = "container"
.log_type = "application"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''

[transforms.input_application_container_throttle]
Expand Down
8 changes: 4 additions & 4 deletions internal/generator/vector/input/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewAuditAuditdSource(input obs.InputSpec, op generator.Options) ([]generato
metaID := helpers.MakeID(hostID, "meta")
el := []generator.Element{
sources.NewHostAuditLog(hostID),
NewLogSourceAndType(metaID, obs.AuditSourceAuditd, obs.InputTypeAudit, hostID),
NewLogSourceAndType(metaID, obs.AuditSourceAuditd, obs.InputTypeAudit, hostID, nil),
}
return el, []string{metaID}
}
Expand All @@ -33,7 +33,7 @@ func NewK8sAuditSource(input obs.InputSpec, op generator.Options) ([]generator.E
metaID := helpers.MakeID(id, "meta")
el := []generator.Element{
sources.NewK8sAuditLog(id),
NewLogSourceAndType(metaID, obs.AuditSourceKube, obs.InputTypeAudit, id),
NewLogSourceAndType(metaID, obs.AuditSourceKube, obs.InputTypeAudit, id, nil),
}
return el, []string{metaID}
}
Expand All @@ -43,7 +43,7 @@ func NewOpenshiftAuditSource(input obs.InputSpec, op generator.Options) ([]gener
metaID := helpers.MakeID(id, "meta")
el := []generator.Element{
sources.NewOpenshiftAuditLog(id),
NewLogSourceAndType(metaID, obs.AuditSourceOpenShift, obs.InputTypeAudit, id),
NewLogSourceAndType(metaID, obs.AuditSourceOpenShift, obs.InputTypeAudit, id, nil),
}
return el, []string{metaID}
}
Expand All @@ -53,7 +53,7 @@ func NewOVNAuditSource(input obs.InputSpec, op generator.Options) ([]generator.E
metaID := helpers.MakeID(id, "meta")
el := []generator.Element{
sources.NewOVNAuditLog(id),
NewLogSourceAndType(metaID, obs.AuditSourceOVN, obs.InputTypeAudit, id),
NewLogSourceAndType(metaID, obs.AuditSourceOVN, obs.InputTypeAudit, id, nil),
}
return el, []string{metaID}
}
7 changes: 6 additions & 1 deletion internal/generator/vector/input/infrastructure.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ type = "remap"
inputs = ["input_infrastructure_container"]
source = '''
.log_source = "container"
.log_type = "infrastructure"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''

[sources.input_infrastructure_journal]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,10 @@ type = "remap"
inputs = ["input_myinfra_container"]
source = '''
.log_source = "container"
.log_type = "infrastructure"
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = "infrastructure"
} else {
.log_type = "application"
}
'''
2 changes: 1 addition & 1 deletion internal/generator/vector/input/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func NewJournalSource(input obs.InputSpec) ([]Element, []string) {
metaID := helpers.MakeID(id, "meta")
el := []Element{
source.NewJournalLog(id),
NewLogSourceAndType(metaID, string(obs.InfrastructureSourceNode), string(obs.InputTypeInfrastructure), id),
NewLogSourceAndType(metaID, string(obs.InfrastructureSourceNode), string(obs.InputTypeInfrastructure), id, nil),
}
return el, []string{metaID}
}
10 changes: 8 additions & 2 deletions internal/generator/vector/input/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ package input

import (
"fmt"

"github.com/openshift/cluster-logging-operator/internal/generator/framework"
"github.com/openshift/cluster-logging-operator/internal/generator/vector/elements"
"github.com/openshift/cluster-logging-operator/internal/generator/vector/helpers"
)

func NewLogSourceAndType(id string, logSource, logType interface{}, inputs string) framework.Element {
return elements.Remap{
func NewLogSourceAndType(id string, logSource, logType interface{}, inputs string, visit func(remap *elements.Remap)) framework.Element {
ele := elements.Remap{
ComponentID: id,
Inputs: helpers.MakeInputs(inputs),
VRL: fmt.Sprintf(".log_source = %q\n.log_type = %q", logSource, logType),
}

if visit != nil {
visit(&ele)
}
return ele
}
4 changes: 2 additions & 2 deletions internal/generator/vector/input/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewViaqReceiverSource(spec obs.InputSpec, resNames factory.ForwarderResourc
els = append(els,
source.NewSyslogSource(base, resNames.GenerateInputServiceName(spec.Name), spec),
tlsConfig,
NewLogSourceAndType(metaID, obs.InfrastructureSourceNode, obs.InputTypeInfrastructure, base),
NewLogSourceAndType(metaID, obs.InfrastructureSourceNode, obs.InputTypeInfrastructure, base, nil),
)
case obs.ReceiverTypeHTTP:
el, id := source.NewHttpSource(base, resNames.GenerateInputServiceName(spec.Name), spec)
Expand All @@ -33,7 +33,7 @@ func NewViaqReceiverSource(spec obs.InputSpec, resNames factory.ForwarderResourc
tlsConfig,
split,
items,
NewLogSourceAndType(metaID, obs.AuditSourceKube, obs.InputTypeAudit, itemsID),
NewLogSourceAndType(metaID, obs.AuditSourceKube, obs.InputTypeAudit, itemsID, nil),
)
}
return els, []string{metaID}
Expand Down
19 changes: 17 additions & 2 deletions internal/generator/vector/input/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@ package input

import (
"fmt"
"regexp"

obs "github.com/openshift/cluster-logging-operator/api/observability/v1"
internalobs "github.com/openshift/cluster-logging-operator/internal/api/observability"
"github.com/openshift/cluster-logging-operator/internal/constants"
"github.com/openshift/cluster-logging-operator/internal/factory"
"github.com/openshift/cluster-logging-operator/internal/generator/framework"
"github.com/openshift/cluster-logging-operator/internal/generator/vector/elements"
"github.com/openshift/cluster-logging-operator/internal/generator/vector/helpers"
"github.com/openshift/cluster-logging-operator/internal/generator/vector/source"
"github.com/openshift/cluster-logging-operator/internal/utils/sets"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/set"
"regexp"
)

const (
Expand Down Expand Up @@ -166,7 +168,20 @@ func NewContainerSource(spec obs.InputSpec, namespace, includes, excludes string
ExcludePaths: excludes,
ExtraLabelSelector: source.LabelSelectorFrom(selector),
},
NewLogSourceAndType(metaID, logSource, logType, base),
NewLogSourceAndType(metaID, logSource, logType, base, func(remap *elements.Remap) {
remap.VRL = fmt.Sprintf(
`
.log_source = %q
# If namespace is infra, label log_type as infra
if match_any(string!(.kubernetes.namespace_name), [r'^default$', r'^openshift(-.+)?$', r'^kube(-.+)?$']) {
.log_type = %q
} else {
.log_type = %q
}`,
logSource,
obs.InputTypeInfrastructure,
obs.InputTypeApplication)
}),
}
inputID := metaID
//TODO: DETERMINE IF key field is correct and actually works
Expand Down