Quantcast
Channel: PagerDuty Community - Latest topics
Viewing all articles
Browse latest Browse all 1569

Scripting Random Incidents for Testing

$
0
0

@dave wrote:

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:

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 1569

Trending Articles