-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for throttle filter plugin
Signed-off-by: Nicholas Tate <[email protected]>
- Loading branch information
Showing
10 changed files
with
1,832 additions
and
537 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
45 changes: 45 additions & 0 deletions
45
api/fluentbitoperator/v1alpha2/plugins/filter/throttle_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,45 @@ | ||
package filter | ||
|
||
import ( | ||
"fmt" | ||
|
||
"kubesphere.io/fluentbit-operator/api/fluentbitoperator/v1alpha2/plugins" | ||
) | ||
|
||
// +kubebuilder:object:generate:=true | ||
|
||
// Throttle filter allows you to set the average rate of messages per internal, based on leaky bucket and sliding window algorithm. | ||
type Throttle struct { | ||
// Rate is the amount of messages for the time. | ||
Rate *int64 `json:"rate,omitempty"` | ||
// Window is the amount of intervals to calculate average over. | ||
Window *int64 `json:"window,omitempty"` | ||
// Interval is the time interval expressed in "sleep" format. e.g. 3s, 1.5m, 0.5h, etc. | ||
// +kubebuilder:validation:Pattern:="^\\d+(\\.[0-9]{0,2})?(s|m|h|d)?$" | ||
Interval string `json:"interval,omitempty"` | ||
// PrintStatus represents whether to print status messages with current rate and the limits to information logs. | ||
PrintStatus *bool `json:"printStatus,omitempty"` | ||
} | ||
|
||
// Name is the name of the filter plugin. | ||
func (*Throttle) Name() string { | ||
return "throttle" | ||
} | ||
|
||
// Params represents the config options for the filter plugin. | ||
func (k *Throttle) Params(_ plugins.SecretLoader) (*plugins.KVs, error) { | ||
kvs := plugins.NewKVs() | ||
if k.Rate != nil { | ||
kvs.Insert("Rate", fmt.Sprint(*k.Rate)) | ||
} | ||
if k.Window != nil { | ||
kvs.Insert("Window", fmt.Sprint(*k.Window)) | ||
} | ||
if k.Interval != "" { | ||
kvs.Insert("Interval", k.Interval) | ||
} | ||
if k.PrintStatus != nil { | ||
kvs.Insert("Print_Status", fmt.Sprint(*k.PrintStatus)) | ||
} | ||
return kvs, nil | ||
} |
30 changes: 30 additions & 0 deletions
30
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
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,11 @@ | ||
# Throttle | ||
|
||
The Throttle Filter plugin sets the average Rate of messages per Interval, based on leaky bucket and sliding window algorithm. In case of overflood, it will leak within certain rate. | ||
|
||
|
||
| Field | Description | Scheme | | ||
| ----- | ----------- | ------ | | ||
| rate | Amount of messages for the time. | *int64 | | ||
| window | Amount of intervals to calculate average over. | *int64 | | ||
| interval | Time interval, expressed in "sleep" format. e.g 3s, 1.5m, 0.5h etc | string | | ||
| printStatus | Whether to print status messages with current rate and the limits to information logs | *bool | |
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
Oops, something went wrong.