django-restit 4.2.116__py3-none-any.whl → 4.2.118__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.116.dist-info → django_restit-4.2.118.dist-info}/METADATA +1 -1
- {django_restit-4.2.116.dist-info → django_restit-4.2.118.dist-info}/RECORD +7 -7
- incident/models/incident.py +15 -25
- metrics/models.py +5 -3
- rest/__init__.py +1 -1
- {django_restit-4.2.116.dist-info → django_restit-4.2.118.dist-info}/LICENSE.md +0 -0
- {django_restit-4.2.116.dist-info → django_restit-4.2.118.dist-info}/WHEEL +0 -0
@@ -114,7 +114,7 @@ incident/migrations/0015_rule_title_template_alter_incident_state.py,sha256=FPUD
|
|
114
114
|
incident/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
115
115
|
incident/models/__init__.py,sha256=NMphuhb0RTMf7Ov4QkNv7iv6_I8Wtr3xQ54yjX_a31M,209
|
116
116
|
incident/models/event.py,sha256=LNKYdqOj_CO4aGvc2dNmy3K-S52Udi_gZ4-wintbs1s,7901
|
117
|
-
incident/models/incident.py,sha256=
|
117
|
+
incident/models/incident.py,sha256=v3UAQFn5IsoS8vhHEQXmGgZ8cIf8Hnd5elmULDTnYlk,19825
|
118
118
|
incident/models/ossec.py,sha256=eUDRGawzuLWobKEVGKfdZisDnyjS_Hlxi0T_GCSLCCI,2252
|
119
119
|
incident/models/rules.py,sha256=aRkJ0ZnTv87nAUC1sHVkPExfb3OJ8fgHQIhnCIpIbhQ,7001
|
120
120
|
incident/models/ticket.py,sha256=S3kqGQpYLE6Y4M9IKu_60sgW-f592xNr8uufqHnvDoU,2302
|
@@ -351,7 +351,7 @@ metrics/migrations/0003_metrics_expires.py,sha256=_g4oRv4NHW-4iCQx2s1SiF38LLyFf8
|
|
351
351
|
metrics/migrations/0004_eodmetrics.py,sha256=Ky6ZVMZqa0F_SUp_QFWY7ZKBgVhy9CS4wZcsEhrkSgc,3271
|
352
352
|
metrics/migrations/0005_alter_metrics_v1_alter_metrics_v10_alter_metrics_v11_and_more.py,sha256=pmwJfpPJ1RUX_CqM66l6vvV-nrAUPo_GIan0Pc9mQHs,2358
|
353
353
|
metrics/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
354
|
-
metrics/models.py,sha256
|
354
|
+
metrics/models.py,sha256=-sATVwJpN830fb02WR7iX48dYEPHFLKJMJ-5PlS8GOw,13536
|
355
355
|
metrics/periodic.py,sha256=IayBLLat40D8FB-A3bYBW9lxm9-IzcugQunojThQ_OU,661
|
356
356
|
metrics/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
357
357
|
metrics/providers/aws.py,sha256=dIBGFE1Fvszy6rmVrn_Fm1zUDv345q4dBsg9Iit-XCc,8358
|
@@ -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=xEslkzQlilJn1Z0GyVu43AgfKG-dqCpYSTh7lo0rFZk,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
|
@@ -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.118.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
|
513
|
+
django_restit-4.2.118.dist-info/METADATA,sha256=NWCvCnQ0SAtLaQlZQUGKZEVIzbLf8_VNVAfNE_7Re2M,7663
|
514
|
+
django_restit-4.2.118.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
515
|
+
django_restit-4.2.118.dist-info/RECORD,,
|
incident/models/incident.py
CHANGED
@@ -13,20 +13,9 @@ import time
|
|
13
13
|
|
14
14
|
logger = log.getLogger("incident", filename="incident.log")
|
15
15
|
|
16
|
-
EVENT_META_TO_INCIDENT =
|
17
|
-
"
|
18
|
-
|
19
|
-
"phone",
|
20
|
-
"group_name",
|
21
|
-
"group_id",
|
22
|
-
("http_user_agent", "user_agent"),
|
23
|
-
"user_agent",
|
24
|
-
"http_url",
|
25
|
-
"error",
|
26
|
-
"error_code",
|
27
|
-
"rule_id",
|
28
|
-
"path"
|
29
|
-
]
|
16
|
+
EVENT_META_TO_INCIDENT = {
|
17
|
+
"http_user_agent": "user_agent"
|
18
|
+
}
|
30
19
|
|
31
20
|
INCIDENT_STATE_NEW = 0
|
32
21
|
INCIDENT_STATE_OPENED = 1
|
@@ -139,22 +128,23 @@ class Incident(models.Model, rm.RestModel, rm.MetaDataModel):
|
|
139
128
|
self.setProperty("event_count", count)
|
140
129
|
|
141
130
|
def updateMeta(self, event):
|
142
|
-
for key in
|
143
|
-
|
144
|
-
if isinstance(
|
145
|
-
|
146
|
-
if key in
|
147
|
-
|
148
|
-
|
131
|
+
for key in event.metadata:
|
132
|
+
v = event.metadata[key]
|
133
|
+
if not isinstance(v, (str, int, float)):
|
134
|
+
continue
|
135
|
+
if key in EVENT_META_TO_INCIDENT:
|
136
|
+
if isinstance(EVENT_META_TO_INCIDENT[key], tuple):
|
137
|
+
key = EVENT_META_TO_INCIDENT[key][1]
|
138
|
+
self.setProperty(key, v)
|
139
|
+
|
140
|
+
if event.details:
|
141
|
+
self.setProperty("details", event.details)
|
142
|
+
|
149
143
|
if event.metadata.geoip and event.metadata.geoip.city:
|
150
144
|
self.setProperty("city", event.metadata.geoip.city)
|
151
145
|
self.setProperty("state", event.metadata.geoip.state)
|
152
146
|
self.setProperty("country", event.metadata.geoip.country)
|
153
147
|
self.setProperty("isp", event.metadata.geoip.isp)
|
154
|
-
else:
|
155
|
-
for key in ["city", "state", "country", "isp"]:
|
156
|
-
if key in event.metadata:
|
157
|
-
self.setProperty(new_key, event.metadata[key])
|
158
148
|
|
159
149
|
def shouldTriggerAction(self):
|
160
150
|
count = self.events.all().count()
|
metrics/models.py
CHANGED
@@ -46,17 +46,18 @@ def metric(
|
|
46
46
|
m.updateMetrics(keys, data, created)
|
47
47
|
|
48
48
|
|
49
|
-
def gauge(slug, keys, data, granularity="daily", group=None, date=None, timezone=None, slug_append=None):
|
49
|
+
def gauge(slug, keys, data, granularity="daily", group=None, date=None, timezone=None, slug_append=None, max_granularity=None):
|
50
50
|
# guage does not accumulate but just stores the data like a cache
|
51
51
|
# if calledf on the same time period it will just update the current numbers
|
52
52
|
uuid_key = generate_uuid(slug, group, slug_append)
|
53
53
|
granularities = utils.granularities(granularity, granularity)
|
54
54
|
date = normalize_date(date, timezone, group)
|
55
|
-
|
55
|
+
if max_granularity is None:
|
56
|
+
max_granularity = granularity
|
56
57
|
uuids = utils.build_keys(
|
57
58
|
uuid_key, date,
|
58
59
|
min_granularity=granularity,
|
59
|
-
max_granularity=
|
60
|
+
max_granularity=max_granularity)
|
60
61
|
|
61
62
|
for gran, key in zip(granularities, uuids):
|
62
63
|
# DO not change slug to uuid_key so we can filter by group using group field
|
@@ -72,6 +73,7 @@ def gauge(slug, keys, data, granularity="daily", group=None, date=None, timezone
|
|
72
73
|
group=group, start=utils.date_for_granulatiry(date, gran)))
|
73
74
|
m.setMetrics(keys, data, created)
|
74
75
|
|
76
|
+
|
75
77
|
def normalize_date(date=None, timezone=None, group=None):
|
76
78
|
if date is None:
|
77
79
|
date = utils.datetime.utcnow()
|
rest/__init__.py
CHANGED
File without changes
|
File without changes
|