-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: chengdehao <dehaocheng@yunify.com>
- Loading branch information
Showing
9 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
api/fluentbitoperator/v1alpha2/plugins/filter/aws_types.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package filter | ||
|
||
import ( | ||
"fmt" | ||
|
||
"kubesphere.io/fluentbit-operator/api/fluentbitoperator/v1alpha2/plugins" | ||
"kubesphere.io/fluentbit-operator/api/fluentbitoperator/v1alpha2/plugins/params" | ||
) | ||
|
||
// +kubebuilder:object:generate:=true | ||
|
||
// The AWS Filter Enriches logs with AWS Metadata. Currently the plugin adds the EC2 instance ID and availability zone to log records. | ||
type AWS struct { | ||
// Specify which version of the instance metadata service to use. Valid values are 'v1' or 'v2'. | ||
// +kubebuilder:validation:Enum:=v1;v2 | ||
ImdsVersion string `json:"imdsVersion,omitempty"` | ||
// The availability zone; for example, "us-east-1a". Default is true. | ||
AZ *bool `json:"az,omitempty"` | ||
//The EC2 instance ID.Default is true. | ||
EC2InstanceID *bool `json:"ec2InstanceID,omitempty"` | ||
//The EC2 instance type.Default is false. | ||
EC2InstanceType *bool `json:"ec2InstanceType,omitempty"` | ||
//The EC2 instance private ip.Default is false. | ||
PrivateIP *bool `json:"privateIP,omitempty"` | ||
//The EC2 instance image id.Default is false. | ||
AmiID *bool `json:"amiID,omitempty"` | ||
//The account ID for current EC2 instance.Default is false. | ||
AccountID *bool `json:"accountID,omitempty"` | ||
//The hostname for current EC2 instance.Default is false. | ||
HostName *bool `json:"hostName,omitempty"` | ||
//The VPC ID for current EC2 instance.Default is false. | ||
VpcID *bool `json:"vpcID,omitempty"` | ||
} | ||
|
||
func (_ *AWS) Name() string { | ||
return "aws" | ||
} | ||
|
||
func (a *AWS) Params(_ plugins.SecretLoader) (*params.KVs, error) { | ||
kvs := params.NewKVs() | ||
if a.ImdsVersion != "" { | ||
kvs.Insert("imds_version", a.ImdsVersion) | ||
} | ||
if a.AZ != nil { | ||
kvs.Insert("az", fmt.Sprint(*a.AZ)) | ||
} | ||
if a.EC2InstanceID != nil { | ||
kvs.Insert("ec2_instance_id", fmt.Sprint(*a.EC2InstanceID)) | ||
} | ||
if a.EC2InstanceType != nil { | ||
kvs.Insert("ec2_instance_type", fmt.Sprint(*a.EC2InstanceType)) | ||
} | ||
if a.PrivateIP != nil { | ||
kvs.Insert("private_ip", fmt.Sprint(*a.PrivateIP)) | ||
} | ||
if a.AmiID != nil { | ||
kvs.Insert("ami_id", fmt.Sprint(*a.AmiID)) | ||
} | ||
if a.AccountID != nil { | ||
kvs.Insert("account_id", fmt.Sprint(*a.AccountID)) | ||
} | ||
if a.HostName != nil { | ||
kvs.Insert("hostname", fmt.Sprint(*a.HostName)) | ||
} | ||
if a.VpcID != nil { | ||
kvs.Insert("vpc_id", fmt.Sprint(*a.VpcID)) | ||
} | ||
return kvs, nil | ||
} |
55 changes: 55 additions & 0 deletions
55
api/fluentbitoperator/v1alpha2/plugins/filter/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# AWS Metadata | ||
|
||
The AWS Filter Enriches logs with AWS Metadata. Currently the plugin adds the EC2 instance ID and availability zone to log records. To use this plugin, you must be running in EC2 and have the [instance metadata service enabled](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html). | ||
|
||
|
||
| Field | Description | Scheme |Default| | ||
| ----- | ----------- | ------ | -----| | ||
| imds_version | Specify which version of the instance metadata service to use. Valid values are 'v1' or 'v2'. | string |v2| | ||
| az | The availability zone; for example, "us-east-1a". | bool |true| | ||
| ec2_instance_id | The EC2 instance ID. | bool |true| | ||
| ec2_instance_type | The EC2 instance type. | bool |false| | ||
| private_ip | The EC2 instance private ip.| bool |false| | ||
| ami_id | The EC2 instance image id. | bool |false| | ||
| account_id | The account ID for current EC2 instance. | bool |false| | ||
| hostname | The hostname for current EC2 instance.| bool |false| | ||
| vpc_id | The VPC ID for current EC2 instance. | bool |false| | ||
|
||
|
||
Note: If you run Fluent Bit in a container, you may have to use instance metadata v1. The plugin behaves the same regardless of which version is used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters