Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Splunk output-types for fluentbit #417

Merged
merged 6 commits into from
Oct 10, 2022

Conversation

momoXD007
Copy link
Contributor

What this PR does / why we need it:

This PR adds the ability to fluent-operator to configure Splunk as an output for fluentbit. Fluentbit already supports Splunk as output but so far fluent-operator simply can not configure a fluentbit-pod to actually make use of that. This PR intends to change that.
In other words it enables users of the fluent-operator to use more of the features fluentbit already has.

I am not an experienced go-developer and have simply used similar PRs (e.g.: PRs that add the opensearch-output types) and fluentbits' documentation for Splunk (here) as base for my work.
Please review and test carefully.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduced a user-facing change?

None

Additional documentation, usage docs, etc.:

- [How to configure Splunk in fluentbit] https://docs.fluentbit.io/manual/pipeline/outputs/splunk

Signed-off-by: Michael J. Wieneke <m.wieneke@sap.com>
Signed-off-by: Michael J. Wieneke <m.wieneke@sap.com>
// +kubebuilder:validation:Maximum:=65535
Port *int32 `json:"port,omitempty"`
// Specify the Authentication Token for the HTTP Event Collector interface.
SplunkToken string `json:"splunk_token,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe splunkToken is better

HTTPPasswd *plugins.Secret `json:"httpPassword,omitempty"`
// If the HTTP server response code is 400 (bad request) and this flag is enabled, it will print the full HTTP request
// and response to the stdout interface. This feature is available for debugging purposes.
HTTPDebugBadRequest bool `json:"httpDebugBadRequest,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTTPDebugBadRequest bool `json:"httpDebugBadRequest,omitempty"`
// When enabled, the record keys and values are set in the top level of the map instead of under the event key. Refer to
// the Sending Raw Events section from the docs for more details to make this option work properly.
SplunkSendRaw bool `json:"splunkSendRaw,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*bool

kvs.Insert("HTTP_Passwd", pwd)
}
if o.Compress != "" {
kvs.Insert("Index", o.Compress)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Index?

kvs.Insert("Index", o.Compress)
}
if o.Channel != "" {
kvs.Insert("Type", o.Channel)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type is wrong.

@benjaminhuo
Copy link
Member

@wanjunlei would you help to review this?
@wenchajun What else should @momoXD007 do to fix the helm e2e error? https://github.com/fluent/fluent-operator/actions/runs/3203685595/jobs/5236604040

@wenchajun
Copy link
Member

These two commands should be executed after the changes are made.

make manifests
make generate

if o.SplunkToken != "" {
kvs.Insert("Splunk_Token", o.SplunkToken)
}
if o.BufferSize != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be http_buffer_size

func (o *Splunk) Params(sl plugins.SecretLoader) (*params.KVs, error) {
kvs := params.NewKVs()
if o.Host != "" {
kvs.Insert("Host", o.Host)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uppercase is not recommended for code consistency.

kvs.Insert("Host", o.Host) => kvs.Insert("host", o.Host)

Others also need to be modified.

if o.HTTPDebugBadRequest {
kvs.Insert("HTTP_Debug_Bad_Request", "On")
} else {
kvs.Insert("HTTP_Debug_Bad_Request", "Off")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is redundant, the default is Off.

if o.SplunkSendRaw {
kvs.Insert("Splunk_Send_Raw", "On")
} else {
kvs.Insert("Splunk_Send_Raw", "Off")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Signed-off-by: Michael J. Wieneke <m.wieneke@sap.com>
Signed-off-by: Michael J. Wieneke <m.wieneke@sap.com>
Signed-off-by: Michael J. Wieneke <m.wieneke@sap.com>
@momoXD007
Copy link
Contributor Author

I hopefully fixed all findings n ow :) Thanks for looking into this so quickly

kvs.Insert("splunk_token", o.SplunkToken)
}
if o.BufferSize != "" {
kvs.Insert("buffer_size", o.BufferSize)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1665382280(1)

buffer_size => http_buffer_size

SplunkToken string `json:"splunkToken,omitempty"`
//Buffer size used to receive Splunk HTTP responses: Default `2M`
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
BufferSize string `json:"bufferSize,omitempty"`
Copy link
Member

@wenchajun wenchajun Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bufferSize -> httpBufferSize

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, ok that's what you meant, will fix that :)

Compress string `json:"compress,omitempty"`
// Specify X-Splunk-Request-Channel Header for the HTTP Event Collector interface.
Channel string `json:"channel,omitempty"`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need for a blank line here.

Signed-off-by: Michael J. Wieneke <m.wieneke@sap.com>
@benjaminhuo benjaminhuo merged commit e2dca72 into fluent:master Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants