---
title: Use $har for custom timing details
source: https://docs.newrelic.com/docs/synthetics/synthetic-monitoring/scripting-monitors/custom-timing-details
---

> #### ⚠️ IMPORTANT
>
> To use custom timing details with your scripted API monitors, you need [the Node.js 16.10 runtime or newer](https://docs.newrelic.com/docs/synthetics/synthetic-monitoring/getting-started/new-runtime).

You can use the $har library to create monitors with custom timing capabilities that report on interactions between the monitors and application being monitored. These custom timing use both the [default node.js module](https://docs.newrelic.com/docs/synthetics/synthetic-monitoring/scripting-monitors/import-nodejs-modules/#supported-core-modules) and [importable node.js modules](https://docs.newrelic.com/docs/synthetics/synthetic-monitoring/using-monitors/manage-monitor-runtimes/#v0).

Creating monitors with custom timing capabilities also lets you:

-   Time a request's completion. For example, using the `dns` module to test DNS look-ups.
-   View custom timers with default timing details in the New Relic UI as part of the waterfall view.
-   Use `SyntheticRequest` events to keep track of trending and alerting patterns.

## Set up your custom timers

Create your timing resources using `addResource()` or `getResource()`. You start these timers by using `startTimer()`. Likewise, you stop these timers by using `stopTimer()`.

To create a timing resource:

```js
const testTimer = $har.addResource("Test Timer");
testTimer.startTimer();
await sleep(100);
testTimer.endTimer();
```

Alternatively, create a timer using `getResource()`:

```js
$har.getResource("Test Timer").startTimer();
await sleep(100);
$har.getResource("Test Timer").endTimer();
```

## Retrieve specific timing details

Depending on your specific scripting needs, you can pull more granular timing details into the UI through a variety of attributes. These include:

-   `blocked`
-   `dns`
-   `connect`
-   `ssl`
-   `send`
-   `wait`
-   `receive`

For example, to add timers to a simple DNS monitor:

```js
const { Resolver } = require("dns").promises;
const myResolver = new Resolver();

myResolver.setServers(["1.1.1.1"]);

const dnsResource = $har.addResource("DNS Lookup");
dnsResource.startTimer();
dnsResource.dns().startTimer();

let addresses = await myResolver.resolve4("newrelic.com");
dnsResource.dns().endTimer();
dnsResource.endTimer();
console.log(addresses);
```
