Scripting Random Incidents for Testing

platform
transformers
official
howto

(David Hayes) #1

Here’s an easy ask from one of our larger customers “Can I script a bunch of incidents with descriptions?”

Here’s the custom event transformer I gave them. If picks a random description and adds a random value:

var errors = ["The Server load is over #%", "# Security incidents detected", "Over # support tickets in Queue"]

var description = errors[Math.floor(Math.random()*errors.length)]
var n = Math.floor(Math.random()*100)
description = description.replace("#", n)

var normalized_event = {
  event_type: PD.Trigger,
  description: description,
  details: {
  	count: n
  }
};

PD.emitGenericEvents([normalized_event]);

You can run it manually by hitting the integration URL, but we actually set up monitoring on the integration URL – so a monitoring tool triggers it every hour :slight_smile:


(system) #2