|
| 1 | +--- |
| 2 | +title: 'TracerouteMonitor Construct' |
| 3 | +description: 'Learn how to configure Traceroute monitors with the Checkly CLI.' |
| 4 | +sidebarTitle: 'Traceroute Monitor' |
| 5 | +canonical: 'https://www.checklyhq.com/docs/constructs/traceroute-monitor/' |
| 6 | +--- |
| 7 | + |
| 8 | +import GeneralMonitorOptionsTable from '/snippets/general-monitor-options-table.mdx'; |
| 9 | + |
| 10 | +<Tip> |
| 11 | +Learn more about Traceroute Monitors in [the Traceroute monitor overview](/detect/uptime-monitoring/traceroute-monitors/overview). |
| 12 | +</Tip> |
| 13 | + |
| 14 | +Traceroute monitors map the network path to a host hop-by-hop, measuring per-hop latency and packet loss, and detecting whether the destination is reached. Use them to monitor path stability and catch routing issues before they affect your users. |
| 15 | + |
| 16 | +<Accordion title="Prerequisites"> |
| 17 | +Before creating Traceroute Monitors, ensure you have: |
| 18 | + |
| 19 | +- An initialized Checkly CLI project |
| 20 | +- A hostname or IP address you want to trace |
| 21 | +- Basic understanding of network tracing (traceroute / tracert) |
| 22 | + |
| 23 | +For additional setup information, see [CLI overview](/cli/overview). |
| 24 | +</Accordion> |
| 25 | + |
| 26 | +<CodeGroup> |
| 27 | + |
| 28 | +```ts Basic Example |
| 29 | +import { Frequency, TracerouteMonitor } from "checkly/constructs" |
| 30 | + |
| 31 | +new TracerouteMonitor('traceroute-api', { |
| 32 | + name: 'API Gateway Network Path', |
| 33 | + description: "Maps the network path to `api.example.com` to detect routing changes.", |
| 34 | + frequency: Frequency.EVERY_5M, |
| 35 | + request: { |
| 36 | + url: 'api.example.com', |
| 37 | + }, |
| 38 | +}) |
| 39 | +``` |
| 40 | + |
| 41 | +```ts Advanced Example |
| 42 | +import { Frequency, TracerouteAssertionBuilder, TracerouteMonitor } from "checkly/constructs" |
| 43 | + |
| 44 | +new TracerouteMonitor('traceroute-db', { |
| 45 | + name: 'Database Routing Monitor', |
| 46 | + description: "Traces path to `db.example.com` with strict latency and hop assertions.", |
| 47 | + activated: true, |
| 48 | + frequency: Frequency.EVERY_10M, |
| 49 | + locations: ['us-east-1', 'eu-central-1'], |
| 50 | + degradedResponseTime: 10000, |
| 51 | + maxResponseTime: 20000, |
| 52 | + request: { |
| 53 | + url: 'db.example.com', |
| 54 | + protocol: 'TCP', |
| 55 | + port: 5432, |
| 56 | + ipFamily: 'IPv4', |
| 57 | + maxHops: 20, |
| 58 | + maxUnknownHops: 10, |
| 59 | + ptrLookup: true, |
| 60 | + timeout: 15, |
| 61 | + assertions: [ |
| 62 | + TracerouteAssertionBuilder.hopCount().lessThan(15), |
| 63 | + TracerouteAssertionBuilder.responseTime('avg').lessThan(50), |
| 64 | + TracerouteAssertionBuilder.packetLoss().lessThan(5), |
| 65 | + ], |
| 66 | + }, |
| 67 | +}) |
| 68 | +``` |
| 69 | + |
| 70 | +</CodeGroup> |
| 71 | + |
| 72 | +## Configuration |
| 73 | + |
| 74 | +Traceroute monitors have their own probe-specific settings, plus the standard monitor options shared across all check types. |
| 75 | + |
| 76 | +<Tabs> |
| 77 | +<Tab title="Traceroute Monitor Settings"> |
| 78 | + |
| 79 | +| Parameter | Type | Required | Default | Description | |
| 80 | +|-----------|------|----------|---------|-------------| |
| 81 | +| `request` | `object` | ✅ | - | Traceroute request configuration object | |
| 82 | +| `degradedResponseTime` | `number` | ❌ | `10000` | Final-hop avg RTT in milliseconds at which the monitor is marked as degraded | |
| 83 | +| `maxResponseTime` | `number` | ❌ | `20000` | Final-hop avg RTT in milliseconds at which the monitor is marked as failed | |
| 84 | + |
| 85 | +</Tab> |
| 86 | +<Tab title="General Monitor Settings"> |
| 87 | + |
| 88 | + <GeneralMonitorOptionsTable /> |
| 89 | + |
| 90 | +</Tab> |
| 91 | +</Tabs> |
| 92 | + |
| 93 | +### `TracerouteMonitor` Options |
| 94 | + |
| 95 | +<ResponseField name="request" type="object" required> |
| 96 | + |
| 97 | +Traceroute request configuration, including probe protocol, target host, and response validation. |
| 98 | + |
| 99 | +**Usage:** |
| 100 | + |
| 101 | +```ts |
| 102 | +new TracerouteMonitor('traceroute-monitor', { |
| 103 | + name: 'Network Path Monitor', |
| 104 | + request: { |
| 105 | + url: 'api.example.com', |
| 106 | + protocol: 'TCP', |
| 107 | + port: 443, |
| 108 | + assertions: [ |
| 109 | + TracerouteAssertionBuilder.hopCount().lessThan(20), |
| 110 | + ], |
| 111 | + }, |
| 112 | +}) |
| 113 | +``` |
| 114 | + |
| 115 | +**Parameters:** |
| 116 | + |
| 117 | +| Parameter | Type | Required | Default | Description | |
| 118 | +|-----------|------|----------|---------|-------------| |
| 119 | +| `url` | `string` | ✅ | - | Target hostname or IP address. Do not include a scheme or port | |
| 120 | +| `protocol` | `string` | ❌ | `'TCP'` | Probe protocol: `'TCP'` \| `'UDP'` \| `'ICMP'` \| `'SCTP'` | |
| 121 | +| `port` | `number` | ❌ | `443` (TCP) / `33434` (UDP, SCTP) | Destination port (1–65535). Defaults to `443` for TCP and to `33434` — a high, typically closed port — for UDP/SCTP, so the destination returns ICMP Destination Unreachable to confirm arrival. Ignored (and not sent) when `protocol` is `'ICMP'` | |
| 122 | +| `ipFamily` | `string` | ❌ | `'IPv4'` | IP family: `'IPv4'` \| `'IPv6'` | |
| 123 | +| `maxHops` | `number` | ❌ | `30` | Maximum hops to probe (1–64) | |
| 124 | +| `maxUnknownHops` | `number` | ❌ | `15` | Maximum consecutive unresponsive hops before stopping (1–30) | |
| 125 | +| `ptrLookup` | `boolean` | ❌ | `true` | Perform reverse-DNS (PTR) lookups on hop IPs | |
| 126 | +| `timeout` | `number` | ❌ | `10` | Seconds to wait for the trace to complete (1–30) | |
| 127 | +| `assertions` | `TracerouteAssertion[]` | ❌ | `[]` | Response assertions using `TracerouteAssertionBuilder` | |
| 128 | + |
| 129 | +</ResponseField> |
| 130 | + |
| 131 | +<ResponseField name="degradedResponseTime" type="number" default="10000"> |
| 132 | +Final-hop average RTT in milliseconds at which the monitor is marked as degraded (warning state). Maximum: 30,000. |
| 133 | + |
| 134 | +**Usage:** |
| 135 | + |
| 136 | +```ts highlight={3} |
| 137 | +new TracerouteMonitor("traceroute-latency-tiers", { |
| 138 | + name: "API Network Path", |
| 139 | + degradedResponseTime: 5000, // Warn when final-hop avg RTT exceeds 5 seconds |
| 140 | + request: { |
| 141 | + url: 'api.example.com', |
| 142 | + }, |
| 143 | +}) |
| 144 | +``` |
| 145 | +</ResponseField> |
| 146 | + |
| 147 | +<ResponseField name="maxResponseTime" type="number" default="20000"> |
| 148 | +Final-hop average RTT in milliseconds at which the monitor is marked as failed. Maximum: 30,000. |
| 149 | + |
| 150 | +**Usage:** |
| 151 | + |
| 152 | +```ts highlight={3} |
| 153 | +new TracerouteMonitor("traceroute-latency-tiers", { |
| 154 | + name: "API Network Path", |
| 155 | + maxResponseTime: 15000, // Fail when final-hop avg RTT exceeds 15 seconds |
| 156 | + request: { |
| 157 | + url: 'api.example.com', |
| 158 | + }, |
| 159 | +}) |
| 160 | +``` |
| 161 | +</ResponseField> |
| 162 | + |
| 163 | +### `TracerouteMonitor` Assertions |
| 164 | + |
| 165 | +Assertions for Traceroute monitors are defined using the `TracerouteAssertionBuilder`. The following sources are available: |
| 166 | + |
| 167 | +- `responseTime(property?)`: Validate RTT at the final responding hop. Pass `'avg'`, `'min'`, `'max'`, or `'stdDev'` as the argument to target a specific statistic; when omitted, it defaults to `'avg'`. This assertion fails when `destinationReached` is `false` |
| 168 | +- `hopCount()`: Assert against the total number of hops recorded in the trace |
| 169 | +- `packetLoss()`: Assert against the packet loss percentage at the last recorded hop (0–100) |
| 170 | + |
| 171 | +Here are some examples: |
| 172 | + |
| 173 | +- Assert that the average final-hop latency is below a threshold (default property is `avg`): |
| 174 | + |
| 175 | +```ts |
| 176 | +TracerouteAssertionBuilder.responseTime().lessThan(100) |
| 177 | +// Equivalent to: |
| 178 | +{ source: 'RESPONSE_TIME', property: 'avg', comparison: 'LESS_THAN', target: '100' } |
| 179 | +``` |
| 180 | + |
| 181 | +- Assert against a specific RTT property: |
| 182 | + |
| 183 | +```ts |
| 184 | +TracerouteAssertionBuilder.responseTime('max').lessThan(200) |
| 185 | +// Equivalent to: |
| 186 | +{ source: 'RESPONSE_TIME', property: 'max', comparison: 'LESS_THAN', target: '200' } |
| 187 | +``` |
| 188 | + |
| 189 | +- Assert on the number of hops: |
| 190 | + |
| 191 | +```ts |
| 192 | +TracerouteAssertionBuilder.hopCount().lessThan(15) |
| 193 | +// Equivalent to: |
| 194 | +{ source: 'HOP_COUNT', comparison: 'LESS_THAN', target: '15' } |
| 195 | +``` |
| 196 | + |
| 197 | +- Assert on packet loss at the last hop: |
| 198 | + |
| 199 | +```ts |
| 200 | +TracerouteAssertionBuilder.packetLoss().lessThan(10) |
| 201 | +// Equivalent to: |
| 202 | +{ source: 'PACKET_LOSS', comparison: 'LESS_THAN', target: '10' } |
| 203 | +``` |
| 204 | + |
| 205 | +Learn more in our docs on [Assertions](/detect/assertions). |
| 206 | + |
| 207 | +### General Monitor Options |
| 208 | + |
| 209 | +<ResponseField name="name" type="string" required> |
| 210 | +Friendly name for your Traceroute Monitor that will be displayed in the Checkly dashboard and used in notifications. |
| 211 | + |
| 212 | +**Usage:** |
| 213 | + |
| 214 | +```ts highlight={2} |
| 215 | +new TracerouteMonitor("my-traceroute", { |
| 216 | + name: "API Gateway Network Path", |
| 217 | + /* More options ... */ |
| 218 | +}) |
| 219 | +``` |
| 220 | +</ResponseField> |
| 221 | + |
| 222 | +<ResponseField name="frequency" type="Frequency"> |
| 223 | +How often the Traceroute Monitor should run. Use the `Frequency` enum to set the check interval. |
| 224 | + |
| 225 | +**Usage:** |
| 226 | + |
| 227 | +```ts highlight={3} |
| 228 | +new TracerouteMonitor("my-traceroute", { |
| 229 | + name: "API Gateway Network Path", |
| 230 | + frequency: Frequency.EVERY_5M, |
| 231 | + /* More options ... */ |
| 232 | +}) |
| 233 | +``` |
| 234 | + |
| 235 | +**Available frequencies**: `EVERY_30S`, `EVERY_1M`, `EVERY_2M`, `EVERY_5M`, `EVERY_10M`, `EVERY_15M`, `EVERY_30M`, `EVERY_1H`, `EVERY_2H`, `EVERY_3H`, `EVERY_6H`, `EVERY_12H`, `EVERY_24H`. Traceroute monitors do not support sub-30-second frequencies (`EVERY_10S` / `EVERY_20S`). |
| 236 | +</ResponseField> |
| 237 | + |
| 238 | +<ResponseField name="locations" type="string[]" default="[]"> |
| 239 | +Array of [public location codes](/concepts/locations/#public-locations) where the Traceroute Monitor should run from. Use `privateLocations` for [private locations](/platform/private-locations/overview). Multiple locations help detect regional routing differences. |
| 240 | + |
| 241 | +**Usage:** |
| 242 | + |
| 243 | +```ts highlight={3} |
| 244 | +new TracerouteMonitor("global-path-monitor", { |
| 245 | + name: "API Path from Multiple Regions", |
| 246 | + locations: ["us-east-1", "eu-central-1", "ap-southeast-1"], |
| 247 | + request: { |
| 248 | + url: 'api.example.com', |
| 249 | + }, |
| 250 | +}) |
| 251 | +``` |
| 252 | +</ResponseField> |
| 253 | + |
| 254 | +<ResponseField name="activated" type="boolean" default="true"> |
| 255 | +Whether the Traceroute Monitor is enabled and will run according to its schedule. |
| 256 | + |
| 257 | +**Usage:** |
| 258 | + |
| 259 | +```ts highlight={3} |
| 260 | +new TracerouteMonitor("my-traceroute", { |
| 261 | + name: "API Gateway Network Path", |
| 262 | + activated: false, // Disabled monitor |
| 263 | + request: { |
| 264 | + url: 'api.example.com', |
| 265 | + }, |
| 266 | +}) |
| 267 | +``` |
| 268 | +</ResponseField> |
0 commit comments