Send metrics to Graphite

The easiest way to send metrics is to install jq and use it to pick the values you wanna track. JQ helps you pick data from a JSON file.

First you just run Browsertime. Here make sure we create the browsertime.json in a directory called tmp.

docker run --shm-size=1g --rm -v "$(pwd)":/browsertime-results sitespeedio/browsertime:23.4.1 --video --visualMetrics  --resultDir tmp https://www.sitespeed.io/ -n 5

Then we pickup the median SpeedIndex from Browsertime and send it to your Graphite instance.

echo "browsertime.your.key.SpeedIndex.median" $(cat tmp/browsertime.json | jq .statistics.visualMetrics.SpeedIndex.median) "`date +%s`" | nc -q0 my.graphite.com 2003

browsertime.your.key.SpeedIndex.median is the start of the key that we send to Graphite and jq .statistics.visualMetrics.SpeedIndex.median make sure we pick the median value of the 5 runs we did. And nc (netcat) sends the data to your Graphite server.