-
Notifications
You must be signed in to change notification settings - Fork 34
Add anomaly detection transform stage to flowlogs-pipeline #1143
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- | ||
| log-level: info | ||
| pipeline: | ||
| - name: ingest | ||
| - name: detect-anomaly | ||
| follows: ingest | ||
| - name: write | ||
| follows: detect-anomaly | ||
| parameters: | ||
| - name: ingest | ||
| ingest: | ||
| type: synthetic | ||
| synthetic: | ||
| flowLogsPerMin: 10 | ||
| - name: detect-anomaly | ||
| transform: | ||
| type: anomaly | ||
| anomaly: | ||
| algorithm: zscore | ||
| valueField: Bytes | ||
| keyFields: [SrcAddr, DstAddr, Proto] | ||
| windowSize: 20 | ||
| baselineWindow: 5 | ||
| sensitivity: 3 | ||
| - name: write | ||
| write: | ||
| type: stdout | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright (C) 2024 IBM, Inc. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| */ | ||
|
|
||
| package api | ||
|
|
||
| // TransformAnomalyAlgorithm defines the supported anomaly detection strategies. | ||
| // For doc generation, enum definitions must match format `Constant Type = "value" // doc` | ||
| type TransformAnomalyAlgorithm string | ||
|
|
||
| const ( | ||
| AnomalyAlgorithmEWMA TransformAnomalyAlgorithm = "ewma" // exponentially weighted moving average baseline | ||
| AnomalyAlgorithmZScore TransformAnomalyAlgorithm = "zscore" // rolling z-score over a sliding window | ||
| ) | ||
|
|
||
| // TransformAnomaly describes configuration for anomaly detection stages. | ||
| type TransformAnomaly struct { | ||
| Algorithm TransformAnomalyAlgorithm `yaml:"algorithm,omitempty" json:"algorithm,omitempty" doc:"(enum) algorithm used to score anomalies: ewma or zscore"` | ||
| ValueField string `yaml:"valueField,omitempty" json:"valueField,omitempty" doc:"field containing the numeric value to evaluate"` | ||
| KeyFields []string `yaml:"keyFields,omitempty" json:"keyFields,omitempty" doc:"list of fields combined to build the per-entity baseline key"` | ||
| WindowSize int `yaml:"windowSize,omitempty" json:"windowSize,omitempty" doc:"number of recent samples to keep for baseline statistics"` | ||
| BaselineWindow int `yaml:"baselineWindow,omitempty" json:"baselineWindow,omitempty" doc:"minimum number of samples before anomaly scores are emitted"` | ||
| Sensitivity float64 `yaml:"sensitivity,omitempty" json:"sensitivity,omitempty" doc:"threshold multiplier for flagging anomalies (e.g., z-score)"` | ||
| EWMAAlpha float64 `yaml:"ewmaAlpha,omitempty" json:"ewmaAlpha,omitempty" doc:"smoothing factor for ewma algorithm; derived from windowSize if omitted"` | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's good enough as example but could you explain what's the final goal for your usage ?
Do you want to expose that in a prometheus metric or somewhere else ?