Skip to content

Commit

Permalink
addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
KalmanMeth committed May 10, 2023
1 parent d2d3957 commit 64a60d8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Following is the supported API format for specifying metrics aggregations:
groupByKeys: list of fields on which to aggregate
operationType: sum, min, max, count, avg or raw_values
operationKey: internal field on which to perform the operation
timeInterval: time interval over which to perform the operation
expiryTime: time interval over which to perform the operation (default: 2 minutes
</pre>
## Connection tracking API
Following is the supported API format for specifying connection tracking:
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/extract_aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ type AggregateDefinition struct {
GroupByKeys AggregateBy `yaml:"groupByKeys,omitempty" json:"groupByKeys,omitempty" doc:"list of fields on which to aggregate"`
OperationType AggregateOperation `yaml:"operationType,omitempty" json:"operationType,omitempty" doc:"sum, min, max, count, avg or raw_values"`
OperationKey string `yaml:"operationKey,omitempty" json:"operationKey,omitempty" doc:"internal field on which to perform the operation"`
TimeInterval Duration `yaml:"timeInterval,omitempty" json:"timeInterval,omitempty" doc:"time interval over which to perform the operation"`
ExpiryTime Duration `yaml:"expiryTime,omitempty" json:"expiryTime,omitempty" doc:"time interval over which to perform the operation (default: 2 minutes"`
}
4 changes: 2 additions & 2 deletions pkg/config/pipeline_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestKafkaPromPipeline(t *testing.T) {
Name: "src_as_connection_count",
GroupByKeys: api.AggregateBy{"srcAS"},
OperationType: "count",
TimeInterval: timeDuration,
ExpiryTime: timeDuration,
}}})
var expiryTimeDuration api.Duration
expiryTimeDuration.Duration = time.Duration(50 * time.Second)
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestKafkaPromPipeline(t *testing.T) {

b, err = json.Marshal(params[3])
require.NoError(t, err)
require.JSONEq(t, `{"name":"aggregate","extract":{"type":"aggregates","aggregates":{"defaultExpiryTime":"0s","rules":[{"name":"src_as_connection_count","groupByKeys":["srcAS"],"operationType":"count","timeInterval":"30s"}]}}}`, string(b))
require.JSONEq(t, `{"name":"aggregate","extract":{"type":"aggregates","aggregates":{"defaultExpiryTime":"0s","rules":[{"name":"src_as_connection_count","groupByKeys":["srcAS"],"operationType":"count","expiryTime":"30s"}]}}}`, string(b))

b, err = json.Marshal(params[4])
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/pipeline/extract/aggregate/aggregates.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (aggregates *Aggregates) GetMetrics() []config.GenericMap {
}

func (aggregates *Aggregates) AddAggregate(aggregateDefinition api.AggregateDefinition) []Aggregate {
expiryTime := aggregateDefinition.TimeInterval
expiryTime := aggregateDefinition.ExpiryTime
if expiryTime.Duration == 0 {
expiryTime.Duration = defaultExpiryTime
}
Expand Down

0 comments on commit 64a60d8

Please sign in to comment.