Synthetics Monitor Script USER_DEFINED_VARIABLES Not Found

I created a Synthetics Monitor Script to ping a server and now that I want to save the server ip address as some secret.

I came across CPM (Install containerized private minions (CPMs) | New Relic Documentation) and it seems it can create environment variables in monitor scripts. I set up a private location and run a minion with custom environment variables.

Then I went back to my synthetics monitor script and tried to access with $env.USER_DEFINED_VARIABLES. I can see all other 8 variables on this page, except $env.USER_DEFINED_VARIABLES. (Manage monitor runtimes | New Relic Documentation )

Did I miss something here?

HI @weiting.chen ,

Happy New Year! Hope 2022 has been going great for you so far!

Through the configuration of CPM Environment Variables based around either creating the environment variable and either passing it or using a json file for Docker or Kubernetes would allow you to access it via something like:

$env.USER_DEFINED_VARIABLES.MY_VARIABLE

docker run -e MINION_PRIVATE_LOCATION_KEY=$SOME-KEY -e MINION_USER_DEFINED_ENV_VARIABLES='{"KEY":"VALUE","NAME":"MINION","ETC":"ETC"}' -v /tmp:/tmp:rw -v /var/run/docker.sock:/var/run/docker.sock:rw quay.io/newrelic/synthetics-minion:latest

I run the script as the above and then tried to access it in my synthetic monitor script with $env.USER_DEFINED_VARIABLES.NAME but it just couldn’t find USER_DEFINED_VARIABLES and returns undefined. I can see the minion count is 1.

I’m running docker run locally on my computer. Not sure if I misunderstood anything here

I think I found where I did wrong. So I need to assign that private location upon creating the monitor.

1 Like

Glad you sorted this our @weiting.chen - thanks so much for sharing how you solved it!