Skip to content

Commit a23ad40

Browse files
authored
Merge pull request #78 from stackhpc/fix-opensearch-backend-zed
Fix API report requests when using opensearch (zed)
2 parents 0745402 + 532f349 commit a23ad40

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

cloudkitty/storage/v2/elasticsearch/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,15 @@ def _build_composite(self, groupby):
9898
sources = []
9999
for elem in groupby:
100100
if elem == 'type':
101-
sources.append({'type': {'terms': {'field': 'type'}}})
101+
sources.append({'type': {'terms': {'field': 'type.keyword'}}})
102102
elif elem == 'time':
103103
# Not doing a date_histogram aggregation because we don't know
104104
# the period
105105
sources.append({'begin': {'terms': {'field': 'start'}}})
106106
sources.append({'end': {'terms': {'field': 'end'}}})
107107
else:
108-
sources.append({elem: {'terms': {'field': 'groupby.' + elem}}})
108+
field = 'groupby.' + elem + '.keyword'
109+
sources.append({elem: {'terms': {'field': field}}})
109110

110111
return {"sources": sources}
111112

cloudkitty/storage/v2/opensearch/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,15 @@ def _build_composite(self, groupby):
9898
sources = []
9999
for elem in groupby:
100100
if elem == 'type':
101-
sources.append({'type': {'terms': {'field': 'type'}}})
101+
sources.append({'type': {'terms': {'field': 'type.keyword'}}})
102102
elif elem == 'time':
103103
# Not doing a date_histogram aggregation because we don't know
104104
# the period
105105
sources.append({'begin': {'terms': {'field': 'start'}}})
106106
sources.append({'end': {'terms': {'field': 'end'}}})
107107
else:
108-
sources.append({elem: {'terms': {'field': 'groupby.' + elem}}})
108+
field = 'groupby.' + elem + '.keyword'
109+
sources.append({elem: {'terms': {'field': field}}})
109110

110111
return {"sources": sources}
111112

cloudkitty/tests/storage/v2/elasticsearch/test_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def test_build_composite(self):
8686
self.assertEqual(
8787
self.client._build_composite(['one', 'type', 'two']),
8888
{'sources': [
89-
{'one': {'terms': {'field': 'groupby.one'}}},
90-
{'type': {'terms': {'field': 'type'}}},
91-
{'two': {'terms': {'field': 'groupby.two'}}},
89+
{'one': {'terms': {'field': 'groupby.one.keyword'}}},
90+
{'type': {'terms': {'field': 'type.keyword'}}},
91+
{'two': {'terms': {'field': 'groupby.two.keyword'}}},
9292
]},
9393
)
9494

cloudkitty/tests/storage/v2/opensearch/test_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def test_build_composite(self):
8686
self.assertEqual(
8787
self.client._build_composite(['one', 'type', 'two']),
8888
{'sources': [
89-
{'one': {'terms': {'field': 'groupby.one'}}},
90-
{'type': {'terms': {'field': 'type'}}},
91-
{'two': {'terms': {'field': 'groupby.two'}}},
89+
{'one': {'terms': {'field': 'groupby.one.keyword'}}},
90+
{'type': {'terms': {'field': 'type.keyword'}}},
91+
{'two': {'terms': {'field': 'groupby.two.keyword'}}},
9292
]},
9393
)
9494

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
Fix some API report requests that were returning HTTP 500 errors when using
5+
the ``opensearch`` storage backend. This fixes failures to load the Horizon
6+
``Rating`` panel.

0 commit comments

Comments
 (0)