New Relic allows you use NerdGraph to create broken links monitors. Broken links monitors check for broken links on a webpage by scanning all links and reporting any that return unsuccessful HTTP status codes. This tutorial provides examples of how to use the NerdGraph API to automate the creation of broken links monitors.
Create a broken links monitor
You can create a broken links monitor using the syntheticsCreateBrokenLinksMonitor mutation. This mutation allows you to set up monitoring for broken links on any webpage.
Input parameters
Parameter | Data Type | Is it Required? | Description |
|---|---|---|---|
| Integer | Yes | Your New Relic account ID where the monitor will be created. |
| Array | Yes | Array of public location identifiers where the monitor will run checks (e.g., |
| String | Yes | The display name for your broken links monitor. |
| Enum | Yes | How often the monitor runs. Options: |
| Enum | Yes | The monitor status. Options: |
| String | Yes | The URI of the webpage to scan for broken links (e.g., |
| Float | No | The monitor's Apdex target in seconds, used to populate SLA reports. Defaults to 7.0 seconds. |
| Object | No | Tags to organize and filter monitors. Each tag has a |
Sample request
mutation { syntheticsCreateBrokenLinksMonitor( accountId: ACCOUNT_ID monitor: { locations: { public: ["LOCATION_1", "LOCATION_2"] } name: "YOUR_MONITOR_NAME" period: PERIOD status: STATUS apdexTarget: APDEX_TARGET uri: "MONITOR_URI" tags: { key: "YOUR_TAG_NAME", values: "TAG_VALUE" } } ) { errors { description type } }}Sample response
A successful response returns null for errors:
{ "data": { "syntheticsCreateBrokenLinksMonitor": { "errors": null } }}If there are any issues creating the monitor, the errors array will contain objects with description and type fields explaining what went wrong.
Update a broken links monitor
You can update an existing broken links monitor using the syntheticsUpdateBrokenLinksMonitor mutation. This allows you to modify the configuration of a broken links monitor that has already been created.
Input parameters
Parameter | Data Type | Is it Required? | Description |
|---|---|---|---|
| String | Yes | The unique entity GUID of the monitor you want to update. |
| Array | No | Array of public location identifiers where the monitor will run checks (e.g., |
| String | No | The updated display name for your broken links monitor. |
| Enum | No | How often the monitor runs. Options: |
| Enum | No | The monitor status. Options: |
| String | No | The URI of the webpage to scan for broken links (e.g., |
| Float | No | The monitor's Apdex target in seconds, used to populate SLA reports. Defaults to 7.0 seconds. |
| Object | No | Tags to organize and filter monitors. Each tag has a |
Sample request
mutation { syntheticsUpdateBrokenLinksMonitor( guid: ENTITY_GUID monitor: { locations: { public: ["LOCATION_1", "LOCATION_2"] } name: "YOUR_MONITOR_NAME" period: PERIOD status: STATUS apdexTarget: APDEX_TARGET uri: "MONITOR_URI" tags: { key: "YOUR_TAG_NAME", values: "TAG_VALUE" } } ) { errors { description type } }}Sample response
A successful response returns null for errors:
{ "data": { "syntheticsUpdateBrokenLinksMonitor": { "errors": null } }}If there are any issues updating the monitor, the errors array will contain objects with description and type fields explaining what went wrong.
Delete a broken links monitor
When a broken links monitor is no longer needed, you can permanently remove it using the syntheticsDeleteMonitor mutation.
To delete a monitor, refer to the Delete Synthetic monitor section.