Hi
I have written the extension EF2 (OneAgent), which monitors the validity of Cloudflare certificates. It connects to Cloudflare, sends an API request, gets a response, does the math, gets the results. Boring, trivial and cliché.
At the end of the whole process, if the result is less than 7 days, it sends CUSTOM_ALERT to Dynatrace (entity type: CUSTOM_DEVICE). And here I have a small problem, because if only one certificate is in such a state, then the alert is visible in Dynatrace. But if I have multiple such certificates, I have to send multiple CUSTOM_ALERT with different payloads, but in my case the payload is just overwritten instead of being sent independently. Is there a setting that I am not aware of that causes Dynatrace to handle these alerts independently?
Here is the code snippet responsible for alerts:
if len(certificates) > 0:
for crt in certificates:
if crt['type'] in ("advanced", "universal", "sni_custom") and len(crt['certificates']) > 0:
d1 = datetime.now() + timedelta(int(self.cf_days))
d2 = datetime.strptime(crt['certificates'][0]['expires_on'], '%Y-%m-%dT%H:%M:%S.%fZ')
if d2 < d1:
delta = d2 - datetime.now()
self.report_dt_event(event_type=DtEventType.CUSTOM_ALERT,
title="The certificate will expire in " + str(delta.days),
timeout=60,
entity_selector="type(CUSTOM_DEVICE),entityName.equals(Cloudflare_Certificates)",
properties={
"dt.event.allow_davis_merge": "false",
"Account Name": zone['account_name'],
"Zone Name": zone['zone_name'],
"Zone ID": zone['zone_id'],
"Certificate Authority": crt['certificate_authority'],
"Status": crt['status'],
"Expires On": d2.strftime('%Y-%m-%d'),
"Days left until expiration": str(delta.days)
}
)