Show More
@@ -691,14 +691,14 b' def logs_cleanup(resource_id, filter_settings):' | |||
|
691 | 691 | request.tm.begin() |
|
692 | 692 | es_query = { |
|
693 | 693 | "query": { |
|
694 |
"bool": {"filter |
|
|
694 | "bool": {"filter": [{"term": {"resource_id": resource_id}}]} | |
|
695 | 695 | } |
|
696 | 696 | } |
|
697 | 697 | |
|
698 | 698 | query = DBSession.query(Log).filter(Log.resource_id == resource_id) |
|
699 | 699 | if filter_settings["namespace"]: |
|
700 | 700 | query = query.filter(Log.namespace == filter_settings["namespace"][0]) |
|
701 |
es_query["query"]["bool"]["filter"] |
|
|
701 | es_query["query"]["bool"]["filter"].append( | |
|
702 | 702 | {"term": {"namespace": filter_settings["namespace"][0]}} |
|
703 | 703 | ) |
|
704 | 704 | query.delete(synchronize_session=False) |
@@ -312,13 +312,11 b' class Report(Base, BaseModel):' | |||
|
312 | 312 | "size": 1, |
|
313 | 313 | "query": { |
|
314 | 314 | "bool": { |
|
315 |
"filter": |
|
|
316 | "and": [ | |
|
315 | "filter": [ | |
|
317 | 316 |
|
|
318 | 317 |
|
|
319 | 318 |
|
|
320 | 319 |
|
|
321 | } | |
|
322 | 320 | }, |
|
323 | 321 | "sort": [{"_doc": {"order": "desc"}}], |
|
324 | 322 | } |
@@ -333,13 +331,11 b' class Report(Base, BaseModel):' | |||
|
333 | 331 | "size": 1, |
|
334 | 332 | "query": { |
|
335 | 333 | "bool": { |
|
336 |
"filter": |
|
|
337 | "and": [ | |
|
334 | "filter": [ | |
|
338 | 335 |
|
|
339 | 336 |
|
|
340 | 337 |
|
|
341 | 338 |
|
|
342 | } | |
|
343 | 339 | }, |
|
344 | 340 | "sort": [{"_doc": {"order": "asc"}}], |
|
345 | 341 | } |
@@ -58,14 +58,14 b' class LogService(BaseService):' | |||
|
58 | 58 | query = { |
|
59 | 59 | "query": { |
|
60 | 60 | "bool": { |
|
61 |
"filter |
|
|
61 | "filter": [{"terms": {"resource_id": list(app_ids)}}] | |
|
62 | 62 | } |
|
63 | 63 | } |
|
64 | 64 | } |
|
65 | 65 | |
|
66 | 66 | start_date = filter_settings.get("start_date") |
|
67 | 67 | end_date = filter_settings.get("end_date") |
|
68 |
filter_part = query["query"]["bool"]["filter"] |
|
|
68 | filter_part = query["query"]["bool"]["filter"] | |
|
69 | 69 | |
|
70 | 70 | for tag in filter_settings.get("tags", []): |
|
71 | 71 | tag_values = [v.lower() for v in tag["value"]] |
@@ -75,8 +75,7 b' class ReportGroupService(BaseService):' | |||
|
75 | 75 | }, |
|
76 | 76 | "query": { |
|
77 | 77 | "bool": { |
|
78 |
"filter": |
|
|
79 | "and": [ | |
|
78 | "filter": [ | |
|
80 | 79 |
|
|
81 | 80 |
|
|
82 | 81 |
|
@@ -92,11 +91,10 b' class ReportGroupService(BaseService):' | |||
|
92 | 91 |
|
|
93 | 92 |
|
|
94 | 93 |
|
|
95 | } | |
|
96 | 94 | }, |
|
97 | 95 | } |
|
98 | 96 | if tags: |
|
99 |
es_query["query"]["bool"]["filter"] |
|
|
97 | es_query["query"]["bool"]["filter"].extend(tags) | |
|
100 | 98 | |
|
101 | 99 | result = Datastores.es.search( |
|
102 | 100 | body=es_query, index=index_names, doc_type="log", size=0 |
@@ -138,7 +136,7 b' class ReportGroupService(BaseService):' | |||
|
138 | 136 | "bool": { |
|
139 | 137 | "must": [], |
|
140 | 138 | "should": [], |
|
141 |
"filter |
|
|
139 | "filter": [{"terms": {"resource_id": list(app_ids)}}] | |
|
142 | 140 | } |
|
143 | 141 | }, |
|
144 | 142 | "aggs": { |
@@ -160,7 +158,7 b' class ReportGroupService(BaseService):' | |||
|
160 | 158 | |
|
161 | 159 | start_date = filter_settings.get("start_date") |
|
162 | 160 | end_date = filter_settings.get("end_date") |
|
163 |
filter_part = query["query"]["bool"]["filter"] |
|
|
161 | filter_part = query["query"]["bool"]["filter"] | |
|
164 | 162 | date_range = {"range": {"start_time": {}}} |
|
165 | 163 | if start_date: |
|
166 | 164 | date_range["range"]["start_time"]["gte"] = start_date |
@@ -467,8 +465,7 b' class ReportGroupService(BaseService):' | |||
|
467 | 465 | }, |
|
468 | 466 | "query": { |
|
469 | 467 | "bool": { |
|
470 |
"filter": |
|
|
471 | "and": [ | |
|
468 | "filter": [ | |
|
472 | 469 |
|
|
473 | 470 |
|
|
474 | 471 |
|
@@ -484,7 +481,6 b' class ReportGroupService(BaseService):' | |||
|
484 | 481 |
|
|
485 | 482 |
|
|
486 | 483 |
|
|
487 | } | |
|
488 | 484 | }, |
|
489 | 485 | } |
|
490 | 486 | if group_id: |
@@ -33,24 +33,20 b' class ReportStatService(BaseService):' | |||
|
33 | 33 | "aggs": { |
|
34 | 34 | "sub_agg": {"value_count": {"field": "tags.group_id.values"}} |
|
35 | 35 | }, |
|
36 |
"filter": |
|
|
37 | "and": [ | |
|
36 | "filter": [ | |
|
38 | 37 |
|
|
39 | 38 |
|
|
40 |
|
|
|
41 | }, | |
|
39 | ], | |
|
42 | 40 | } |
|
43 | 41 | }, |
|
44 | 42 | "query": { |
|
45 | 43 | "bool": { |
|
46 |
"filter": |
|
|
47 | "and": [ | |
|
44 | "filter": [ | |
|
48 | 45 |
|
|
49 | 46 |
|
|
50 | 47 |
|
|
51 | 48 |
|
|
52 | 49 |
|
|
53 | } | |
|
54 | 50 | }, |
|
55 | 51 | } |
|
56 | 52 |
@@ -141,8 +141,7 b' class RequestMetricService(BaseService):' | |||
|
141 | 141 | }, |
|
142 | 142 | "query": { |
|
143 | 143 | "bool": { |
|
144 |
"filter": |
|
|
145 | "and": [ | |
|
144 | "filter": [ | |
|
146 | 145 |
|
|
147 | 146 |
|
|
148 | 147 |
|
@@ -159,7 +158,6 b' class RequestMetricService(BaseService):' | |||
|
159 | 158 |
|
|
160 | 159 |
|
|
161 | 160 |
|
|
162 | } | |
|
163 | 161 | }, |
|
164 | 162 | } |
|
165 | 163 | |
@@ -209,8 +207,7 b' class RequestMetricService(BaseService):' | |||
|
209 | 207 | }, |
|
210 | 208 | "query": { |
|
211 | 209 | "bool": { |
|
212 |
"filter": |
|
|
213 | "and": [ | |
|
210 | "filter": [ | |
|
214 | 211 |
|
|
215 | 212 |
|
|
216 | 213 |
|
@@ -227,7 +224,6 b' class RequestMetricService(BaseService):' | |||
|
227 | 224 |
|
|
228 | 225 |
|
|
229 | 226 |
|
|
230 | } | |
|
231 | 227 | }, |
|
232 | 228 | } |
|
233 | 229 | result = Datastores.es.search( |
@@ -288,8 +284,7 b' class RequestMetricService(BaseService):' | |||
|
288 | 284 | }, |
|
289 | 285 | "query": { |
|
290 | 286 | "bool": { |
|
291 |
"filter": |
|
|
292 | "and": [ | |
|
287 | "filter": [ | |
|
293 | 288 |
|
|
294 | 289 |
|
|
295 | 290 |
|
@@ -305,7 +300,6 b' class RequestMetricService(BaseService):' | |||
|
305 | 300 |
|
|
306 | 301 |
|
|
307 | 302 |
|
|
308 | } | |
|
309 | 303 | }, |
|
310 | 304 | } |
|
311 | 305 | result = Datastores.es.search( |
@@ -331,7 +325,7 b' class RequestMetricService(BaseService):' | |||
|
331 | 325 | }, |
|
332 | 326 | } |
|
333 | 327 | }, |
|
334 |
"query": {"bool": {"filter": |
|
|
328 | "query": {"bool": {"filter": and_part}}, | |
|
335 | 329 | } |
|
336 | 330 | details = {} |
|
337 | 331 | index_names = es_index_name_limiter(ixtypes=["reports"]) |
@@ -462,8 +456,7 b' class RequestMetricService(BaseService):' | |||
|
462 | 456 | }, |
|
463 | 457 | "query": { |
|
464 | 458 | "bool": { |
|
465 |
"filter": |
|
|
466 | "and": [ | |
|
459 | "filter": [ | |
|
467 | 460 |
|
|
468 | 461 |
|
|
469 | 462 |
|
@@ -480,7 +473,6 b' class RequestMetricService(BaseService):' | |||
|
480 | 473 |
|
|
481 | 474 |
|
|
482 | 475 |
|
|
483 | } | |
|
484 | 476 | }, |
|
485 | 477 | } |
|
486 | 478 | |
@@ -541,8 +533,7 b' class RequestMetricService(BaseService):' | |||
|
541 | 533 | }, |
|
542 | 534 | "query": { |
|
543 | 535 | "bool": { |
|
544 |
"filter": |
|
|
545 | "and": [ | |
|
536 | "filter": [ | |
|
546 | 537 |
|
|
547 | 538 |
|
|
548 | 539 |
|
@@ -559,7 +550,6 b' class RequestMetricService(BaseService):' | |||
|
559 | 550 |
|
|
560 | 551 |
|
|
561 | 552 |
|
|
562 | } | |
|
563 | 553 | }, |
|
564 | 554 | } |
|
565 | 555 | result = Datastores.es.search( |
@@ -68,8 +68,7 b' class SlowCallService(BaseService):' | |||
|
68 | 68 | }, |
|
69 | 69 | "query": { |
|
70 | 70 | "bool": { |
|
71 |
"filter": |
|
|
72 | "and": [ | |
|
71 | "filter": [ | |
|
73 | 72 |
|
|
74 | 73 |
|
|
75 | 74 |
|
@@ -85,7 +84,6 b' class SlowCallService(BaseService):' | |||
|
85 | 84 |
|
|
86 | 85 |
|
|
87 | 86 |
|
|
88 | } | |
|
89 | 87 | }, |
|
90 | 88 | } |
|
91 | 89 | result = Datastores.es.search( |
@@ -110,8 +108,7 b' class SlowCallService(BaseService):' | |||
|
110 | 108 | }, |
|
111 | 109 | "query": { |
|
112 | 110 | "bool": { |
|
113 |
"filter": |
|
|
114 | "and": [ | |
|
111 | "filter": [ | |
|
115 | 112 |
|
|
116 | 113 |
|
|
117 | 114 |
|
@@ -128,7 +125,6 b' class SlowCallService(BaseService):' | |||
|
128 | 125 |
|
|
129 | 126 |
|
|
130 | 127 |
|
|
131 | } | |
|
132 | 128 | }, |
|
133 | 129 | } |
|
134 | 130 | calls = Datastores.es.search( |
@@ -148,13 +148,13 b' def common_tags(request):' | |||
|
148 | 148 | query = { |
|
149 | 149 | "query": { |
|
150 | 150 | "bool": { |
|
151 |
"filter |
|
|
151 | "filter": [{"terms": {"resource_id": list(resources)}}] | |
|
152 | 152 | } |
|
153 | 153 | } |
|
154 | 154 | } |
|
155 | 155 | start_date = filter_settings.get("start_date") |
|
156 | 156 | end_date = filter_settings.get("end_date") |
|
157 |
filter_part = query["query"]["bool"]["filter"] |
|
|
157 | filter_part = query["query"]["bool"]["filter"] | |
|
158 | 158 | |
|
159 | 159 | date_range = {"range": {"timestamp": {}}} |
|
160 | 160 | if start_date: |
@@ -207,9 +207,7 b' def common_values(request):' | |||
|
207 | 207 | query = { |
|
208 | 208 | "query": { |
|
209 | 209 | "bool": { |
|
210 |
"filter": |
|
|
211 | "and": and_part | |
|
212 | } | |
|
210 | "filter": and_part | |
|
213 | 211 | } |
|
214 | 212 | } |
|
215 | 213 | } |
General Comments 0
You need to be logged in to leave comments.
Login now