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