Skip to content

Commit

Permalink
[summerospp]add fluentbit opentelemetry plugin (#890)
Browse files Browse the repository at this point in the history
* [summerospp]add fluentbit opentelemetry plugin

Signed-off-by: 刘帅军 <liudonglan@liudonglandeMacBook-Pro.local>

* [summerospp]add fluentbit opentelemetry plugin

Signed-off-by: 刘帅军 <liudonglan@192.168.2.101>

* [summerospp]add fluentbit opentelemetry plugin

Signed-off-by: 刘帅军 <liudonglan@192.168.2.101>

* Delete .DS_Store

Signed-off-by: SjLiu <139106424+sjliu1@users.noreply.github.com>

---------

Signed-off-by: 刘帅军 <liudonglan@liudonglandeMacBook-Pro.local>
Signed-off-by: 刘帅军 <liudonglan@192.168.2.101>
Signed-off-by: Elon Cheng <dehaocheng@kubesphere.io>
Signed-off-by: SjLiu <139106424+sjliu1@users.noreply.github.com>
Co-authored-by: 刘帅军 <liudonglan@liudonglandeMacBook-Pro.local>
Co-authored-by: 刘帅军 <liudonglan@192.168.2.101>
Co-authored-by: Elon Cheng <dehaocheng@kubesphere.io>
  • Loading branch information
4 people committed Aug 30, 2023
1 parent 3c42ca7 commit 9f220bc
Show file tree
Hide file tree
Showing 19 changed files with 338 additions and 42 deletions.
2 changes: 2 additions & 0 deletions apis/fluentbit/v1alpha2/clusterinput_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ type InputSpec struct {
CustomPlugin *custom.CustomPlugin `json:"customPlugin,omitempty"`
// Forward defines forward input plugin configuration
Forward *input.Forward `json:"forward,omitempty"`
// OpenTelemetry defines forward input plugin configuration
OpenTelemetry *input.OpenTelemetry `json:"openTelemetry,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
65 changes: 65 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/input/open_telemetry_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package input

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 OpenTelemetry plugin allows you to ingest telemetry data as per the OTLP specification, <br />
// from various OpenTelemetry exporters, the OpenTelemetry Collector, or Fluent Bit's OpenTelemetry output plugin. <br />
// **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/opentelemetry**
type OpenTelemetry struct {
// The address to listen on,default 0.0.0.0
Listen string `json:"listen,omitempty"`
// The port for Fluent Bit to listen on.default 4318.
// +kubebuilder:validation:Minimum:=1
// +kubebuilder:validation:Maximum:=65535
Port *int32 `json:"port,omitempty"`
// Specify the key name to overwrite a tag. If set, the tag will be overwritten by a value of the key.
Tagkey string `json:"tagKey,omitempty"`
// Route trace data as a log message(default false).
RawTraces *bool `json:"rawTraces,omitempty"`
// Specify the maximum buffer size in KB to receive a JSON message(default 4M).
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
BufferMaxSize string `json:"bufferMaxSize,omitempty"`
// This sets the chunk size for incoming incoming JSON messages. These chunks are then stored/managed in the space available by buffer_max_size(default 512K).
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
BufferChunkSize string `json:"bufferChunkSize,omitempty"`
//It allows to set successful response code. 200, 201 and 204 are supported(default 201).
SuccessfulResponseCode *int32 `json:"successfulResponseCode,omitempty"`
}

func (_ *OpenTelemetry) Name() string {
return "opentelemetry"
}

// implement Section() method
func (ot *OpenTelemetry) Params(_ plugins.SecretLoader) (*params.KVs, error) {
kvs := params.NewKVs()
if ot.Listen != "" {
kvs.Insert("listen", ot.Listen)
}
if ot.Port != nil {
kvs.Insert("port", fmt.Sprint(*ot.Port))
}
if ot.Tagkey != "" {
kvs.Insert("tag_key", ot.Tagkey)
}
if ot.RawTraces != nil {
kvs.Insert("raw_traces", fmt.Sprint(*ot.RawTraces))
}
if ot.BufferMaxSize != "" {
kvs.Insert("buffer_max_size", ot.BufferMaxSize)
}
if ot.BufferChunkSize != "" {
kvs.Insert("buffer_chunk_size", ot.BufferChunkSize)
}
if ot.SuccessfulResponseCode != nil {
kvs.Insert("successful_response_code", fmt.Sprint(*ot.SuccessfulResponseCode))
}
return kvs, nil
}
30 changes: 30 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/input/zz_generated.deepcopy.go

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

5 changes: 5 additions & 0 deletions apis/fluentbit/v1alpha2/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,42 @@ spec:
plugin.
type: string
type: object
openTelemetry:
description: OpenTelemetry defines forward input plugin configuration
properties:
bufferChunkSize:
description: This sets the chunk size for incoming incoming JSON
messages. These chunks are then stored/managed in the space
available by buffer_max_size(default 512K).
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
bufferMaxSize:
description: Specify the maximum buffer size in KB to receive
a JSON message(default 4M).
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
listen:
description: The address to listen on,default 0.0.0.0
type: string
port:
description: The port for Fluent Bit to listen on.default 4318.
format: int32
maximum: 65535
minimum: 1
type: integer
rawTraces:
description: Route trace data as a log message(default false).
type: boolean
successfulResponseCode:
description: It allows to set successful response code. 200, 201
and 204 are supported(default 201).
format: int32
type: integer
tagKey:
description: Specify the key name to overwrite a tag. If set,
the tag will be overwritten by a value of the key.
type: string
type: object
prometheusScrapeMetrics:
description: PrometheusScrapeMetrics defines Prometheus Scrape Metrics
Input configuration.
Expand Down
36 changes: 36 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,42 @@ spec:
plugin.
type: string
type: object
openTelemetry:
description: OpenTelemetry defines forward input plugin configuration
properties:
bufferChunkSize:
description: This sets the chunk size for incoming incoming JSON
messages. These chunks are then stored/managed in the space
available by buffer_max_size(default 512K).
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
bufferMaxSize:
description: Specify the maximum buffer size in KB to receive
a JSON message(default 4M).
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
type: string
listen:
description: The address to listen on,default 0.0.0.0
type: string
port:
description: The port for Fluent Bit to listen on.default 4318.
format: int32
maximum: 65535
minimum: 1
type: integer
rawTraces:
description: Route trace data as a log message(default false).
type: boolean
successfulResponseCode:
description: It allows to set successful response code. 200, 201
and 204 are supported(default 201).
format: int32
type: integer
tagKey:
description: Specify the key name to overwrite a tag. If set,
the tag will be overwritten by a value of the key.
type: string
type: object
prometheusScrapeMetrics:
description: PrometheusScrapeMetrics defines Prometheus Scrape Metrics
Input configuration.
Expand Down
2 changes: 2 additions & 0 deletions docs/fluentbit.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ InputSpec defines the desired state of ClusterInput
| fluentBitMetrics | FluentBitMetrics defines Fluent Bit Metrics Input configuration. | *[input.FluentbitMetrics](plugins/input/fluentbitmetrics.md) |
| customPlugin | CustomPlugin defines Custom Input configuration. | *custom.CustomPlugin |
| forward | Forward defines forward input plugin configuration | *[input.Forward](plugins/input/forward.md) |
| openTelemetry | OpenTelemetry defines forward input plugin configuration | *[input.OpenTelemetry](plugins/input/opentelemetry.md) |


[Back to TOC](#table-of-contents)
# NamespacedFluentBitCfgSpec
Expand Down
9 changes: 6 additions & 3 deletions docs/fluentd.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ FluentdSpec defines the desired state of Fluentd
| ----- | ----------- | ------ |
| globalInputs | Fluentd global inputs. | [][[input.Input](plugins/input/input.md)](plugins/[input/input](plugins/input/input/md).md) |
| defaultFilterSelector | Select cluster filter plugins used to filter for the default cluster output | *[metav1.LabelSelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#labelselector-v1-meta) |
| defaultOutputSelector | Select cluster output plugins used to send all logs that did not match a route to the matching outputs | *[metav1.LabelSelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#labelselector-v1-meta) |
| defaultOutputSelector | Select cluster output plugins used to send all logs that did not match any route to the matching outputs | *[metav1.LabelSelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#labelselector-v1-meta) |
| disableService | By default will build the related service according to the globalinputs definition. | bool |
| replicas | Numbers of the Fluentd instance | *int32 |
| replicas | Numbers of the Fluentd instance Applicable when the mode is \"collector\", and will be ignored when the mode is \"agent\" | *int32 |
| workers | Numbers of the workers in Fluentd instance | *int32 |
| logLevel | Global logging verbosity | string |
| image | Fluentd image. | string |
Expand All @@ -310,10 +310,13 @@ FluentdSpec defines the desired state of Fluentd
| rbacRules | RBACRules represents additional rbac rules which will be applied to the fluentd clusterrole. | []rbacv1.PolicyRule |
| volumes | List of volumes that can be mounted by containers belonging to the pod. | []corev1.Volume |
| volumeMounts | Pod volumes to mount into the container's filesystem. Cannot be updated. | []corev1.VolumeMount |
| volumeClaimTemplates | volumeClaimTemplates is a list of claims that pods are allowed to reference. The StatefulSet controller is responsible for mapping network identities to claims in a way that maintains the identity of a pod. Every claim in this list must have at least one matching (by name) volumeMount in one container in the template. | []corev1.PersistentVolumeClaim |
| volumeClaimTemplates | volumeClaimTemplates is a list of claims that pods are allowed to reference. The StatefulSet controller is responsible for mapping network identities to claims in a way that maintains the identity of a pod. Every claim in this list must have at least one matching (by name) volumeMount in one container in the template. Applicable when the mode is \"collector\", and will be ignored when the mode is \"agent\" | []corev1.PersistentVolumeClaim |
| service | Service represents configurations on the fluentd service. | FluentDService |
| securityContext | PodSecurityContext represents the security context for the fluentd pods. | *corev1.PodSecurityContext |
| schedulerName | SchedulerName represents the desired scheduler for fluentd pods. | string |
| mode | Mode to determine whether to run Fluentd as collector or agent. | string |
| containerSecurityContext | ContainerSecurityContext represents the security context for the fluentd container. | *corev1.SecurityContext |
| positionDB | Storage for position db. You will use it if tail input is enabled. Applicable when the mode is \"agent\", and will be ignored when the mode is \"collector\" | [corev1.VolumeSource](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#volume-v1-core) |

[Back to TOC](#table-of-contents)
# FluentdStatus
Expand Down
16 changes: 16 additions & 0 deletions docs/plugins/fluentbit/input/forward.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Forward

Forward defines the in_forward Input plugin that listens to TCP socket to recieve the event stream. **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/forward**


| Field | Description | Scheme |
| ----- | ----------- | ------ |
| port | Port for forward plugin instance. | *int32 |
| listen | Listener network interface. | string |
| tag | in_forward uses the tag value for incoming logs. If not set it uses tag from incoming log. | string |
| tagPrefix | Adds the prefix to incoming event's tag | string |
| unixPath | Specify the path to unix socket to recieve a forward message. If set, Listen and port are ignnored. | string |
| unixPerm | Set the permission of unix socket file. | string |
| bufferMaxSize | Specify maximum buffer memory size used to recieve a forward message. The value must be according to the Unit Size specification. | string |
| bufferchunkSize | Set the initial buffer size to store incoming data. This value is used too to increase buffer size as required. The value must be according to the Unit Size specification. | string |
| threaded | Threaded mechanism allows input plugin to run in a separate thread which helps to desaturate the main pipeline. | string |
14 changes: 14 additions & 0 deletions docs/plugins/fluentbit/input/open_telemetry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# OpenTelemetry

The OpenTelemetry plugin allows you to ingest telemetry data as per the OTLP specification, <br /> from various OpenTelemetry exporters, the OpenTelemetry Collector, or Fluent Bit's OpenTelemetry output plugin. <br /> **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/opentelemetry**


| Field | Description | Scheme |
| ----- | ----------- | ------ |
| listen | The address to listen on,default 0.0.0.0 | string |
| port | The port for Fluent Bit to listen on.default 4318. | *int32 |
| tagKey | Specify the key name to overwrite a tag. If set, the tag will be overwritten by a value of the key. | string |
| rawTraces | Route trace data as a log message(default false). | *bool |
| bufferMaxSize | Specify the maximum buffer size in KB to receive a JSON message(default 4M). | string |
| bufferChunkSize | This sets the chunk size for incoming incoming JSON messages. These chunks are then stored/managed in the space available by buffer_max_size(default 512K). | string |
| successfulResponseCode | It allows to set successful response code. 200, 201 and 204 are supported(default 201). | *int32 |
2 changes: 2 additions & 0 deletions docs/plugins/fluentbit/input/systemd.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ The Systemd input plugin allows to collect log messages from the Journald daemon
| systemdFilterType | Define the filter type when Systemd_Filter is specified multiple times. Allowed values are And and Or. With And a record is matched only when all of the Systemd_Filter have a match. With Or a record is matched when any of the Systemd_Filter has a match. | string |
| readFromTail | Start reading new entries. Skip entries already stored in Journald. | string |
| stripUnderscores | Remove the leading underscore of the Journald field (key). For example the Journald field _PID becomes the key PID. | string |
| storageType | Specify the buffering mechanism to use. It can be memory or filesystem | string |
| pauseOnChunksOverlimit | Specifies if the input plugin should be paused (stop ingesting new data) when the storage.max_chunks_up value is reached. | string |
2 changes: 2 additions & 0 deletions docs/plugins/fluentbit/input/tail.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ The Tail input plugin allows to monitor one or several text files. <br /> It has
| dockerModeParser | Specify an optional parser for the first line of the docker multiline mode. The parser name to be specified must be registered in the parsers.conf file. | string |
| disableInotifyWatcher | DisableInotifyWatcher will disable inotify and use the file stat watcher instead. | *bool |
| multilineParser | This will help to reassembly multiline messages originally split by Docker or CRI Specify one or Multiline Parser definition to apply to the content. | string |
| storageType | Specify the buffering mechanism to use. It can be memory or filesystem | string |
| pauseOnChunksOverlimit | Specifies if the input plugin should be paused (stop ingesting new data) when the storage.max_chunks_up value is reached. | string |
1 change: 1 addition & 0 deletions docs/plugins/fluentbit/output/open_search.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ OpenSearch is the opensearch output plugin, allows to ingest your records into a
| suppressTypeName | When enabled, mapping types is removed and Type option is ignored. Types are deprecated in APIs in v7.0. This options is for v7.0 or later. | *bool |
| Workers | Enables dedicated thread(s) for this output. Default value is set since version 1.8.13. For previous versions is 0. | *int32 |
| tls | | *[plugins.TLS](../tls.md) |
| totalLimitSize | Limit the maximum number of Chunks in the filesystem for the current output logical destination. | string |
10 changes: 10 additions & 0 deletions docs/plugins/fluentbit/output/prometheus_exporter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# PrometheusExporter

PrometheusExporter An output plugin to expose Prometheus Metrics. <br /> The prometheus exporter allows you to take metrics from Fluent Bit and expose them such that a Prometheus instance can scrape them. <br /> **Important Note: The prometheus exporter only works with metric plugins, such as Node Exporter Metrics** <br /> **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/outputs/prometheus-exporter**


| Field | Description | Scheme |
| ----- | ----------- | ------ |
| host | IP address or hostname of the target HTTP Server, default: 0.0.0.0 | string |
| port | This is the port Fluent Bit will bind to when hosting prometheus metrics. | *int32 |
| addLabels | This allows you to add custom labels to all metrics exposed through the prometheus exporter. You may have multiple of these fields | map[string]string |
Loading

0 comments on commit 9f220bc

Please sign in to comment.