Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Feature Idea: Alert Notification Channel/Webhook - Enable execution of a Synthetic monitor

webhook
synthetics
api
feature-idea

#1

I am requesting a feature that will allow an alert notification to activate a synthetic monitor.

Presently, an Alert webhook notifaction channel executes a POST. The Synthetic API requires a PATCH (or PUT) request to change an existing monitor. And since the notification webhook is a single request, I can’t add the script to the monitor (requires a subsequent PUT request).

There are a variety of other enhancements that I’d suggest, like:

  • pass params
  • deduplication,

But, I’d be happy with the baby step to change a monitor’s status to ENABLE. I’ll call the Synthetics API from within the script to change it’s own status to DISABLE at the end of the script execution (the request library should allow me to do this), but I’m not sure this is really doable at this point. Seems it should be, but haven’t tested it yet.

In the meantime, I’ll configure the alert webhook to insert Insights custom events and poll them from a synthetic monitor. But, this is not an ideal solution. There’s cost associated with polling that is avoided with on-demand execution. (of course, some may want to poll - depends on the use case).

Suggestions from NR and the community are always welcome

Thanks


New Relic Edit

  • I want this too
  • I have more info to share (reply below)
  • I have a solution for this

0 voters

We take feature ideas seriously and our product managers review every one when plotting their roadmaps. However, there is no guarantee this feature will be implemented. This post ensures the idea is put on the table and discussed though. So please vote and share your extra details with our team.


#2

Hi, @CHRISTOPHER.MCKENNA: Until this feature is implemented, the workaround is to create your own endpoint (such as a lambda function) to receive the webhook POST and do what you want with it (such as issue a PUT request to Synthetics).


#3

@CHRISTOPHER.MCKENNA - Thanks for posting so much detail in your feature request! I’ve got that sent up for you internally :smiley:


#4

@philweber Thanks for the suggestion. Are you aware of an an existing Lambda implementation for receiving New Relic alert webhooks on Github or elsewhere? I’ll a bit of a newb in this area. Good pointers are greatly appreciated.


#5

Here is a simple Node Express application that will receive a POST containing the ID of a Synthetics monitor, and issue a PATCH request to enable it:

const request = require('request');
const express = require('express');
const app = express();
const port = 8000;

// Body parser
app.use(express.json());

app.listen(port, () => {
  console.log(`Listening on port ${port}`);
});

app.post("/", (req, res) => {
  const monitor = req.body.synthetics_monitor_to_activate;
  const headers = {
    "Content-Type": "application/json",
    "X-Api-Key": YOUR_ADMIN_API_KEY
  };
  const options = {
    url: "https://synthetics.newrelic.com/synthetics/api/v3/monitors/" + monitor,
    method: "PATCH",
    headers: headers, 
    body: JSON.stringify({ status: 'enabled' })
  };
  request(options, 
    function(error, response, body) {
      console.log(error);
      res.end();
    }
  );
});

#6

@philweber Thank you very much.