Cannot create Synthetic monitors with NerdGraph

Hello,
I tried following this tutorial from the NerdGraph documentation, but unfortunately I get an error messsage when I try to create the monitor. I’m wondering if the documentation is correct or if this funtionality hasn’t been implemented yet.

my API call:
(I’ve tried both curl and the online query builder.)

mutation {
    syntheticsCreateScriptApiMonitor (
      accountId: 1111111, 
      monitor: {
        locations: {
          public: ["Paris, FR"]
          }, 
        name: "TEST", 
        period: EVERY_DAY,
        runtime: {
          runtimeType: "NODE_API",
          runtimeTypeVersion: "16.10.0",
          scriptLanguage: "JAVASCRIPT"
        }
        script: "test", 
        status: ENABLED
      }
    ) {
      errors {
        description
        type
      }
    }
  }

The response:

{
  "data": {
    "syntheticsCreateScriptApiMonitor": null
  },
  "errors": [
    {
      "locations": [
        {
          "column": 5,
          "line": 2
        }
      ],
      "message": "Cannot query field \"syntheticsCreateScriptApiMonitor\" on type \"RootMutationType\".",
      "path": [
        "syntheticsCreateScriptApiMonitor"
      ]
    }
  ]
}

Thank you in advance.

Hi, @ewout.vanschil: This query works for me:

mutation {
  syntheticsCreateScriptApiMonitor (
    accountId: 1038287, 
    monitor: {
      locations: {
        public: "US_WEST_1"
      }, 
      name: "My API Monitor", 
      period: EVERY_DAY, 
      script: "$http.get('https://google.com');", 
      status: ENABLED
    }) {
    errors {
      description
      type
    }
  }
}

I think the issue is your location: try passing EU_WEST_3.

Thank you for your answer, I’ve tried replacing the location in my original query and tried running yours with my account ID but sadly it still returns the same error.

this is the curl command I used:

curl https://api.eu.newrelic.com/graphql \

  -H 'Content-Type: application/json' \

  -H 'API-Key: NRAK-MYKEY123' \

  --data-binary '{"query":"mutation {\n  syntheticsCreateScriptApiMonitor(accountId: 1111111, monitor: {locations: {public: \"EU_WEST_3\"}, name: \"My API Monitor\", period: EVERY_DAY, script: \"$http.get(\u0027https://google.com\u0027);\", status: ENABLED}) {\n    errors {\n      description\n      type\n    }\n  }\n}\n", "variables":""}'

Hey @ewout.vanschil - I wonder if there is an issue in your curl. Could you try the same config within the GraphQL explorer and let us know if the response is the same with the new location format that @philweber mentioned?

Hi Ryan,

I’ve tried using the GraphQL explorer, (Its’s the api.eu one for me not the one you linked if that makes a difference.) This is the query I used and it still returns the same error. “syntheticsCreateScriptApiMonitor” is also underlined in red.

mutation {
  syntheticsCreateScriptApiMonitor (
    accountId: 1111111, 
    monitor: {
      locations: {
        public: "EU_WEST_3"
      }, 
      name: "My API Monitor", 
      period: EVERY_DAY, 
      script: "$http.get('https://google.com');", 
      status: ENABLED
    }) {
    errors {
      description
      type
    }
  }
}

Thanks for clarifying that this is for the EU region - let me take this to the dev team and see if there are expected differences in EU vs US. I’ll get back to you once I get an update.

Hey @ewout.vanschil - looks like this was an issue on our side in the EU version of NerdGraph!

That should be fixed now - could you try again and confirm it now works for you please?

1 Like

Hi Ryan,
It appears to be working now, thank you for your help!

Hi @ewout.vanschil

Thats great news, thanks for confirming it is working now!

I hope you have a great day!

Quick question If I want to use a private location where can I find the minion GUID?.. I been looking for hours and I cant find it.

You can use this query to get the details of the Private Minions and their GUIDs:

{
  actor {
    entitySearch(query: "domain = 'SYNTH' AND type = 'PRIVATE_LOCATION'") {
      results {
        entities {
          guid
          name
        }
      }
    }
  }
}
3 Likes

@vamsi_krishna_pattam Thank you for sharing that query! :slight_smile: