Skip to content

Commit 08e1c0c

Browse files
authored
NETOBSERV-1017 extract timebased indexKeys (#450)
* extract timebased indexKeys * simplified string convert * cleaned output
1 parent d127e36 commit 08e1c0c

File tree

12 files changed

+268
-161
lines changed

12 files changed

+268
-161
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -742,23 +742,27 @@ parameters:
742742
- name: "Top 3 Sum of bytes per source subnet over last 10 seconds"
743743
operation: sum
744744
operationKey: bytes
745-
recordKey: srcSubnet
745+
recordKeys: srcSubnet
746746
topK: 3
747747
reversed: false
748748
timeInterval: 10s
749749
```
750750
751751
The output fields of the aggregates stage are:
752-
- `name`
753-
- `operation`
754-
- `operation_key`
755-
- `record_key`; the field specified in the rules upon which to perform the operation
756-
- `key`; the value of the record_key
757-
- `operation_result`; (computed sum, max, min, etc, as the case may be)
752+
- `name`; the name of the rule.
753+
- `index_key`; the fields specified in the rules upon which to index, comma separated. Each of these keys will be append in the output with their corresponding values.
754+
- `operation`; the operation of the rule. The result value of the operation is append in `operationKey` output field.
758755
759-
In addition there is a field with the
760-
"$record_key": "$key"
761-
representing the original map entry in the input flow-log.
756+
Example output:
757+
```json
758+
{
759+
"name":"Top 3 Sum of bytes per source subnet over last 10 seconds",
760+
"index_key":"srcSubnet",
761+
"operation":"sum",
762+
"srcSubnet":"10.0.0.0/16",
763+
"bytes":1234,
764+
}
765+
```
762766
763767
These fields are used by the next stage (for example `prom` encoder).
764768

contrib/kubernetes/flowlogs-pipeline.conf.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ parameters:
277277
filter:
278278
key: name
279279
value: bandwidth_source_subnet
280-
valueKey: operation_result
280+
valueKey: bytes
281281
labels:
282282
- srcSubnet
283283
buckets: []

docs/api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ Following is the supported API format for specifying metrics time-based filters:
259259
timebased:
260260
rules: list of filter rules, each includes:
261261
name: description of filter result
262-
indexKey: internal field to index TopK
262+
indexKey: internal field to index TopK. Deprecated, use indexKeys instead
263+
indexKeys: internal fields to index TopK
263264
operationType: (enum) sum, min, max, avg, count, last or diff
264265
sum: set output field to sum of parameters fields in the time window
265266
avg: set output field to average of parameters fields in the time window

network_definitions/bandwidth_per_src_subnet.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ encode:
3333
- name: bandwidth_per_source_subnet
3434
type: gauge
3535
filter: {key: name, value: bandwidth_source_subnet}
36-
valueKey: operation_result
36+
valueKey: bytes
3737
labels:
3838
- srcSubnet
3939
visualization:

pkg/api/extract_timebased.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ type ExtractTimebased struct {
3737

3838
type TimebasedFilterRule struct {
3939
Name string `yaml:"name,omitempty" json:"name,omitempty" doc:"description of filter result"`
40-
IndexKey string `yaml:"indexKey,omitempty" json:"indexKey,omitempty" doc:"internal field to index TopK"`
40+
IndexKey string `yaml:"indexKey,omitempty" json:"indexKey,omitempty" doc:"internal field to index TopK. Deprecated, use indexKeys instead"`
41+
IndexKeys []string `yaml:"indexKeys,omitempty" json:"indexKeys,omitempty" doc:"internal fields to index TopK"`
4142
OperationType string `yaml:"operationType,omitempty" json:"operationType,omitempty" enum:"FilterOperationEnum" doc:"sum, min, max, avg, count, last or diff"`
4243
OperationKey string `yaml:"operationKey,omitempty" json:"operationKey,omitempty" doc:"internal field on which to perform the operation"`
4344
TopK int `yaml:"topK,omitempty" json:"topK,omitempty" doc:"number of highest incidence to report (default - report all)"`

0 commit comments

Comments
 (0)