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