diff --git a/api/fluentbitoperator/v1alpha2/output_types.go b/api/fluentbitoperator/v1alpha2/output_types.go index 506c48caf..61a2ffbc1 100644 --- a/api/fluentbitoperator/v1alpha2/output_types.go +++ b/api/fluentbitoperator/v1alpha2/output_types.go @@ -60,6 +60,8 @@ type OutputSpec struct { Loki *output.Loki `json:"loki,omitempty"` // Syslog defines Syslog Output configuration. Syslog *output.Syslog `json:"syslog,omitempty"` + // DataDog defines DataDog Output configuration. + DataDog *output.DataDog `json:"datadog,omitempty"` } // +kubebuilder:object:root=true diff --git a/api/fluentbitoperator/v1alpha2/plugins/filter/zz_generated.deepcopy.go b/api/fluentbitoperator/v1alpha2/plugins/filter/zz_generated.deepcopy.go index aec513c26..150ebfbf1 100644 --- a/api/fluentbitoperator/v1alpha2/plugins/filter/zz_generated.deepcopy.go +++ b/api/fluentbitoperator/v1alpha2/plugins/filter/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* diff --git a/api/fluentbitoperator/v1alpha2/plugins/input/zz_generated.deepcopy.go b/api/fluentbitoperator/v1alpha2/plugins/input/zz_generated.deepcopy.go index 3e1cca9a5..1cb454491 100644 --- a/api/fluentbitoperator/v1alpha2/plugins/input/zz_generated.deepcopy.go +++ b/api/fluentbitoperator/v1alpha2/plugins/input/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* diff --git a/api/fluentbitoperator/v1alpha2/plugins/output/datadog_types.go b/api/fluentbitoperator/v1alpha2/plugins/output/datadog_types.go new file mode 100644 index 000000000..f0e8caafe --- /dev/null +++ b/api/fluentbitoperator/v1alpha2/plugins/output/datadog_types.go @@ -0,0 +1,95 @@ +package output + +import ( + "fmt" + + "kubesphere.io/fluentbit-operator/api/fluentbitoperator/v1alpha2/plugins" + "kubesphere.io/fluentbit-operator/api/fluentbitoperator/v1alpha2/plugins/params" +) + +// +kubebuilder:object:generate:=true + +// DataDog output plugin allows you to ingest your logs into Datadog. +type DataDog struct { + // Host is the Datadog server where you are sending your logs. + Host string `json:"host,omitempty"` + // TLS controls whether to use end-to-end security communications security protocol. + // Datadog recommends setting this to on. + TLS *bool `json:"tls,omitempty"` + // Compress the payload in GZIP format. + // Datadog supports and recommends setting this to gzip. + Compress string `json:"compress,omitempty"` + // Your Datadog API key. + APIKey string `json:"apikey,omitempty"` + // Specify an HTTP Proxy. + Proxy string `json:"proxy,omitempty"` + // To activate the remapping, specify configuration flag provider. + Provider string `json:"provider,omitempty"` + // Date key name for output. + JSONDateKey string `json:"json_date_key,omitempty"` + // If enabled, a tag is appended to output. The key name is used tag_key property. + IncludeTagKey *bool `json:"include_tag_key,omitempty"` + // The key name of tag. If include_tag_key is false, This property is ignored. + TagKey string `json:"tag_key,omitempty"` + // The human readable name for your service generating the logs. + Service string `json:"dd_service,omitempty"` + // A human readable name for the underlying technology of your service. + Source string `json:"dd_source,omitempty"` + // The tags you want to assign to your logs in Datadog. + Tags string `json:"dd_tags,omitempty"` + // By default, the plugin searches for the key 'log' and remap the value to the key 'message'. If the property is set, the plugin will search the property name key. + MessageKey string `json:"dd_message_key,omitempty"` + + // *plugins.HTTP `json:"tls,omitempty"` +} + +func (_ *DataDog) Name() string { + return "datadog" +} + +// implement Section() method +func (s *DataDog) Params(sl plugins.SecretLoader) (*params.KVs, error) { + kvs := params.NewKVs() + + if s.Host != "" { + kvs.Insert("Host", s.Host) + } + if s.TLS != nil { + kvs.Insert("TLS", fmt.Sprint(*s.TLS)) + } + if s.Compress != "" { + kvs.Insert("compress", s.Compress) + } + if s.APIKey != "" { + kvs.Insert("apikey", s.APIKey) + } + if s.Proxy != "" { + kvs.Insert("proxy", s.Proxy) + } + if s.Provider != "" { + kvs.Insert("provider", s.Provider) + } + if s.JSONDateKey != "" { + kvs.Insert("json_date_key", s.JSONDateKey) + } + if s.IncludeTagKey != nil { + kvs.Insert("include_tag_key", fmt.Sprint(*s.IncludeTagKey)) + } + if s.TagKey != "" { + kvs.Insert("tag_key", s.TagKey) + } + if s.Service != "" { + kvs.Insert("dd_service", s.Service) + } + if s.Source != "" { + kvs.Insert("dd_source", s.Source) + } + if s.Tags != "" { + kvs.Insert("dd_tags", s.Tags) + } + if s.MessageKey != "" { + kvs.Insert("dd_message_key", s.MessageKey) + } + + return kvs, nil +} diff --git a/api/fluentbitoperator/v1alpha2/plugins/output/datadog_types_test.go b/api/fluentbitoperator/v1alpha2/plugins/output/datadog_types_test.go new file mode 100644 index 000000000..c79e0c72b --- /dev/null +++ b/api/fluentbitoperator/v1alpha2/plugins/output/datadog_types_test.go @@ -0,0 +1,51 @@ +package output + +import ( + "testing" + + . "github.com/onsi/gomega" + "kubesphere.io/fluentbit-operator/api/fluentbitoperator/v1alpha2/plugins" + "kubesphere.io/fluentbit-operator/api/fluentbitoperator/v1alpha2/plugins/params" +) + +func TestOutput_DataDog_Params(t *testing.T) { + g := NewGomegaWithT(t) + + sl := plugins.NewSecretLoader(nil, "test namespace", nil) + + dd := DataDog{ + Host: "http-intake.logs.datadoghq.com", + APIKey: "1234apikey", + TLS: ptrBool(true), + Compress: "gzip", + Service: "service_name", + Source: "app_name", + Tags: "foo:bar", + MessageKey: "message", + JSONDateKey: "timestamp", + IncludeTagKey: ptrBool(true), + TagKey: "tagkey", + } + + expected := params.NewKVs() + expected.Insert("Host", "http-intake.logs.datadoghq.com") + expected.Insert("TLS", "true") + expected.Insert("compress", "gzip") + expected.Insert("apikey", "1234apikey") + expected.Insert("json_date_key", "timestamp") + expected.Insert("include_tag_key", "true") + expected.Insert("tag_key", "tagkey") + expected.Insert("dd_service", "service_name") + expected.Insert("dd_source", "app_name") + expected.Insert("dd_tags", "foo:bar") + expected.Insert("dd_message_key", "message") + + kvs, err := dd.Params(sl) + g.Expect(err).NotTo(HaveOccurred()) + g.Expect(kvs).To(Equal(expected)) + +} + +func ptrBool(v bool) *bool { + return &v +} diff --git a/api/fluentbitoperator/v1alpha2/plugins/output/zz_generated.deepcopy.go b/api/fluentbitoperator/v1alpha2/plugins/output/zz_generated.deepcopy.go index ac0260f47..e96cafbfc 100644 --- a/api/fluentbitoperator/v1alpha2/plugins/output/zz_generated.deepcopy.go +++ b/api/fluentbitoperator/v1alpha2/plugins/output/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* @@ -23,6 +24,31 @@ import ( "kubesphere.io/fluentbit-operator/api/fluentbitoperator/v1alpha2/plugins" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DataDog) DeepCopyInto(out *DataDog) { + *out = *in + if in.TLS != nil { + in, out := &in.TLS, &out.TLS + *out = new(bool) + **out = **in + } + if in.IncludeTagKey != nil { + in, out := &in.IncludeTagKey, &out.IncludeTagKey + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DataDog. +func (in *DataDog) DeepCopy() *DataDog { + if in == nil { + return nil + } + out := new(DataDog) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Elasticsearch) DeepCopyInto(out *Elasticsearch) { *out = *in diff --git a/api/fluentbitoperator/v1alpha2/plugins/parser/zz_generated.deepcopy.go b/api/fluentbitoperator/v1alpha2/plugins/parser/zz_generated.deepcopy.go index ca280c232..cfed70272 100644 --- a/api/fluentbitoperator/v1alpha2/plugins/parser/zz_generated.deepcopy.go +++ b/api/fluentbitoperator/v1alpha2/plugins/parser/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* diff --git a/api/fluentbitoperator/v1alpha2/plugins/zz_generated.deepcopy.go b/api/fluentbitoperator/v1alpha2/plugins/zz_generated.deepcopy.go index a0668a95e..18604b8d7 100644 --- a/api/fluentbitoperator/v1alpha2/plugins/zz_generated.deepcopy.go +++ b/api/fluentbitoperator/v1alpha2/plugins/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* diff --git a/api/fluentbitoperator/v1alpha2/zz_generated.deepcopy.go b/api/fluentbitoperator/v1alpha2/zz_generated.deepcopy.go index 5a58b3848..3ffb3aab4 100644 --- a/api/fluentbitoperator/v1alpha2/zz_generated.deepcopy.go +++ b/api/fluentbitoperator/v1alpha2/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* @@ -584,6 +585,11 @@ func (in *OutputSpec) DeepCopyInto(out *OutputSpec) { *out = new(output.Syslog) (*in).DeepCopyInto(*out) } + if in.DataDog != nil { + in, out := &in.DataDog, &out.DataDog + *out = new(output.DataDog) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OutputSpec. diff --git a/config/crd/bases/logging.kubesphere.io_outputs.yaml b/config/crd/bases/logging.kubesphere.io_outputs.yaml index b0775c25b..80cecadbb 100644 --- a/config/crd/bases/logging.kubesphere.io_outputs.yaml +++ b/config/crd/bases/logging.kubesphere.io_outputs.yaml @@ -40,6 +40,59 @@ spec: description: A user friendly alias name for this output plugin. Used in metrics for distinction of each configured output. type: string + datadog: + description: DataDog defines DataDog Output configuration. + properties: + apikey: + description: Your Datadog API key. + type: string + compress: + description: Compress the payload in GZIP format. Datadog supports + and recommends setting this to gzip. + type: string + dd_message_key: + description: By default, the plugin searches for the key 'log' + and remap the value to the key 'message'. If the property is + set, the plugin will search the property name key. + type: string + dd_service: + description: The human readable name for your service generating + the logs. + type: string + dd_source: + description: A human readable name for the underlying technology + of your service. + type: string + dd_tags: + description: The tags you want to assign to your logs in Datadog. + type: string + host: + description: Host is the Datadog server where you are sending + your logs. + type: string + include_tag_key: + description: If enabled, a tag is appended to output. The key + name is used tag_key property. + type: boolean + json_date_key: + description: Date key name for output. + type: string + provider: + description: To activate the remapping, specify configuration + flag provider. + type: string + proxy: + description: Specify an HTTP Proxy. + type: string + tag_key: + description: The key name of tag. If include_tag_key is false, + This property is ignored. + type: string + tls: + description: TLS controls whether to use end-to-end security communications + security protocol. Datadog recommends setting this to on. + type: boolean + type: object es: description: Elasticsearch defines Elasticsearch Output configuration. properties: diff --git a/manifests/setup/fluentbit-operator-crd.yaml b/manifests/setup/fluentbit-operator-crd.yaml index b9f37a531..5202bb0d2 100644 --- a/manifests/setup/fluentbit-operator-crd.yaml +++ b/manifests/setup/fluentbit-operator-crd.yaml @@ -3399,6 +3399,59 @@ spec: description: A user friendly alias name for this output plugin. Used in metrics for distinction of each configured output. type: string + datadog: + description: DataDog defines DataDog Output configuration. + properties: + apikey: + description: Your Datadog API key. + type: string + compress: + description: Compress the payload in GZIP format. Datadog supports + and recommends setting this to gzip. + type: string + dd_message_key: + description: By default, the plugin searches for the key 'log' + and remap the value to the key 'message'. If the property is + set, the plugin will search the property name key. + type: string + dd_service: + description: The human readable name for your service generating + the logs. + type: string + dd_source: + description: A human readable name for the underlying technology + of your service. + type: string + dd_tags: + description: The tags you want to assign to your logs in Datadog. + type: string + host: + description: Host is the Datadog server where you are sending + your logs. + type: string + include_tag_key: + description: If enabled, a tag is appended to output. The key + name is used tag_key property. + type: boolean + json_date_key: + description: Date key name for output. + type: string + provider: + description: To activate the remapping, specify configuration + flag provider. + type: string + proxy: + description: Specify an HTTP Proxy. + type: string + tag_key: + description: The key name of tag. If include_tag_key is false, + This property is ignored. + type: string + tls: + description: TLS controls whether to use end-to-end security communications + security protocol. Datadog recommends setting this to on. + type: boolean + type: object es: description: Elasticsearch defines Elasticsearch Output configuration. properties: diff --git a/manifests/setup/setup.yaml b/manifests/setup/setup.yaml index 91428a1d6..387ee5466 100644 --- a/manifests/setup/setup.yaml +++ b/manifests/setup/setup.yaml @@ -3404,6 +3404,59 @@ spec: description: A user friendly alias name for this output plugin. Used in metrics for distinction of each configured output. type: string + datadog: + description: DataDog defines DataDog Output configuration. + properties: + apikey: + description: Your Datadog API key. + type: string + compress: + description: Compress the payload in GZIP format. Datadog supports + and recommends setting this to gzip. + type: string + dd_message_key: + description: By default, the plugin searches for the key 'log' + and remap the value to the key 'message'. If the property is + set, the plugin will search the property name key. + type: string + dd_service: + description: The human readable name for your service generating + the logs. + type: string + dd_source: + description: A human readable name for the underlying technology + of your service. + type: string + dd_tags: + description: The tags you want to assign to your logs in Datadog. + type: string + host: + description: Host is the Datadog server where you are sending + your logs. + type: string + include_tag_key: + description: If enabled, a tag is appended to output. The key + name is used tag_key property. + type: boolean + json_date_key: + description: Date key name for output. + type: string + provider: + description: To activate the remapping, specify configuration + flag provider. + type: string + proxy: + description: Specify an HTTP Proxy. + type: string + tag_key: + description: The key name of tag. If include_tag_key is false, + This property is ignored. + type: string + tls: + description: TLS controls whether to use end-to-end security communications + security protocol. Datadog recommends setting this to on. + type: boolean + type: object es: description: Elasticsearch defines Elasticsearch Output configuration. properties: