generator-nrsynthetics-workspace v0.1.0
generator-nrsynthetics-workspace
Generate local workspace for creating/testing NR Synthetics ScriptedBrowse and API Tests.
Installation
First, install Yeoman and generator-nrsynthetics-workspace using npm (we assume you have pre-installed node.js).
npm install -g yo
npm install -g generator-nrsynthetics-workspaceThen generate your new project:
yo nrsynthetics-workspaceGenerating a NR Synthetics workspace
Run
yo nrsynthetics-workspacefrom commandlineSelect
Yeswhen prompted? Enable Download/Upload of Synthetics scripts to your account?Enter your Admin API Key when prompted
? Enter your admin Api Key
This generator can also be run with: yo synth-generator
_-----_ ╭──────────────────────────╮
| | │ Welcome to the │
|--(o)--| │ bedazzling Synthetics │
`---------´ │ generator! │
( _´U`_ ) ╰──────────────────────────╯
/___A___\ /
| ~ |
__'.___.'__
´ ` |° ´ Y `
? Enable Download/Upload of Synthetics scripts to your account? Yes
? Enter your admin Api Key NRAA-XXXXXXXXXXXXXXXXXXXXXXXXXXXThe admin key will be stored in .nrconfig.json.
Download / Upload monitor
- Download monitor by running this command:
npm run downloadto uploadnpm run upload - You will be presented with a list for Scripted Browser and API test.
You can select single or multiple monitors or select
ALL.
> npm run download
Using apiKey: "XXXX-XXXXXXXXXXXXXXXXXXXXXXXXX"
? Select Monitors (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯ ◯ ALL
= Scripted Browsers =
◯ scriptedBrowser-test1
◯ scriptedBrowser-test2
= API Tests =
◯ apiTest-test1
◯ apiTest-test2Files are downloaded to ./monitors directory including the monitor configuration are saved in nr-monitor.json.
NOTE: Do not rename the file or update the configuration file.
Running script locally
Add this to the top of your script, the library mimcs the Synthetics API and implements most common commands in Synthetics.
if (typeof $env === 'undefined'){
require('../lib/simulator')();
}Open a terminal, and cd ./monitors
node <filename>.jsOr from VSCode hit F5.
Directory
./synthetics-local
|
├── apps
│ ├── downloadConfig.js
│ ├── downloadScripts.js
│ ├── listLocalScripts.js
│ └── uploadScripts.js
|
├── examples
│ ├── apiTest.js
│ └── scriptedBrowser.js
├── lib
│ ├── simulator.js // mock New Relic Synthetics implicit objects
|
├── LICENSE
├── monitors // created after downloading a monitor
│ ├── nr-monitor.json // holds the account monitor configurations
│ └── scriptedBrowser-test1.js // downloaded script
|
├── package.json
└── package-lock.jsonLicense
Apache-2.0 © Benedicto Tan
5 years ago