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,12 +312,10 b' class Report(Base, BaseModel):' | |||
|
312 | 312 | "size": 1, |
|
313 | 313 | "query": { |
|
314 | 314 | "bool": { |
|
315 |
"filter": |
|
|
316 |
" |
|
|
317 |
|
|
|
318 | {"range": {"pg_id": {"lt": self.id}}}, | |
|
319 | ] | |
|
320 | } | |
|
315 | "filter": [ | |
|
316 | {"term": {"group_id": self.group_id}}, | |
|
317 | {"range": {"pg_id": {"lt": self.id}}}, | |
|
318 | ] | |
|
321 | 319 | } |
|
322 | 320 | }, |
|
323 | 321 | "sort": [{"_doc": {"order": "desc"}}], |
@@ -333,12 +331,10 b' class Report(Base, BaseModel):' | |||
|
333 | 331 | "size": 1, |
|
334 | 332 | "query": { |
|
335 | 333 | "bool": { |
|
336 |
"filter": |
|
|
337 |
" |
|
|
338 |
|
|
|
339 | {"range": {"pg_id": {"gt": self.id}}}, | |
|
340 | ] | |
|
341 | } | |
|
334 | "filter": [ | |
|
335 | {"term": {"group_id": self.group_id}}, | |
|
336 | {"range": {"pg_id": {"gt": self.id}}}, | |
|
337 | ] | |
|
342 | 338 | } |
|
343 | 339 | }, |
|
344 | 340 | "sort": [{"_doc": {"order": "asc"}}], |
@@ -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,28 +75,26 b' class ReportGroupService(BaseService):' | |||
|
75 | 75 | }, |
|
76 | 76 | "query": { |
|
77 | 77 | "bool": { |
|
78 |
"filter": |
|
|
79 |
|
|
|
80 | { | |
|
81 |
" |
|
|
82 | "resource_id": [filter_settings["resource"][0]] | |
|
83 |
|
|
|
84 |
|
|
|
85 | { | |
|
86 |
" |
|
|
87 |
"t |
|
|
88 |
|
|
|
89 | "lte": filter_settings["end_date"], | |
|
90 | } | |
|
78 | "filter": [ | |
|
79 | { | |
|
80 | "terms": { | |
|
81 | "resource_id": [filter_settings["resource"][0]] | |
|
82 | } | |
|
83 | }, | |
|
84 | { | |
|
85 | "range": { | |
|
86 | "timestamp": { | |
|
87 | "gte": filter_settings["start_date"], | |
|
88 | "lte": filter_settings["end_date"], | |
|
91 | 89 | } |
|
92 |
} |
|
|
93 |
|
|
|
94 |
|
|
|
90 | } | |
|
91 | }, | |
|
92 | ] | |
|
95 | 93 | } |
|
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,23 +465,21 b' class ReportGroupService(BaseService):' | |||
|
467 | 465 | }, |
|
468 | 466 | "query": { |
|
469 | 467 | "bool": { |
|
470 |
"filter": |
|
|
471 |
|
|
|
472 | { | |
|
473 |
" |
|
|
474 | "resource_id": [filter_settings["resource"][0]] | |
|
475 |
|
|
|
476 |
|
|
|
477 | { | |
|
478 |
" |
|
|
479 |
"t |
|
|
480 |
|
|
|
481 | "lte": filter_settings["end_date"], | |
|
482 | } | |
|
468 | "filter": [ | |
|
469 | { | |
|
470 | "terms": { | |
|
471 | "resource_id": [filter_settings["resource"][0]] | |
|
472 | } | |
|
473 | }, | |
|
474 | { | |
|
475 | "range": { | |
|
476 | "timestamp": { | |
|
477 | "gte": filter_settings["start_date"], | |
|
478 | "lte": filter_settings["end_date"], | |
|
483 | 479 | } |
|
484 |
} |
|
|
485 |
|
|
|
486 |
|
|
|
480 | } | |
|
481 | }, | |
|
482 | ] | |
|
487 | 483 | } |
|
488 | 484 | }, |
|
489 | 485 | } |
@@ -33,23 +33,19 b' class ReportStatService(BaseService):' | |||
|
33 | 33 | "aggs": { |
|
34 | 34 | "sub_agg": {"value_count": {"field": "tags.group_id.values"}} |
|
35 | 35 | }, |
|
36 |
"filter": |
|
|
37 |
" |
|
|
38 |
|
|
|
39 | {"exists": {"field": "tags.group_id.values"}}, | |
|
40 | ] | |
|
41 | }, | |
|
36 | "filter": [ | |
|
37 | {"terms": {"resource_id": [resource_id]}}, | |
|
38 | {"exists": {"field": "tags.group_id.values"}}, | |
|
39 | ], | |
|
42 | 40 | } |
|
43 | 41 | }, |
|
44 | 42 | "query": { |
|
45 | 43 | "bool": { |
|
46 |
"filter": |
|
|
47 |
" |
|
|
48 |
|
|
|
49 |
|
|
|
50 | {"range": {"timestamp": {"gte": since_when}}}, | |
|
51 | ] | |
|
52 | } | |
|
44 | "filter": [ | |
|
45 | {"terms": {"resource_id": [resource_id]}}, | |
|
46 | {"terms": {"tags.type.values": [report_type]}}, | |
|
47 | {"range": {"timestamp": {"gte": since_when}}}, | |
|
48 | ] | |
|
53 | 49 | } |
|
54 | 50 | }, |
|
55 | 51 | } |
@@ -141,24 +141,22 b' class RequestMetricService(BaseService):' | |||
|
141 | 141 | }, |
|
142 | 142 | "query": { |
|
143 | 143 | "bool": { |
|
144 |
"filter": |
|
|
145 |
|
|
|
146 | { | |
|
147 |
" |
|
|
148 | "resource_id": [filter_settings["resource"][0]] | |
|
149 |
|
|
|
150 |
|
|
|
151 | { | |
|
152 |
" |
|
|
153 |
"t |
|
|
154 |
|
|
|
155 | "lte": filter_settings["end_date"], | |
|
156 | } | |
|
144 | "filter": [ | |
|
145 | { | |
|
146 | "terms": { | |
|
147 | "resource_id": [filter_settings["resource"][0]] | |
|
148 | } | |
|
149 | }, | |
|
150 | { | |
|
151 | "range": { | |
|
152 | "timestamp": { | |
|
153 | "gte": filter_settings["start_date"], | |
|
154 | "lte": filter_settings["end_date"], | |
|
157 | 155 | } |
|
158 |
} |
|
|
159 | {"terms": {"namespace": ["appenlight.request_metric"]}}, | |
|
160 | ] | |
|
161 |
|
|
|
156 | } | |
|
157 | }, | |
|
158 | {"terms": {"namespace": ["appenlight.request_metric"]}}, | |
|
159 | ] | |
|
162 | 160 | } |
|
163 | 161 | }, |
|
164 | 162 | } |
@@ -209,24 +207,22 b' class RequestMetricService(BaseService):' | |||
|
209 | 207 | }, |
|
210 | 208 | "query": { |
|
211 | 209 | "bool": { |
|
212 |
"filter": |
|
|
213 |
|
|
|
214 | { | |
|
215 |
" |
|
|
216 | "resource_id": [filter_settings["resource"][0]] | |
|
217 |
|
|
|
218 |
|
|
|
219 | { | |
|
220 |
" |
|
|
221 |
"t |
|
|
222 |
|
|
|
223 | "lte": filter_settings["end_date"], | |
|
224 | } | |
|
210 | "filter": [ | |
|
211 | { | |
|
212 | "terms": { | |
|
213 | "resource_id": [filter_settings["resource"][0]] | |
|
214 | } | |
|
215 | }, | |
|
216 | { | |
|
217 | "range": { | |
|
218 | "timestamp": { | |
|
219 | "gte": filter_settings["start_date"], | |
|
220 | "lte": filter_settings["end_date"], | |
|
225 | 221 | } |
|
226 |
} |
|
|
227 | {"terms": {"namespace": ["appenlight.request_metric"]}}, | |
|
228 | ] | |
|
229 |
|
|
|
222 | } | |
|
223 | }, | |
|
224 | {"terms": {"namespace": ["appenlight.request_metric"]}}, | |
|
225 | ] | |
|
230 | 226 | } |
|
231 | 227 | }, |
|
232 | 228 | } |
@@ -288,23 +284,21 b' class RequestMetricService(BaseService):' | |||
|
288 | 284 | }, |
|
289 | 285 | "query": { |
|
290 | 286 | "bool": { |
|
291 |
"filter": |
|
|
292 |
|
|
|
293 | { | |
|
294 |
" |
|
|
295 | "resource_id": [filter_settings["resource"][0]] | |
|
296 |
|
|
|
297 |
|
|
|
298 | { | |
|
299 |
" |
|
|
300 |
"t |
|
|
301 |
|
|
|
302 | "lte": filter_settings["end_date"], | |
|
303 | } | |
|
287 | "filter": [ | |
|
288 | { | |
|
289 | "terms": { | |
|
290 | "resource_id": [filter_settings["resource"][0]] | |
|
291 | } | |
|
292 | }, | |
|
293 | { | |
|
294 | "range": { | |
|
295 | "timestamp": { | |
|
296 | "gte": filter_settings["start_date"], | |
|
297 | "lte": filter_settings["end_date"], | |
|
304 | 298 | } |
|
305 |
} |
|
|
306 |
|
|
|
307 |
|
|
|
299 | } | |
|
300 | }, | |
|
301 | ] | |
|
308 | 302 | } |
|
309 | 303 | }, |
|
310 | 304 | } |
@@ -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,24 +456,22 b' class RequestMetricService(BaseService):' | |||
|
462 | 456 | }, |
|
463 | 457 | "query": { |
|
464 | 458 | "bool": { |
|
465 |
"filter": |
|
|
466 |
|
|
|
467 | { | |
|
468 |
" |
|
|
469 | "resource_id": [filter_settings["resource"][0]] | |
|
470 |
|
|
|
471 |
|
|
|
472 | { | |
|
473 |
" |
|
|
474 |
"t |
|
|
475 |
|
|
|
476 | "lte": filter_settings["end_date"], | |
|
477 | } | |
|
459 | "filter": [ | |
|
460 | { | |
|
461 | "terms": { | |
|
462 | "resource_id": [filter_settings["resource"][0]] | |
|
463 | } | |
|
464 | }, | |
|
465 | { | |
|
466 | "range": { | |
|
467 | "timestamp": { | |
|
468 | "gte": filter_settings["start_date"], | |
|
469 | "lte": filter_settings["end_date"], | |
|
478 | 470 | } |
|
479 |
} |
|
|
480 | {"terms": {"namespace": ["appenlight.request_metric"]}}, | |
|
481 | ] | |
|
482 |
|
|
|
471 | } | |
|
472 | }, | |
|
473 | {"terms": {"namespace": ["appenlight.request_metric"]}}, | |
|
474 | ] | |
|
483 | 475 | } |
|
484 | 476 | }, |
|
485 | 477 | } |
@@ -541,24 +533,22 b' class RequestMetricService(BaseService):' | |||
|
541 | 533 | }, |
|
542 | 534 | "query": { |
|
543 | 535 | "bool": { |
|
544 |
"filter": |
|
|
545 |
|
|
|
546 | { | |
|
547 |
" |
|
|
548 | "resource_id": [filter_settings["resource"][0]] | |
|
549 |
|
|
|
550 |
|
|
|
551 | { | |
|
552 |
" |
|
|
553 |
"t |
|
|
554 |
|
|
|
555 | "lte": filter_settings["end_date"], | |
|
556 | } | |
|
536 | "filter": [ | |
|
537 | { | |
|
538 | "terms": { | |
|
539 | "resource_id": [filter_settings["resource"][0]] | |
|
540 | } | |
|
541 | }, | |
|
542 | { | |
|
543 | "range": { | |
|
544 | "timestamp": { | |
|
545 | "gte": filter_settings["start_date"], | |
|
546 | "lte": filter_settings["end_date"], | |
|
557 | 547 | } |
|
558 |
} |
|
|
559 | {"terms": {"namespace": ["appenlight.error"]}}, | |
|
560 | ] | |
|
561 |
|
|
|
548 | } | |
|
549 | }, | |
|
550 | {"terms": {"namespace": ["appenlight.error"]}}, | |
|
551 | ] | |
|
562 | 552 | } |
|
563 | 553 | }, |
|
564 | 554 | } |
@@ -68,23 +68,21 b' class SlowCallService(BaseService):' | |||
|
68 | 68 | }, |
|
69 | 69 | "query": { |
|
70 | 70 | "bool": { |
|
71 |
"filter": |
|
|
72 |
|
|
|
73 | { | |
|
74 |
" |
|
|
75 | "resource_id": [filter_settings["resource"][0]] | |
|
76 |
|
|
|
77 |
|
|
|
78 | { | |
|
79 |
" |
|
|
80 |
"t |
|
|
81 |
|
|
|
82 | "lte": filter_settings["end_date"], | |
|
83 | } | |
|
71 | "filter": [ | |
|
72 | { | |
|
73 | "terms": { | |
|
74 | "resource_id": [filter_settings["resource"][0]] | |
|
75 | } | |
|
76 | }, | |
|
77 | { | |
|
78 | "range": { | |
|
79 | "timestamp": { | |
|
80 | "gte": filter_settings["start_date"], | |
|
81 | "lte": filter_settings["end_date"], | |
|
84 | 82 | } |
|
85 |
} |
|
|
86 |
|
|
|
87 |
|
|
|
83 | } | |
|
84 | }, | |
|
85 | ] | |
|
88 | 86 | } |
|
89 | 87 | }, |
|
90 | 88 | } |
@@ -110,24 +108,22 b' class SlowCallService(BaseService):' | |||
|
110 | 108 | }, |
|
111 | 109 | "query": { |
|
112 | 110 | "bool": { |
|
113 |
"filter": |
|
|
114 |
|
|
|
115 | { | |
|
116 |
" |
|
|
117 | "resource_id": [filter_settings["resource"][0]] | |
|
118 |
|
|
|
119 | }, | |
|
120 | {"terms": {"tags.statement_hash.values": hashes}}, | |
|
121 | { | |
|
122 |
" |
|
|
123 |
"t |
|
|
124 |
|
|
|
125 | "lte": filter_settings["end_date"], | |
|
126 | } | |
|
111 | "filter": [ | |
|
112 | { | |
|
113 | "terms": { | |
|
114 | "resource_id": [filter_settings["resource"][0]] | |
|
115 | } | |
|
116 | }, | |
|
117 | {"terms": {"tags.statement_hash.values": hashes}}, | |
|
118 | { | |
|
119 | "range": { | |
|
120 | "timestamp": { | |
|
121 | "gte": filter_settings["start_date"], | |
|
122 | "lte": filter_settings["end_date"], | |
|
127 | 123 | } |
|
128 |
} |
|
|
129 |
|
|
|
130 |
|
|
|
124 | } | |
|
125 | }, | |
|
126 | ] | |
|
131 | 127 | } |
|
132 | 128 | }, |
|
133 | 129 | } |
@@ -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