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