Skip to content

Commit

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

Signed-off-by: sjliu1 <sj_liu123@163.com>

* [summerospp]add fluentbit http plugin

Signed-off-by: “sjliu1” <“sj_liu123@163.com”>

* .DS_Store banished!

* Delete .DS_Store

---------

Signed-off-by: sjliu1 <sj_liu123@163.com>
Signed-off-by: “sjliu1” <“sj_liu123@163.com”>
Co-authored-by: “sjliu1” <“sj_liu123@163.com”>
  • Loading branch information
sjliu1 and “sjliu1” committed Sep 4, 2023
1 parent 76b5297 commit a669907
Show file tree
Hide file tree
Showing 12 changed files with 549 additions and 4 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 @@ -57,6 +57,8 @@ type InputSpec struct {
Forward *input.Forward `json:"forward,omitempty"`
// OpenTelemetry defines forward input plugin configuration
OpenTelemetry *input.OpenTelemetry `json:"openTelemetry,omitempty"`
// HTTP defines forward input plugin configuration
HTTP *input.HTTP `json:"http,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
73 changes: 73 additions & 0 deletions apis/fluentbit/v1alpha2/plugins/input/http.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
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 HTTP input plugin allows you to send custom records to an HTTP endpoint.
// **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/http**
type HTTP 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 9880
// +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"`
// 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"`
// Add an HTTP header key/value pair on success. Multiple headers can be set. Example: X-Custom custom-answer.
SuccessfulHeader string `json:"successfulHeader,omitempty"`
*plugins.TLS `json:"tls,omitempty"`
}

func (_ *HTTP) Name() string {
return "http"
}

// Params implement Section() method
func (h *HTTP) Params(sl plugins.SecretLoader) (*params.KVs, error) {
kvs := params.NewKVs()
if h.Listen != "" {
kvs.Insert("listen", h.Listen)
}
if h.Port != nil {
kvs.Insert("port", fmt.Sprint(*h.Port))
}
if h.Tagkey != "" {
kvs.Insert("tag_key", h.Tagkey)
}
if h.BufferMaxSize != "" {
kvs.Insert("buffer_max_size", h.BufferMaxSize)
}
if h.BufferChunkSize != "" {
kvs.Insert("buffer_chunk_size", h.BufferChunkSize)
}
if h.SuccessfulResponseCode != nil {
kvs.Insert("successful_response_code", fmt.Sprint(*h.SuccessfulResponseCode))
}
if h.SuccessfulHeader != "" {
kvs.Insert("success_header", h.SuccessfulHeader)
}
if h.TLS != nil {
tls, err := h.TLS.Params(sl)
if err != nil {
return nil, err
}
kvs.Merge(tls)
}
return kvs, nil
}
34 changes: 33 additions & 1 deletion 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 @@ -123,6 +123,110 @@ spec:
description: Set the permission of unix socket file.
type: string
type: object
http:
description: HTTP 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 9880
format: int32
maximum: 65535
minimum: 1
type: integer
successfulHeader:
description: 'Add an HTTP header key/value pair on success. Multiple
headers can be set. Example: X-Custom custom-answer.'
type: string
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
tls:
description: Fluent Bit provides integrated support for Transport
Layer Security (TLS) and it predecessor Secure Sockets Layer
(SSL) respectively.
properties:
caFile:
description: Absolute path to CA certificate file
type: string
caPath:
description: Absolute path to scan for certificate files
type: string
crtFile:
description: Absolute path to Certificate file
type: string
debug:
description: 'Set TLS debug verbosity level. It accept the
following values: 0 (No debug), 1 (Error), 2 (State change),
3 (Informational) and 4 Verbose'
enum:
- 0
- 1
- 2
- 3
- 4
format: int32
type: integer
keyFile:
description: Absolute path to private Key file
type: string
keyPassword:
description: Optional password for tls.key_file file
properties:
valueFrom:
description: ValueSource defines how to find a value's
key.
properties:
secretKeyRef:
description: Selects a key of a secret in the pod's
namespace
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info:
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the Secret or its
key must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
type: object
type: object
verify:
description: Force certificate validation
type: boolean
vhost:
description: Hostname to be used for TLS SNI extension
type: string
type: object
type: object
logLevel:
enum:
- "off"
Expand Down
104 changes: 104 additions & 0 deletions config/crd/bases/fluentbit.fluent.io_clusterinputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,110 @@ spec:
description: Set the permission of unix socket file.
type: string
type: object
http:
description: HTTP 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 9880
format: int32
maximum: 65535
minimum: 1
type: integer
successfulHeader:
description: 'Add an HTTP header key/value pair on success. Multiple
headers can be set. Example: X-Custom custom-answer.'
type: string
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
tls:
description: Fluent Bit provides integrated support for Transport
Layer Security (TLS) and it predecessor Secure Sockets Layer
(SSL) respectively.
properties:
caFile:
description: Absolute path to CA certificate file
type: string
caPath:
description: Absolute path to scan for certificate files
type: string
crtFile:
description: Absolute path to Certificate file
type: string
debug:
description: 'Set TLS debug verbosity level. It accept the
following values: 0 (No debug), 1 (Error), 2 (State change),
3 (Informational) and 4 Verbose'
enum:
- 0
- 1
- 2
- 3
- 4
format: int32
type: integer
keyFile:
description: Absolute path to private Key file
type: string
keyPassword:
description: Optional password for tls.key_file file
properties:
valueFrom:
description: ValueSource defines how to find a value's
key.
properties:
secretKeyRef:
description: Selects a key of a secret in the pod's
namespace
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info:
https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind,
uid?'
type: string
optional:
description: Specify whether the Secret or its
key must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
type: object
type: object
verify:
description: Force certificate validation
type: boolean
vhost:
description: Hostname to be used for TLS SNI extension
type: string
type: object
type: object
logLevel:
enum:
- "off"
Expand Down
1 change: 1 addition & 0 deletions docs/fluentbit.md
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ InputSpec defines the desired state of ClusterInput
| 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) |
| http | HTTP defines forward input plugin configuration | *[input.OpenTelemetry](plugins/input/opentelemetry.md) |

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

The HTTP input plugin allows you to send custom records to an HTTP endpoint. **For full documentation, refer to https://docs.fluentbit.io/manual/pipeline/inputs/http**


| 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 9880 | *int32 |
| tagKey | Specify the key name to overwrite a tag. If set, the tag will be overwritten by a value of the key. | string |
| 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 |
| successfulHeader | Add an HTTP header key/value pair on success. Multiple headers can be set. Example: X-Custom custom-answer. | string |
| tls | | *[plugins.TLS](../tls.md) |

0 comments on commit a669907

Please sign in to comment.