weather_exporter
weather_exporter copied to clipboard
A prometheus exporter that scrapes dark sky api for current weather for a set of cities'
weather_exporter
A docker container for running a prometheus weather_exporter using Dark Sky API. It exports current weather for a list of cities. Demo
Grafana Dashboard
Usage
Configuration
weather_exporter
can be configured via json file, environment, and/or commandline.
Configuration option names are the same across all methods. Environment variables MUST BE CAPITALIZED.
Configuration Options
-
config
: path to a json config file. -
dark_sky_api_key
: API key to query with. REQUIRED. -
dark_sky_api_uri
: URL of the darksky.net api (version as of 10/10/2017). Defaults tohttps://api.darksky.net/forecast
. -
scrape_interval
: how often to poll darksky.net for data in seconds. Defaults to600
seconds. -
endpoint_port
: what port to exposeweather_exporter
on. Defaults to9265
. -
cities
: comma-separated list of cities as understood byNominatim
. Defaults to "nyc,tokyo,lima,london,shanghai
". -
geocode_timeout
: timeout in seconds on api calls toNominatim
. Defaults to10
seconds. -
units
: unit of the weather data. See Dark Sky API Docs for a list of valid units. Defaults tous
(imperial units).
Simple Setup and Go
Export DARK_SKY_API_KEY
$ export DARK_SKY_API_KEY=<dark_ski_api_key>
Set Env Vars in .env
# ENV Variables
ENDPOINT_PORT=9265
CITIES=nyc,portland or,london
SCRAPE_INTERVAL=10000
Run container
$ make up
Prometheus Endpoint
http://localhost:9265
Prometheus config
scrape_configs:
- job_name: weather_exporter
metrics_path: /
static_configs:
- targets:
- '172.17.0.1:9265'
labels:
alias: 'weather-exporter'
To build and push container to docker hub
$ make push
Helm chart
Deploy
$ export DARK_SKY_API_KEY=<dark_ski_api_key>
$ make deploy
$ export POD_NAME=$(kubectl get pods --namespace weather-exporter -l "app=weather-exporter,release=weather-exporter" -o jsonpath="{.items[0].metadata.name}")
$ kubectl port-forward --namespace weather-exporter $POD_NAME 9265:9265
In a browser, open 127.0.0.1:9265
Delete
$ make delete