|
| 1 | +--- |
| 2 | +title: "Debug Endpoints" |
| 3 | +linkTitle: "Debug Endpoints" |
| 4 | +weight: 130 |
| 5 | +type: "docs" |
| 6 | +description: "Advanced debugging endpoints available in viam-server for troubleshooting and development." |
| 7 | +date: "2025-05-19" |
| 8 | +--- |
| 9 | + |
| 10 | +The RDK (Robot Development Kit) that powers `viam-server` includes several debug endpoints that expose server internals. |
| 11 | +These endpoints can be helpful during development or when troubleshooting complex issues: |
| 12 | + |
| 13 | +- [`pprof`](#pprof) |
| 14 | +- [`graph`](#graph) |
| 15 | + |
| 16 | +## `pprof` |
| 17 | + |
| 18 | +Setting `enable_web_profile` to `true` in your machine configuration allows you to visualize runtime profiling data by opening a locally hosted webpage that displays profiling data. |
| 19 | +The pprof tool provides the following information about machine performance: |
| 20 | + |
| 21 | +- CPU usage |
| 22 | +- Memory allocation |
| 23 | +- Goroutine blocking |
| 24 | +- Execution tracing |
| 25 | + |
| 26 | +For more detailed information on using pprof, refer to the [Go pprof documentation](https://pkg.go.dev/net/http/pprof). |
| 27 | + |
| 28 | +### Configuration |
| 29 | + |
| 30 | +To enable the pprof endpoints, set `enable_web_profile` to `true` in your machine configuration: |
| 31 | + |
| 32 | +1. Navigate to the **CONFIGURE** tab of your machine in the Viam app |
| 33 | +1. Click on the **...** menu next to your machine part in the left-hand menu |
| 34 | +1. Select **Edit JSON** |
| 35 | +1. Add the `enable_web_profile` field at the root level of your configuration: |
| 36 | + |
| 37 | +```json |
| 38 | +{ |
| 39 | + "components": [...], |
| 40 | + "services": [...], |
| 41 | + "enable_web_profile": true |
| 42 | +} |
| 43 | +``` |
| 44 | + |
| 45 | +{{< alert title="Caution" color="caution" >}} |
| 46 | +The debug endpoints expose internal details about your machine's configuration and runtime behavior. |
| 47 | +Only enable these endpoints in development environments. |
| 48 | +{{< /alert >}} |
| 49 | + |
| 50 | +### Available Endpoints |
| 51 | + |
| 52 | +Once enabled, you can access the pprof interface by navigating to `https://localhost:8080/debug/pprof/` in your browser. |
| 53 | + |
| 54 | +The following pprof routes are available: |
| 55 | + |
| 56 | +- `/debug/pprof/cmdline`: Command line arguments used to start the process |
| 57 | +- `/debug/pprof/profile`: CPU profile data (30-second sample by default) |
| 58 | +- `/debug/pprof/symbol`: Symbol lookup for program counters |
| 59 | +- `/debug/pprof/trace`: Execution trace data |
| 60 | + |
| 61 | +## `graph` |
| 62 | + |
| 63 | +The `/debug/graph` endpoint shows a graphical representation of the machine resources managed by the RDK. |
| 64 | + |
| 65 | +To access this endpoint, visit `https://localhost:8080/debug/graph` on the machine. |
| 66 | + |
| 67 | +### Layout Options |
| 68 | + |
| 69 | +To view different [layouts](https://graphviz.org/docs/layouts/), use the `layout` query parameter: |
| 70 | + |
| 71 | +The following example URL specifies the `circo` layout: |
| 72 | + |
| 73 | +```txt |
| 74 | +https://localhost:8080/debug/graph?layout=circo |
| 75 | +``` |
| 76 | + |
| 77 | +Available layout options include: |
| 78 | + |
| 79 | +- `dot` (default): Hierarchical layout |
| 80 | +- `neato`: Spring model layout |
| 81 | +- `fdp`: Force-directed layout |
| 82 | +- `sfdp`: Multiscale version of fdp for large graphs |
| 83 | +- `circo`: Circular layout |
| 84 | +- `twopi`: Radial layout |
| 85 | +- `osage`: Array-based layout |
| 86 | +- `text`: raw [DOT](https://graphviz.org/doc/info/lang.html) text of the graph, for use with external tools |
| 87 | + |
| 88 | +## Next Steps |
| 89 | + |
| 90 | +{{< cards >}} |
| 91 | +{{% card link="/manage/troubleshoot/troubleshoot/" %}} |
| 92 | +{{% card link="/operate/reference/viam-server/manage-viam-server/" %}} |
| 93 | +{{% card link="/dev/tools/common-errors/" %}} |
| 94 | +{{< /cards >}} |
0 commit comments