Skip to content
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

Lucene metrics: Remove "size":500 from backend processTimeSeriesQuery #269

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pkg/opensearch/lucene_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ func processDocumentQuery(q *Query, b *es.SearchRequestBuilder, defaultTimeField
}

func processTimeSeriesQuery(q *Query, b *es.SearchRequestBuilder, fromMs int64, toMs int64, defaultTimeField string) {
metric := q.Metrics[0]
b.Size(metric.Settings.Get("size").MustInt(500))
aggBuilder := b.Agg()

// iterate backwards to create aggregations bottom-down
Expand Down
30 changes: 30 additions & 0 deletions pkg/opensearch/time_series_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,36 @@ func TestExecuteTimeSeriesQuery(t *testing.T) {
})
}

func Test_timeSeriesQuery_execute_processTimeSeriesQuery_size_in_search_request(t *testing.T) {
from := time.Date(2018, 5, 15, 17, 50, 0, 0, time.UTC)
to := time.Date(2018, 5, 15, 17, 55, 0, 0, time.UTC)
c := newFakeClient(es.OpenSearch, "2.3.0")

t.Run("size is 0 by default", func(t *testing.T) {
_, err := executeTsdbQuery(c, `{
"timeField": "@timestamp",
"bucketAggs": [{ "type": "date_histogram", "field": "@timestamp", "id": "2" }],
"metrics": [{"type": "count", "id": "0" }]
}`, from, to, 15*time.Second)
assert.NoError(t, err)
sr := c.multisearchRequests[0].Requests[0]

assert.Equal(t, 0, sr.Size)
})

t.Run("size from settings is ignored", func(t *testing.T) {
_, err := executeTsdbQuery(c, `{
"timeField": "@timestamp",
"bucketAggs": [{ "type": "date_histogram", "field": "@timestamp", "id": "2" }],
"metrics": [{"type": "count", "id": "0", "settings": {"size": "1337" }}]
}`, from, to, 15*time.Second)
assert.NoError(t, err)
sr := c.multisearchRequests[0].Requests[0]

assert.Equal(t, 0, sr.Size)
})
}

type fakeClient struct {
flavor es.Flavor
version *semver.Version
Expand Down
Loading