Feature Idea: Referencing common script functions

Is there a mechanism where we can store common scripts on the New Relic servers or do we have to host them on our own servers?

For example, I have created some API monitors and the authorisation is common with a few parameters so I have been duplicating this code in each API monitor where I would like to put these in a common script asset.

Potential consideration for product improvement?

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.

1 Like

Hi @stefan_garnham, currently it’s not possible to store common scripts on the New Relic servers but I have filed a feature request with our product management team for such functionality.

Hi @stefan_garnham,

right now we don’t offer a way to host “common scripts” but you do have the ability to fetch it from… anywhere you like really. It’s just a plain http request away.

So, to substantiate what I’m claiming, I wrote this simple monitor:

var req = require('urllib-sync').request;
var res = req('https://gist.githubusercontent.com/detro/23c09b9153251d904dfc/raw/156b3f9b3e8c8a25e0841e9ff6d3ed8dc91e6fcc/remote_loaded.js');
var monitorBody = new Function('$browser', res.data);


I wrote a very basic script and hosted it on GitHub Gist (but you can host the script anywhere reachable with a simple HTTP request).
Than I use the urllib-sync that is the equivalent of cURL, and allows to do the request synchronously.

So the response object res contains the data field: that will be the body of the script I posted on GitHub gist.

I wrapped that in a new Function() call, so I generated a runnable function that expects as parameter the variable $browser.

Now my script lives on GitHub but I run it on Synthetics :smile:

It’s not our final solution, but I hope a way to move forward with your needs.


1 Like

That’s a workaround which would be acceptable while awaiting the functionality to upload our own scripts/functions.

With your solution, if GitHub is down then the synthetic fails resulting in having to analyse the script. I feel that the fewer external hosting dependencies we can get, the more robust the solution.

Hey, if New Relic were to go down then we would know about it pretty quickly :stuck_out_tongue_winking_eye:

Absolutely. Your point is fair.

And I’m in no way advertising this as “the ultimate solution”.
It’s more of a way to move forward, while we cover that usage scenario.


We will have potentially hundreds of scripts and most will have a common login sequence (among other common actions) . From what I’m reading here there is no way to #include common code or user defined libs/functions to avoid writing and maintaining the same code across all of our scripts? This is such a huge, inefficient gap that, quite frankly, I hope I am not the one selected to maintain our synthetic monitors. I hope this is something that is considered for enhancement.

@don_bonin Hopefully @idemarino option might help mitigate some of the potential issues in having to login on hundreds of scripts.

I’ll file a feature request to suggest the idea to our product managers. It’s not a guarantee the feature would be implemented but it does ensure the idea is discussed by our product managers as they plan our roadmap and if implemented you should be notified of it’s rolling out to production.


Is there any progress on this feature request?

@Linds - can you convert this to a poll like the newer feature requests please?

1 Like

Sure thing, @stefan_garnham!

Keep checking back for updates. :blush:


How could I call functions located in the gist?



In @idemarino 's example, their gist link just returns the string $browser.get('http://www.google.com'); they then take this string value and set that in the body parameter for the Function constructor.

That Function is instantiated with new and stored in the variable monitorBody, which is then invoked to execute the function body code.

Similarly you can host reusable code as a string value on an endpoint (hosted on gist as for the example), fetch it from your Synthetics script, and execute it using the Function constructor.

1 Like

Hi all,

I was wondering if this is still in the works? It would be cool to have this in New Relic!



Hey @chelsea.x.boling_nd - indeed, for now this is not yet available and is still a feature request.

Does Ivan’s workaround above work for you?

Regardless of the workaround, I’ll get your +1 added here for inbuilt support for reusable code anyway :slight_smile:

1 Like