-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Athish Pranav D <[email protected]>
- Loading branch information
1 parent
e470969
commit fc28e76
Showing
8 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
apis/fluentbit/v1alpha2/plugins/filter/log_to_metrics_types.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package filter | ||
|
||
import ( | ||
"fmt" | ||
"github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins" | ||
"github.com/fluent/fluent-operator/v2/apis/fluentbit/v1alpha2/plugins/params" | ||
) | ||
|
||
// +kubebuilder:object:generate:=true | ||
|
||
// The Log To Metrics Filter plugin allows you to generate log-derived metrics. <br /> | ||
// **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/filters/log_to_metrics** | ||
type LogToMetrics struct { | ||
plugins.CommonParams `json:",inline"` | ||
// Defines the tag for the generated metrics record | ||
Tag string `json:"tag,omitempty"` | ||
// Optional filter for records in which the content of KEY matches the regular expression. | ||
// Value Format: FIELD REGEX | ||
Regex []string `json:"regex,omitempty"` | ||
// Optional filter for records in which the content of KEY does not matches the regular expression. | ||
// Value Format: FIELD REGEX | ||
Exclude []string `json:"exclude,omitempty"` | ||
// Defines the mode for the metric. Valid values are [counter, gauge or histogram] | ||
MetricMode string `json:"metric_mode,omitempty"` | ||
// Sets the name of the metric. | ||
MetricName string `json:"metric_name,omitempty"` | ||
// Namespace of the metric | ||
MetricNamespace string `json:"metric_namespace,omitempty"` | ||
// Sets a sub-system for the metric. | ||
MetricSubsystem string `json:"metric_subsystem,omitempty"` | ||
// Sets a help text for the metric. | ||
MetricDescription string `json:"metric_description,omitempty"` | ||
// Defines a bucket for histogram | ||
Bucket []string `json:"bucket,omitempty"` | ||
// Add a custom label NAME and set the value to the value of KEY | ||
AddLabel []string `json:"add_label,omitempty"` | ||
// Includes a record field as label dimension in the metric. | ||
LabelField []string `json:"label_field,omitempty"` | ||
// Specify the record field that holds a numerical value | ||
ValueField string `json:"value_field,omitempty"` | ||
// If enabled, it will automatically put pod_id, pod_name, namespace_name, docker_id and container_name | ||
// into the metric as labels. This option is intended to be used in combination with the kubernetes filter plugin. | ||
KubernetesMode *bool `json:"kubernetes_mode,omitempty"` | ||
// Name of the emitter (advanced users) | ||
EmitterName string `json:"emitter_name,omitempty"` | ||
// set a buffer limit to restrict memory usage of metrics emitter | ||
EmitterMemBufLimit string `json:"emitter_mem_limit,omitempty"` | ||
// Flag that defines if logs should be discarded after processing. This applies | ||
// for all logs, no matter if they have emitted metrics or not. | ||
DiscardLogs *bool `json:"discard_logs,omitempty"` | ||
} | ||
|
||
func (_ *LogToMetrics) Name() string { | ||
return "log_to_metrics" | ||
} | ||
|
||
func (l *LogToMetrics) Params(_ plugins.SecretLoader) (*params.KVs, error) { | ||
kvs := params.NewKVs() | ||
err := g.AddCommonParams(kvs) | ||
if err != nil { | ||
return kvs, err | ||
} | ||
if l.Tag != "" { | ||
kvs.Insert("Tag", l.Tag) | ||
} | ||
for _, reg := range l.Regex { | ||
kvs.Insert("Regex", reg) | ||
} | ||
for _, ex := range l.Exclude { | ||
kvs.Insert("Exclude", ex) | ||
} | ||
if l.MetricMode != "" { | ||
kvs.Insert("Metric_mode", l.MetricMode) | ||
} | ||
if l.MetricName != "" { | ||
kvs.Insert("Metric_name", l.MetricName) | ||
} | ||
if l.MetricNamespace != "" { | ||
kvs.Insert("Metric_namespace", l.MetricNamespace) | ||
} | ||
if l.MetricSubsystem != "" { | ||
kvs.Insert("Metric_subsystem", l.MetricSubsystem) | ||
} | ||
if l.MetricDescription != "" { | ||
kvs.Insert("Metric_description", l.MetricDescription) | ||
} | ||
for _, b := range l.Bucket { | ||
kvs.Insert("Bucket", b) | ||
} | ||
for _, al := range l.AddLabel { | ||
kvs.Insert("Add_label", al) | ||
} | ||
for _, lf := range l.LabelField { | ||
kvs.Insert("Label_field", lf) | ||
} | ||
if l.ValueField != "" { | ||
kvs.Insert("Value_field", l.ValueField) | ||
} | ||
if l.KubernetesMode != nil { | ||
kvs.Insert("Kubernetes_mode", fmt.Sprintf("%t", *l.KubernetesMode)) | ||
} | ||
if l.EmitterName != "" { | ||
kvs.Insert("Emitter_Name", l.EmitterName) | ||
} | ||
if l.EmitterMemBufLimit != "" { | ||
kvs.Insert("Emitter_Mem_Buf_Limit", l.EmitterMemBufLimit) | ||
} | ||
if l.DiscardLogs !=nil { | ||
kvs.Insert("Discard_logs", fmt.Sprintf("%t", *l.DiscardLogs)) | ||
} | ||
return kvs, nil | ||
} |
46 changes: 46 additions & 0 deletions
46
apis/fluentbit/v1alpha2/plugins/filter/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# LogToMetrics | ||
|
||
The Log To Metrics Filter plugin allows you to generate log-derived metrics. <br /> **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/filters/log_to_metrics** | ||
|
||
|
||
| Field | Description | Scheme | | ||
| ----- | ----------- | ------ | | ||
| tag | Defines the tag for the generated metrics record | string | | ||
| regex | Optional filter for records in which the content of KEY matches the regular expression. Value Format: FIELD REGEX | []string | | ||
| exclude | Optional filter for records in which the content of KEY does not matches the regular expression. Value Format: FIELD REGEX | []string | | ||
| metric_mode | Defines the mode for the metric. Valid values are [counter, gauge or histogram] | string | | ||
| metric_name | Sets the name of the metric. | string | | ||
| metric_namespace | Namespace of the metric | string | | ||
| metric_subsystem | Sets a sub-system for the metric. | string | | ||
| metric_description | Sets a help text for the metric. | string | | ||
| bucket | Defines a bucket for histogram | []string | | ||
| add_label | Add a custom label NAME and set the value to the value of KEY | []string | | ||
| label_field | Includes a record field as label dimension in the metric. | []string | | ||
| value_field | Specify the record field that holds a numerical value | string | | ||
| kubernetes_mode | If enabled, it will automatically put pod_id, pod_name, namespace_name, docker_id and container_name into the metric as labels. This option is intended to be used in combination with the kubernetes filter plugin. | *bool | | ||
| emitter_name | Name of the emitter (advanced users) | string | | ||
| emitter_mem_limit | set a buffer limit to restrict memory usage of metrics emitter | string | | ||
| discard_logs | Flag that defines if logs should be discarded after processing. This applies for all logs, no matter if they have emitted metrics or not. | bool | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters