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:3.12.0 --video --visualMetrics  --resultDir tmp -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 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.