django-restit 4.2.113__py3-none-any.whl → 4.2.115__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_restit-4.2.113.dist-info → django_restit-4.2.115.dist-info}/METADATA +1 -1
- {django_restit-4.2.113.dist-info → django_restit-4.2.115.dist-info}/RECORD +9 -9
- incident/models/event.py +4 -2
- metrics/client.py +4 -0
- rest/__init__.py +1 -1
- rest/decorators.py +5 -4
- taskqueue/models.py +21 -0
- {django_restit-4.2.113.dist-info → django_restit-4.2.115.dist-info}/LICENSE.md +0 -0
- {django_restit-4.2.113.dist-info → django_restit-4.2.115.dist-info}/WHEEL +0 -0
@@ -113,7 +113,7 @@ incident/migrations/0014_event_group_alter_rulecheck_index.py,sha256=v3gm5k0LVoa
|
|
113
113
|
incident/migrations/0015_rule_title_template_alter_incident_state.py,sha256=FPUDhFwqBC39EjeknRT7BPddEf6ExCjsXVb9LMqIn3U,687
|
114
114
|
incident/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
115
115
|
incident/models/__init__.py,sha256=NMphuhb0RTMf7Ov4QkNv7iv6_I8Wtr3xQ54yjX_a31M,209
|
116
|
-
incident/models/event.py,sha256=
|
116
|
+
incident/models/event.py,sha256=LNKYdqOj_CO4aGvc2dNmy3K-S52Udi_gZ4-wintbs1s,7901
|
117
117
|
incident/models/incident.py,sha256=1uLkr7_QEKYsccO-OVmb7YcM8BA3Q6UCWWw2m935YKg,20030
|
118
118
|
incident/models/ossec.py,sha256=eUDRGawzuLWobKEVGKfdZisDnyjS_Hlxi0T_GCSLCCI,2252
|
119
119
|
incident/models/rules.py,sha256=aRkJ0ZnTv87nAUC1sHVkPExfb3OJ8fgHQIhnCIpIbhQ,7001
|
@@ -333,7 +333,7 @@ medialib/youtube/upload.py,sha256=MTuPxm1ZC-y5pXAGtLNtp1hBSNZgCKYt1ewP5hwMQHI,28
|
|
333
333
|
medialib/youtube/uritemplate/__init__.py,sha256=ONWR_KRz9au0O-XUUTrO_UN7GHTmZCTKyvflUQb8wxM,4996
|
334
334
|
metrics/README.md,sha256=YwbCA2y6xJBlaO6yEtl1zWpqrQ4ZzkQSuQT-h6btET8,2307
|
335
335
|
metrics/__init__.py,sha256=70sdDZGOwGIEFWgDkHWPMVODFelo206jp1g-BFV2u_4,90
|
336
|
-
metrics/client.py,sha256=
|
336
|
+
metrics/client.py,sha256=vc49J0KLLJlryhb77I-ejShDnWGF8NqSU6mhdPv8V2s,25570
|
337
337
|
metrics/eod.py,sha256=gnq-tNE7xfm2ah52e2TUyERgUQNwkFuT2rtDv8XOUVQ,9182
|
338
338
|
metrics/examples/eod_example.py,sha256=gYtansjsKILVxe8XJD12XPaxmBJ-B6dOXGZG2JTGWA8,1664
|
339
339
|
metrics/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -374,7 +374,7 @@ pushit/utils.py,sha256=IeTCGa-164nmB1jIsK1lu1O1QzUhS3BKfuXHGjCW-ck,2121
|
|
374
374
|
rest/.gitignore,sha256=TbEvWRMnAiajCTOdhiNrd9eeCAaIjRp9PRjE_VkMM5g,118
|
375
375
|
rest/README.md,sha256=V3ETc-cJu8PZIbKr9xSe_pA4JEUpC8Dhw4bQeVCDJPw,5460
|
376
376
|
rest/RemoteEvents.py,sha256=nL46U7AuxIrlw2JunphR1tsXyqi-ep_gD9CYGpYbNgE,72
|
377
|
-
rest/__init__.py,sha256=
|
377
|
+
rest/__init__.py,sha256=rpT5GRLaen0ZtXUGON9i6D2o8jTE0wUDdVakkyznoVk,122
|
378
378
|
rest/arc4.py,sha256=y644IbF1ec--e4cUJ3KEYsewTCITK0gmlwa5mJruFC0,1967
|
379
379
|
rest/cache.py,sha256=1Qg0rkaCJCaVP0-l5hZg2CIblTdeBSlj_0fP6vlKUpU,83
|
380
380
|
rest/crypto/__init__.py,sha256=Tl0U11rgj1eBYqd6OXJ2_XSdNLumW_JkBZnaJqI6Ldw,72
|
@@ -382,7 +382,7 @@ rest/crypto/aes.py,sha256=NOVRBRSHCV-om68YpGySWWG-4kako3iEVjq8hxZWPUU,4372
|
|
382
382
|
rest/crypto/privpub.py,sha256=_FioylVcbMmDP80yPYjURmafEiDmEAMkskbc7WF10ac,4082
|
383
383
|
rest/crypto/util.py,sha256=agFN2OCPHC70tHNGWrMkkZX4Tt_Ty6imoKEMdTkZpKA,4514
|
384
384
|
rest/datem.py,sha256=JHMvWG8A-n4g915wrZiCtfuhgcLMgNYMXuzXIEtgaPg,12335
|
385
|
-
rest/decorators.py,sha256=
|
385
|
+
rest/decorators.py,sha256=AuB4agpog587CUsF8HkAZiHDfs_pueb2rdxXZD7dUUE,15327
|
386
386
|
rest/encryption.py,sha256=x6Kiez0tVqfxK26MSsRL3k8OS05ni1gEX2aj3I0S9V0,788
|
387
387
|
rest/errors.py,sha256=uKwG9OkLme36etabqK54DMjMQc1fgEoUIAUxXa7WFQw,612
|
388
388
|
rest/extra/__init__.py,sha256=YzmNsch5H5FFLkUK9mIAKyoRK_rJCA9HGb0kubp4h30,54
|
@@ -456,7 +456,7 @@ taskqueue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
456
456
|
taskqueue/admin.py,sha256=E6zXoToS_ea3MdoGjZzF1JiepWFtDSoZUQdan8H-pXI,208
|
457
457
|
taskqueue/migrations/0001_initial.py,sha256=JwYib8CK5ftSXlfxKZUcKEEVsXktNB5q3h-2tu9inGk,4738
|
458
458
|
taskqueue/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
459
|
-
taskqueue/models.py,sha256=
|
459
|
+
taskqueue/models.py,sha256=VQ8Slk6Cm3H7ZDCfFP_b83VL2mpSdOOGTxALTZxQdqo,23726
|
460
460
|
taskqueue/periodic.py,sha256=hpXnunJL_cuVQLAKpjTbABbsQ4fvdsV9_gyyK-_53Sk,3844
|
461
461
|
taskqueue/rpc.py,sha256=Lf5VUoqCRkfWUAIvx_s508mjAtDPwpiWyxg0ryqWbQA,5793
|
462
462
|
taskqueue/tq.py,sha256=PzSoDrawYcqZylruEgsK95gcJ4J_VhdM6rxg9V6_X8E,942
|
@@ -509,7 +509,7 @@ ws4redis/servers/uwsgi.py,sha256=VyhoCI1DnVFqBiJYHoxqn5Idlf6uJPHvfBKgkjs34mo,172
|
|
509
509
|
ws4redis/settings.py,sha256=K0yBiLUuY81iDM4Yr-k8hbvjn5VVHu5zQhmMK8Dtz0s,1536
|
510
510
|
ws4redis/utf8validator.py,sha256=S0OlfjeGRP75aO6CzZsF4oTjRQAgR17OWE9rgZdMBZA,5122
|
511
511
|
ws4redis/websocket.py,sha256=R0TUyPsoVRD7Y_oU7w2I6NL4fPwiz5Vl94-fUkZgLHA,14848
|
512
|
-
django_restit-4.2.
|
513
|
-
django_restit-4.2.
|
514
|
-
django_restit-4.2.
|
515
|
-
django_restit-4.2.
|
512
|
+
django_restit-4.2.115.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
|
513
|
+
django_restit-4.2.115.dist-info/METADATA,sha256=uI2rG3O3i93ljjzF9wkBo86YUx0sUU-eR6FfZ8erZHQ,7663
|
514
|
+
django_restit-4.2.115.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
515
|
+
django_restit-4.2.115.dist-info/RECORD,,
|
incident/models/event.py
CHANGED
@@ -14,6 +14,7 @@ from .rules import Rule
|
|
14
14
|
|
15
15
|
INCIDENT_METRICS = settings.get("INCIDENT_METRICS", False)
|
16
16
|
INCIDENT_EVENT_METRICS = settings.get("INCIDENT_EVENT_METRICS", False)
|
17
|
+
INCIDENT_EVENT_GRANULARITY = settings.get("INCIDENT_EVENT_GRANULARITY", "hourly")
|
17
18
|
EVENT_TO_INCIDENT_LEVEL = settings.get("EVENT_TO_INCIDENT_LEVEL", 4)
|
18
19
|
EVENT_DETAIL_TEMPLATES = settings.get("EVENT_DETAIL_TEMPLATES", None)
|
19
20
|
EVENT_META_KEYWORDS = settings.get("EVENT_META_KEYWORDS", [
|
@@ -144,7 +145,7 @@ class Event(JSONMetaData, rm.RestModel):
|
|
144
145
|
if INCIDENT_EVENT_METRICS:
|
145
146
|
if self.hostname:
|
146
147
|
metrics.metric(f"incident_evt_{self.hostname}", category="incident_events", min_granularity="hourly")
|
147
|
-
metrics.metric("incident_evt",
|
148
|
+
metrics.metric("incident_evt", min_granularity=INCIDENT_EVENT_GRANULARITY)
|
148
149
|
|
149
150
|
self.setProperty("level", self.level)
|
150
151
|
if request is not None:
|
@@ -199,9 +200,10 @@ class Event(JSONMetaData, rm.RestModel):
|
|
199
200
|
self.incident = incident
|
200
201
|
self.save()
|
201
202
|
if INCIDENT_METRICS:
|
203
|
+
# we want to track any incidents, including bundles
|
202
204
|
if self.hostname:
|
203
205
|
metrics.metric(f"incidents_{self.hostname}", category="incidents", min_granularity="hourly")
|
204
|
-
metrics.metric("incidents",
|
206
|
+
metrics.metric("incidents", min_granularity=INCIDENT_EVENT_GRANULARITY)
|
205
207
|
|
206
208
|
try:
|
207
209
|
incident.triggerAction()
|
metrics/client.py
CHANGED
@@ -607,6 +607,10 @@ class R(object):
|
|
607
607
|
data[slug].append(v)
|
608
608
|
|
609
609
|
# Now, reorganize data for our end result.
|
610
|
+
if len(slugs) == 0:
|
611
|
+
periods = self.build_periods("junk", since, granularity=granularity, samples=samples)
|
612
|
+
values = [0 for p in periods]
|
613
|
+
return dict(periods=periods, data=[dict(slug="na", values=values)])
|
610
614
|
periods = self.build_periods(slugs[0], since, granularity=granularity, samples=samples)
|
611
615
|
metrics = {'periods': periods, 'data': []}
|
612
616
|
for slug, values in data.items():
|
rest/__init__.py
CHANGED
rest/decorators.py
CHANGED
@@ -25,6 +25,7 @@ import traceback
|
|
25
25
|
REST_METRICS = settings.get("REST_METRICS", False)
|
26
26
|
REST_METRICS_BY_ENDPOINT = settings.get("REST_METRICS_BY_ENDPOINT", False)
|
27
27
|
REST_METRICS_IGNORE = settings.get("REST_METRICS_IGNORE", [])
|
28
|
+
REST_METRICS_GRANULARITY = settings.get("REST_METRICS_GRANULARITY", "daily")
|
28
29
|
REST_MODULE_NAME = settings.get("REST_MODULE_NAME", "rpc")
|
29
30
|
|
30
31
|
|
@@ -55,17 +56,17 @@ def postpone(function):
|
|
55
56
|
def rest_error_catcher(func, request, *args, **kwargs):
|
56
57
|
try:
|
57
58
|
if REST_METRICS:
|
58
|
-
metrics.metric("rest_calls")
|
59
|
+
metrics.metric("rest_calls", min_granularity=REST_METRICS_GRANULARITY)
|
59
60
|
if REST_METRICS_BY_ENDPOINT:
|
60
61
|
slug_path = request.path.replace("/", "__")
|
61
|
-
metrics.metric(f"rest_call_{slug_path}", category="rest_calls")
|
62
|
+
metrics.metric(f"rest_call_{slug_path}", category="rest_calls", min_granularity=REST_METRICS_GRANULARITY)
|
62
63
|
return func(request, *args, **kwargs)
|
63
64
|
except PermissionDeniedException as err:
|
64
65
|
return rv.restPermissionDenied(request, err.reason, err.code)
|
65
66
|
except RestError as err:
|
66
67
|
rh.log_exception("REST ERROR", request.path, err.reason)
|
67
68
|
if settings.get("REST_ERROR_METRICS", True):
|
68
|
-
metrics.metric("rest_errors")
|
69
|
+
metrics.metric("rest_errors", min_granularity=REST_METRICS_GRANULARITY)
|
69
70
|
if settings.get("REST_ERROR_EVENTS", True):
|
70
71
|
incident.exception_event(
|
71
72
|
request, f"{err.code}: {err.reason}", level=7,
|
@@ -75,7 +76,7 @@ def rest_error_catcher(func, request, *args, **kwargs):
|
|
75
76
|
except Exception as err:
|
76
77
|
rh.log_exception("REST EXCEPTION", request.path)
|
77
78
|
if settings.get("REST_ERROR_METRICS", True):
|
78
|
-
metrics.metric("rest_errors")
|
79
|
+
metrics.metric("rest_errors", min_granularity=REST_METRICS_GRANULARITY)
|
79
80
|
try:
|
80
81
|
body = request.body.decode('utf-8')
|
81
82
|
except Exception:
|
taskqueue/models.py
CHANGED
@@ -8,6 +8,7 @@ from rest import crypto
|
|
8
8
|
from ws4redis import client as redis
|
9
9
|
from account.models import Member
|
10
10
|
import importlib
|
11
|
+
import metrics
|
11
12
|
|
12
13
|
import traceback
|
13
14
|
|
@@ -34,6 +35,12 @@ TASK_STATES = [
|
|
34
35
|
TQ_RETRY_BACKOFF_FACTOR = settings.get("TQ_RETRY_BACKOFF_FACTOR", 2)
|
35
36
|
TQ_RETRY_ATTEMPTS = settings.get("TQ_RETRY_ATTEMPTS", 5)
|
36
37
|
TQ_RETRY_DELAY = settings.get("TQ_RETRY_DELAY", 60)
|
38
|
+
TQ_METRICS = settings.get("TQ_METRICS", True)
|
39
|
+
TQ_METRICS_GRANULARITY = settings.get("TQ_METRICS_GRANULARITY", "hourly")
|
40
|
+
TQ_METRICS_CREATED = settings.get("TQ_METRICS_CREATED", False)
|
41
|
+
TQ_METRICS_FUNCTION = settings.get("TQ_METRICS_FUNCTION", False)
|
42
|
+
TQ_METRICS_CHANNEL = settings.get("TQ_METRICS_CHANNEL", False)
|
43
|
+
|
37
44
|
|
38
45
|
def getAppHandler(app_name, fname):
|
39
46
|
try:
|
@@ -225,6 +232,12 @@ class Task(models.Model, RestModel):
|
|
225
232
|
self.runtime = int(time.time() - self._started)
|
226
233
|
self.state = TASK_STATE_COMPLETED
|
227
234
|
self.save()
|
235
|
+
if TQ_METRICS:
|
236
|
+
metrics.metric("tq_task_completed", min_granularity=TQ_METRICS_GRANULARITY)
|
237
|
+
if TQ_METRICS_CHANNEL:
|
238
|
+
metrics.metric(f"tq_chan_done_{self.channel}", category="tq_chan_done", min_granularity=TQ_METRICS_GRANULARITY)
|
239
|
+
if TQ_METRICS_FUNCTION:
|
240
|
+
metrics.metric(f"tq_func_done_{self.fname}", category="tq_func_done", min_granularity=TQ_METRICS_GRANULARITY)
|
228
241
|
|
229
242
|
def failed(self, reason=None, category="taskqueue_errors"):
|
230
243
|
if reason and len(reason) > 250:
|
@@ -233,6 +246,12 @@ class Task(models.Model, RestModel):
|
|
233
246
|
self.state = TASK_STATE_FAILED
|
234
247
|
self.notifyError(category=category, reason=reason)
|
235
248
|
self.save()
|
249
|
+
if TQ_METRICS:
|
250
|
+
metrics.metric("tq_task_failed", min_granularity=TQ_METRICS_GRANULARITY)
|
251
|
+
if TQ_METRICS_CHANNEL:
|
252
|
+
metrics.metric(f"tq_chan_fail_{self.channel}", category="tq_chan_fail", min_granularity=TQ_METRICS_GRANULARITY)
|
253
|
+
if TQ_METRICS_FUNCTION:
|
254
|
+
metrics.metric(f"tq_func_fail_{self.fname}", category="tq_func_fail", min_granularity=TQ_METRICS_GRANULARITY)
|
236
255
|
|
237
256
|
def notifyError(self, category="taskqueue_errors", reason=None):
|
238
257
|
handler = f"{self.model}.{self.fname}"
|
@@ -287,6 +306,8 @@ class Task(models.Model, RestModel):
|
|
287
306
|
out.data = self.data
|
288
307
|
if not channel:
|
289
308
|
channel = self.channel
|
309
|
+
if TQ_METRICS and TQ_METRICS_CREATED:
|
310
|
+
metrics.metric("tq_task_created", min_granularity=TQ_METRICS_GRANULARITY)
|
290
311
|
return redis.publish(channel, out)
|
291
312
|
|
292
313
|
def getHandler(self):
|
File without changes
|
File without changes
|