Skip to content

Commit

Permalink
Introduce relabel output (#1294)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Gvizd <[email protected]>
Signed-off-by: Peter Wilcsinszky <[email protected]>
Co-authored-by: Peter Gvizd <[email protected]>
Co-authored-by: Peter Wilcsinszky <[email protected]>
Co-authored-by: Peter Wilcsinszky <[email protected]>
  • Loading branch information
4 people authored Apr 20, 2023
1 parent 9eb754a commit 0fa1657
Show file tree
Hide file tree
Showing 26 changed files with 296 additions and 32 deletions.
8 changes: 8 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_clusterflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -967,10 +967,14 @@ spec:
type: object
type: object
type: array
flowLabel:
type: string
globalOutputRefs:
items:
type: string
type: array
includeLabelInRouter:
type: boolean
loggingRef:
type: string
match:
Expand Down Expand Up @@ -1990,10 +1994,14 @@ spec:
type: object
type: object
type: array
flowLabel:
type: string
globalOutputRefs:
items:
type: string
type: array
includeLabelInRouter:
type: boolean
loggingRef:
type: string
match:
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_clusteroutputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4833,6 +4833,13 @@ spec:
ttl:
type: integer
type: object
relabel:
properties:
label:
type: string
required:
- label
type: object
s3:
properties:
acl:
Expand Down Expand Up @@ -10819,6 +10826,13 @@ spec:
ttl:
type: integer
type: object
relabel:
properties:
label:
type: string
required:
- label
type: object
s3:
properties:
acl:
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_flows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -967,10 +967,14 @@ spec:
type: object
type: object
type: array
flowLabel:
type: string
globalOutputRefs:
items:
type: string
type: array
includeLabelInRouter:
type: boolean
localOutputRefs:
items:
type: string
Expand Down Expand Up @@ -1986,10 +1990,14 @@ spec:
type: object
type: object
type: array
flowLabel:
type: string
globalOutputRefs:
items:
type: string
type: array
includeLabelInRouter:
type: boolean
localOutputRefs:
items:
type: string
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_loggings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -985,10 +985,14 @@ spec:
type: object
type: object
type: array
flowLabel:
type: string
globalOutputRefs:
items:
type: string
type: array
includeLabelInRouter:
type: boolean
outputRefs:
items:
type: string
Expand Down
14 changes: 14 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_outputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4748,6 +4748,13 @@ spec:
ttl:
type: integer
type: object
relabel:
properties:
label:
type: string
required:
- label
type: object
s3:
properties:
acl:
Expand Down Expand Up @@ -10728,6 +10735,13 @@ spec:
ttl:
type: integer
type: object
relabel:
properties:
label:
type: string
required:
- label
type: object
s3:
properties:
acl:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,10 +967,14 @@ spec:
type: object
type: object
type: array
flowLabel:
type: string
globalOutputRefs:
items:
type: string
type: array
includeLabelInRouter:
type: boolean
loggingRef:
type: string
match:
Expand Down Expand Up @@ -1990,10 +1994,14 @@ spec:
type: object
type: object
type: array
flowLabel:
type: string
globalOutputRefs:
items:
type: string
type: array
includeLabelInRouter:
type: boolean
loggingRef:
type: string
match:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4833,6 +4833,13 @@ spec:
ttl:
type: integer
type: object
relabel:
properties:
label:
type: string
required:
- label
type: object
s3:
properties:
acl:
Expand Down Expand Up @@ -10819,6 +10826,13 @@ spec:
ttl:
type: integer
type: object
relabel:
properties:
label:
type: string
required:
- label
type: object
s3:
properties:
acl:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,10 +967,14 @@ spec:
type: object
type: object
type: array
flowLabel:
type: string
globalOutputRefs:
items:
type: string
type: array
includeLabelInRouter:
type: boolean
localOutputRefs:
items:
type: string
Expand Down Expand Up @@ -1986,10 +1990,14 @@ spec:
type: object
type: object
type: array
flowLabel:
type: string
globalOutputRefs:
items:
type: string
type: array
includeLabelInRouter:
type: boolean
localOutputRefs:
items:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -985,10 +985,14 @@ spec:
type: object
type: object
type: array
flowLabel:
type: string
globalOutputRefs:
items:
type: string
type: array
includeLabelInRouter:
type: boolean
outputRefs:
items:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4748,6 +4748,13 @@ spec:
ttl:
type: integer
type: object
relabel:
properties:
label:
type: string
required:
- label
type: object
s3:
properties:
acl:
Expand Down Expand Up @@ -10728,6 +10735,13 @@ spec:
ttl:
type: integer
type: object
relabel:
properties:
label:
type: string
required:
- label
type: object
s3:
properties:
acl:
Expand Down
6 changes: 3 additions & 3 deletions pkg/resources/model/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func FlowForFlow(flow v1beta1.Flow, clusterOutputs ClusterOutputs, outputs Outpu

flowID := fmt.Sprintf("flow:%s:%s", flow.Namespace, flow.Name)

result, err := types.NewFlow(matches, flowID, flow.Name, flow.Namespace)
result, err := types.NewFlow(matches, flowID, flow.Name, flow.Namespace, flow.Spec.FlowLabel, flow.Spec.IncludeLabelInRouter)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -346,7 +346,7 @@ func FlowForClusterFlow(flow v1beta1.ClusterFlow, clusterOutputs ClusterOutputs,

flowID := fmt.Sprintf("clusterflow:%s:%s", flow.Namespace, flow.Name)

result, err := types.NewFlow(matches, flowID, flow.Name, flow.Namespace)
result, err := types.NewFlow(matches, flowID, flow.Name, flow.Namespace, flow.Spec.FlowLabel, flow.Spec.IncludeLabelInRouter)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -383,7 +383,7 @@ func FlowForDefaultFlow(logging v1beta1.Logging, clusterOutputs ClusterOutputs,

flowID := fmt.Sprintf("logging:%s:%s", logging.Namespace, logging.Name)

result, err := types.NewFlow([]types.FlowMatch{}, flowID, logging.Name, logging.Namespace)
result, err := types.NewFlow([]types.FlowMatch{}, flowID, logging.Name, logging.Namespace, logging.Spec.DefaultFlowSpec.FlowLabel, logging.Spec.DefaultFlowSpec.IncludeLabelInRouter)
if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/sdk/logging/api/v1alpha1/output_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type OutputSpec struct {
SyslogOutputConfig *output.SyslogOutputConfig `json:"syslog,omitempty"`
GELFOutputConfig *output.GELFOutputConfig `json:"gelf,omitempty"`
SQSOutputConfig *output.SQSOutputConfig `json:"sqs,omitempty"`
RelabelOutputConfig *output.RelabelOutputConfig `json:"relabel,omitempty"`
}

// OutputStatus defines the observed state of Output
Expand Down
5 changes: 5 additions & 0 deletions pkg/sdk/logging/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions pkg/sdk/logging/api/v1beta1/clusterflow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ type ClusterFlowSpec struct {
Filters []Filter `json:"filters,omitempty"`
LoggingRef string `json:"loggingRef,omitempty"`
// Deprecated
OutputRefs []string `json:"outputRefs,omitempty"`
GlobalOutputRefs []string `json:"globalOutputRefs,omitempty"`
OutputRefs []string `json:"outputRefs,omitempty"`
GlobalOutputRefs []string `json:"globalOutputRefs,omitempty"`
FlowLabel string `json:"flowLabel,omitempty"`
IncludeLabelInRouter *bool `json:"includeLabelInRouter,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
8 changes: 5 additions & 3 deletions pkg/sdk/logging/api/v1beta1/flow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ type FlowSpec struct {
Filters []Filter `json:"filters,omitempty"`
LoggingRef string `json:"loggingRef,omitempty"`
// Deprecated
OutputRefs []string `json:"outputRefs,omitempty"`
GlobalOutputRefs []string `json:"globalOutputRefs,omitempty"`
LocalOutputRefs []string `json:"localOutputRefs,omitempty"`
OutputRefs []string `json:"outputRefs,omitempty"`
GlobalOutputRefs []string `json:"globalOutputRefs,omitempty"`
LocalOutputRefs []string `json:"localOutputRefs,omitempty"`
FlowLabel string `json:"flowLabel,omitempty"`
IncludeLabelInRouter *bool `json:"includeLabelInRouter,omitempty"`
}

type Match struct {
Expand Down
6 changes: 4 additions & 2 deletions pkg/sdk/logging/api/v1beta1/logging_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ type LoggingList struct {
type DefaultFlowSpec struct {
Filters []Filter `json:"filters,omitempty"`
// Deprecated
OutputRefs []string `json:"outputRefs,omitempty"`
GlobalOutputRefs []string `json:"globalOutputRefs,omitempty"`
OutputRefs []string `json:"outputRefs,omitempty"`
GlobalOutputRefs []string `json:"globalOutputRefs,omitempty"`
FlowLabel string `json:"flowLabel,omitempty"`
IncludeLabelInRouter *bool `json:"includeLabelInRouter,omitempty"`
}

const (
Expand Down
1 change: 1 addition & 0 deletions pkg/sdk/logging/api/v1beta1/output_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type OutputSpec struct {
GELFOutputConfig *output.GELFOutputConfig `json:"gelf,omitempty"`
SQSOutputConfig *output.SQSOutputConfig `json:"sqs,omitempty"`
MattermostOutputConfig *output.MattermostOutputConfig `json:"mattermost,omitempty"`
RelabelOutputConfig *output.RelabelOutputConfig `json:"relabel,omitempty"`
}

// OutputStatus defines the observed state of Output
Expand Down
Loading

0 comments on commit 0fa1657

Please sign in to comment.