Traceroute Map Panel
Traceroute Map Panel is a Grafana panel that visualize the traceroute hops in a map, just like Besttrace.
Traceroute Map Panel expects traceroute data in the following schema, where fields order does not matter: | Field | Type | Description | |:-:|:-:|:-:|-|-|-|-| | host | string | source host where the data is collected | | dest | string | host where the trace is destinated | | hop | number | nth hop | | ip | string | IP address of the hop | | rtt | number | round-trip time | | loss | number | packet loss | | time | number | timestamp, not used yet |
Preview via the CLi tool of InfluxDB
This query groups data by
host->dest pair so that to be clear when previewing data with the CLi client of InfluxDB.
select hop, ip, rtt, loss from (select mean(avg) as rtt, mean(loss) as loss from mtr WHERE now() - 6h < time AND time < now() group by hop, ip, host, dest) group by host, dest
Query in Grafana
This query is more straightforward and intended to be read by Grafana.
select mean(avg) as rtt, mean(loss) as loss from mtr WHERE now() - 5m < time group by hop, ip, host, dest
& Format as Table.
Or (less recommended, see Notes):
select mean(avg) as rtt, mean(loss) as loss from mtr WHERE $timeFilter group by hop, ip, host, dest
& Format as Table. .
This panel relys on external API service for Geo IP resolving.
The panel ships with two built-in Geo IP service providers: IP.sb and IPInfo.io. The former is activated by default and free all the time while inaccurate sometimes as it is backed by MaxMind's GeoLite2 database. The latter is a little more accurate in general while rate-limited without API token.
An alternative way is custom API or custom function as long as the target API has proper CORS header set. A sample Cloudflare Worker script that proxies requests to some third-party service is located in ipip-cfworker.js.
- Install & Configure Telegraf and InfluxDB properly.
- See Telegraf's wiki to configure MTR data collection as an input.
- Explore database via the
influxCLi tool, so that to make sure data is collected as expected. See the query section.
- Install the Traceroute Map Panel plugin to Grafana.
- Create a new panel in Grafana:
- Choose visualization "Traceroute Map Panel"
- In query editor, toggle the text edit mode by clicking the pen icon and enter the query. See the query section.
- At the bottom of the edtior, choose FORMAT AS Table instead of Time Series.
- Setup Geo IP service provider, optionally.
The panel is not really time-series aware in the sense that it expects only static route path for one src-dest pair.
If there is dynamic routing (e.g. multiple route paths for one src-dest pair), the paths displayed on the map may get disrupted in unexpected ways. So it is generally a good idea to hardcode the
$timeFilter to be a small range, such as
now() - 5m < time (recent 5 mins) to circumvent the case.
Keeping loading for long
In the current implementation, the Geo IP resolving is sequential, instead of concurrent. So it is predicatable that the map keeps loading for a long while at the first time. The resolving result is then cached in sessionStorage.
Error processing data
If it errors with "Error processing data", the problem could be failures in Geo IP resolving or invalid query data (response data is empty or the data is not Formatted as Table). The detailed error is logged in the debugging console.