doug dobies
about | projects | linkedin | github | twitter |
Weather Graphing with DarkSky, Grafana, and InfluxDB

I'm one of those people that like data points, I like graphing weather especially. Recently I started using Grafana to create fancy graphs for various things, and weather is one of those things. There are a bunch of ways to do this, but I'm using the DarkSky API to pull weather data, then doing some simple manipulation via a shell script to parse relevant weather values, and finally I'm using curl to push those values to an InfluxDB instance.

After all of that happens, eventually I get graphs that look like this.

Below is the shell script I created to handle the heavy lifting.

# Your API key

# Your geographic location

# file to save weather data to

# remove any old files


# Get Temperature
TEMP=`cat $OFILE |grep currently |cut -d: -f14 |cut -d. -f1`

FEELSLIKE=`cat $OFILE |grep currently |cut -d: -f15 |cut -d. -f1`

# This needs extra steps, returns a percentage via . ie: 0.71 for 71%
# so we have to grab the 71 and nothing else, ie the ccond cut.
HUMIDITY=`cat $OFILE |grep currently |cut -d: -f17 |cut -d. -f2 |cut -d, -f1`

#Push all this into a local InfluxDB in a db called MyWeather

curl -XPOST '' --data-binary 'Temperature value='"$TEMP"''

curl -XPOST '' --data-binary 'FeelsLike value='"$FEELSLIKE"''

curl -XPOST '' --data-binary 'Humidity value='"$HUMIDITY"''

# fi

<this is a work in progress>