Skip to content

Commit 5a4a5f6

Browse files
author
Benjamin Huo
authored
Merge pull request #125 from wanjunlei/master
Add supports for Amazon ElasticSearch Service and Elastic's Elasticse…
2 parents 57ca429 + 639d304 commit 5a4a5f6

File tree

5 files changed

+1221
-3305
lines changed

5 files changed

+1221
-3305
lines changed

api/fluentbitoperator/v1alpha2/plugins/output/elasticsearch_types.go

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
// +kubebuilder:object:generate:=true
1010

11-
// The es output plugin, allows to ingest your records into a Elasticsearch database.
11+
// Elasticsearch is the es output plugin, allows to ingest your records into an Elasticsearch database.
1212
type Elasticsearch struct {
1313
// IP address or hostname of the target Elasticsearch instance
1414
Host string `json:"host,omitempty"`
@@ -28,11 +28,25 @@ type Elasticsearch struct {
2828
// otherwise the value must be according to the Unit Size specification.
2929
// +kubebuilder:validation:Pattern:="^\\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$"
3030
BufferSize string `json:"bufferSize,omitempty"`
31-
// Newer versions of Elasticsearch allows to setup filters called pipelines.
32-
// This option allows to define which pipeline the database should use.
33-
// For performance reasons is strongly suggested to do parsing
31+
// Newer versions of Elasticsearch allows setting up filters called pipelines.
32+
// This option allows defining which pipeline the database should use.
33+
// For performance reasons is strongly suggested parsing
3434
// and filtering on Fluent Bit side, avoid pipelines.
3535
Pipeline string `json:"pipeline,omitempty"`
36+
// Enable AWS Sigv4 Authentication for Amazon ElasticSearch Service.
37+
AWSAuth string `json:"awsAuth,omitempty"`
38+
// Specify the AWS region for Amazon ElasticSearch Service.
39+
AWSRegion string `json:"awsRegion,omitempty"`
40+
// Specify the custom sts endpoint to be used with STS API for Amazon ElasticSearch Service.
41+
AWSSTSEndpoint string `json:"awsSTSEndpoint,omitempty"`
42+
// AWS IAM Role to assume to put records to your Amazon ES cluster.
43+
AWSRoleARN string `json:"awsRoleARN,omitempty"`
44+
// External ID for the AWS IAM Role specified with aws_role_arn.
45+
AWSExternalID string `json:"awsExternalID,omitempty"`
46+
// If you are using Elastic's Elasticsearch Service you can specify the cloud_id of the cluster running.
47+
CloudID string `json:"cloudID,omitempty"`
48+
// Specify the credentials to use to connect to Elastic's Elasticsearch Service running on Elastic Cloud.
49+
CloudAuth string `json:"cloudAuth,omitempty"`
3650
// Optional username credential for Elastic X-Pack access
3751
HTTPUser *plugins.Secret `json:"httpUser,omitempty"`
3852
// Password for user defined in HTTP_User
@@ -62,6 +76,8 @@ type Elasticsearch struct {
6276
// When enabled, generate _id for outgoing records.
6377
// This prevents duplicate records when retrying ES.
6478
GenerateID *bool `json:"generateID,omitempty"`
79+
// If set, _id will be the value of the key from incoming record and Generate_ID option is ignored.
80+
IdKey string `json:"idKey,omitempty"`
6581
// When enabled, replace field name dots with underscore, required by Elasticsearch 2.0-2.3.
6682
ReplaceDots *bool `json:"replaceDots,omitempty"`
6783
// When enabled print the elasticsearch API calls to stdout (for diag only)
@@ -72,15 +88,17 @@ type Elasticsearch struct {
7288
CurrentTimeIndex *bool `json:"currentTimeIndex,omitempty"`
7389
// Prefix keys with this string
7490
LogstashPrefixKey string `json:"logstashPrefixKey,omitempty"`
75-
*plugins.TLS `json:"tls,omitempty"`
91+
// 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.
92+
SuppressTypeName string `json:"suppressTypeName,omitempty"`
93+
*plugins.TLS `json:"tls,omitempty"`
7694
}
7795

78-
// implement Section() method
96+
// Name implement Section() method
7997
func (_ *Elasticsearch) Name() string {
8098
return "es"
8199
}
82100

83-
// implement Section() method
101+
// Params implement Section() method
84102
func (es *Elasticsearch) Params(sl plugins.SecretLoader) (*plugins.KVs, error) {
85103
kvs := plugins.NewKVs()
86104
if es.Host != "" {
@@ -98,6 +116,27 @@ func (es *Elasticsearch) Params(sl plugins.SecretLoader) (*plugins.KVs, error) {
98116
if es.Pipeline != "" {
99117
kvs.Insert("Pipeline", es.Pipeline)
100118
}
119+
if es.AWSAuth != "" {
120+
kvs.Insert("AWS_Auth", es.AWSAuth)
121+
}
122+
if es.AWSRegion != "" {
123+
kvs.Insert("AWS_Region", es.AWSRegion)
124+
}
125+
if es.AWSSTSEndpoint != "" {
126+
kvs.Insert("AWS_STS_Endpoint", es.AWSSTSEndpoint)
127+
}
128+
if es.AWSRoleARN != "" {
129+
kvs.Insert("AWS_Role_ARN", es.AWSRoleARN)
130+
}
131+
if es.CloudID != "" {
132+
kvs.Insert("Cloud_ID", es.CloudID)
133+
}
134+
if es.CloudAuth != "" {
135+
kvs.Insert("Cloud_Auth", es.CloudAuth)
136+
}
137+
if es.AWSExternalID != "" {
138+
kvs.Insert("AWS_External_ID", es.AWSExternalID)
139+
}
101140
if es.HTTPUser != nil {
102141
u, err := sl.LoadSecret(*es.HTTPUser)
103142
if err != nil {
@@ -142,6 +181,9 @@ func (es *Elasticsearch) Params(sl plugins.SecretLoader) (*plugins.KVs, error) {
142181
if es.GenerateID != nil {
143182
kvs.Insert("Generate_ID", fmt.Sprint(*es.GenerateID))
144183
}
184+
if es.IdKey != "" {
185+
kvs.Insert("ID_KEY", es.IdKey)
186+
}
145187
if es.ReplaceDots != nil {
146188
kvs.Insert("Replace_Dots", fmt.Sprint(*es.ReplaceDots))
147189
}
@@ -157,6 +199,9 @@ func (es *Elasticsearch) Params(sl plugins.SecretLoader) (*plugins.KVs, error) {
157199
if es.LogstashPrefixKey != "" {
158200
kvs.Insert("Logstash_Prefix_Key", es.LogstashPrefixKey)
159201
}
202+
if es.SuppressTypeName != "" {
203+
kvs.Insert("Suppress_Type_Name", es.SuppressTypeName)
204+
}
160205
if es.TLS != nil {
161206
tls, err := es.TLS.Params(sl)
162207
if err != nil {

api/fluentbitoperator/v1alpha2/plugins/tls_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type TLS struct {
3030

3131
func (t *TLS) Params(sl SecretLoader) (*KVs, error) {
3232
kvs := NewKVs()
33-
kvs.Insert("tls", "true")
33+
kvs.Insert("tls", "On")
3434
if t.Verify != nil {
3535
kvs.Insert("tls.verify", fmt.Sprint(*t.Verify))
3636
}

config/crd/bases/logging.kubesphere.io_outputs.yaml

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ spec:
4343
es:
4444
description: Elasticsearch defines Elasticsearch Output configuration.
4545
properties:
46+
awsAuth:
47+
description: Enable AWS Sigv4 Authentication for Amazon ElasticSearch
48+
Service.
49+
type: string
50+
awsExternalID:
51+
description: External ID for the AWS IAM Role specified with aws_role_arn.
52+
type: string
53+
awsRegion:
54+
description: Specify the AWS region for Amazon ElasticSearch Service.
55+
type: string
56+
awsRoleARN:
57+
description: AWS IAM Role to assume to put records to your Amazon
58+
ES cluster.
59+
type: string
60+
awsSTSEndpoint:
61+
description: Specify the custom sts endpoint to be used with STS
62+
API for Amazon ElasticSearch Service.
63+
type: string
4664
bufferSize:
4765
description: Specify the buffer size used to read the response
4866
from the Elasticsearch HTTP service. This option is useful for
@@ -53,6 +71,14 @@ spec:
5371
Size specification.
5472
pattern: ^\d+(k|K|KB|kb|m|M|MB|mb|g|G|GB|gb)?$
5573
type: string
74+
cloudAuth:
75+
description: Specify the credentials to use to connect to Elastic's
76+
Elasticsearch Service running on Elastic Cloud.
77+
type: string
78+
cloudID:
79+
description: If you are using Elastic's Elasticsearch Service
80+
you can specify the cloud_id of the cluster running.
81+
type: string
5682
currentTimeIndex:
5783
description: Use current time for index generation instead of
5884
message record
@@ -121,6 +147,10 @@ spec:
121147
type: object
122148
type: object
123149
type: object
150+
idKey:
151+
description: If set, _id will be the value of the key from incoming
152+
record and Generate_ID option is ignored.
153+
type: string
124154
includeTagKey:
125155
description: When enabled, it append the Tag name to the record.
126156
type: boolean
@@ -153,11 +183,11 @@ spec:
153183
indexing HTTP POST URI.
154184
type: string
155185
pipeline:
156-
description: Newer versions of Elasticsearch allows to setup filters
157-
called pipelines. This option allows to define which pipeline
158-
the database should use. For performance reasons is strongly
159-
suggested to do parsing and filtering on Fluent Bit side, avoid
160-
pipelines.
186+
description: Newer versions of Elasticsearch allows setting up
187+
filters called pipelines. This option allows defining which
188+
pipeline the database should use. For performance reasons is
189+
strongly suggested parsing and filtering on Fluent Bit side,
190+
avoid pipelines.
161191
type: string
162192
port:
163193
description: TCP port of the target Elasticsearch instance
@@ -169,6 +199,11 @@ spec:
169199
description: When enabled, replace field name dots with underscore,
170200
required by Elasticsearch 2.0-2.3.
171201
type: boolean
202+
suppressTypeName:
203+
description: When enabled, mapping types is removed and Type option
204+
is ignored. Types are deprecated in APIs in v7.0. This options
205+
is for v7.0 or later.
206+
type: string
172207
tagKey:
173208
description: When Include_Tag_Key is enabled, this property defines
174209
the key name for the tag.

0 commit comments

Comments
 (0)