diff --git a/docs/api.md b/docs/api.md index 74fc0a258..0cad9f88c 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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 ## Connection tracking API Following is the supported API format for specifying connection tracking: diff --git a/pkg/api/extract_aggregate.go b/pkg/api/extract_aggregate.go index 749941130..0a9b2936a 100644 --- a/pkg/api/extract_aggregate.go +++ b/pkg/api/extract_aggregate.go @@ -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"` } diff --git a/pkg/config/pipeline_builder_test.go b/pkg/config/pipeline_builder_test.go index dc7bb2d3c..3a78d09e5 100644 --- a/pkg/config/pipeline_builder_test.go +++ b/pkg/config/pipeline_builder_test.go @@ -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) @@ -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) diff --git a/pkg/pipeline/extract/aggregate/aggregates.go b/pkg/pipeline/extract/aggregate/aggregates.go index 8e51129eb..775b90baf 100644 --- a/pkg/pipeline/extract/aggregate/aggregates.go +++ b/pkg/pipeline/extract/aggregate/aggregates.go @@ -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 }