Skip to content

A simple API-client that gets current weather-data from the https://openweathermap.org/ API and stores them into a time-series-database called InfluxDB.

Notifications You must be signed in to change notification settings

Pulsar7/weather_data_harvester

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weather-Data-Harvester

Description

A simple API-client that gets current weather-data from the openweathermap.org-API and stores it in an InfluxDB time-series database.

⚠️ Warning: Using DEBUG logging level will expose sensitive data, such as your OpenWeatherMap API key, in the logs!

Usage

git clone https://github.com/Pulsar7/weather_data_harvester.git
python3 -m venv .venv && source .venv/bin/activate
cd weather_data_harvester/
pip install -r requirements.txt

Copy .sample.env & adjust it to your own values:

cp .sample.env .env
nano .env
python3 harvester.py

Example implementation

  1. Create InfluxDB & Grafana docker-container.
  2. Run harvester.py as cronjob or systemd-timed-service (recommended)

Example docker-compose.yaml-file for InfluxDB & Grafana:

services:
  influxdb:
    image: influxdb:2.7
    container_name: influxdb
    ports:
      - "8086:8086"  # For Python script access
    volumes:
      - influxdb-data:/var/lib/influxdb2
    environment:
      - DOCKER_INFLUXDB_INIT_MODE=setup
      - DOCKER_INFLUXDB_INIT_USERNAME=admin
      - DOCKER_INFLUXDB_INIT_PASSWORD=admin123
      - DOCKER_INFLUXDB_INIT_ORG=openweathermap-api-harvester
      - DOCKER_INFLUXDB_INIT_BUCKET=my-bucket
      - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=my-super-secret-token
    restart: unless-stopped
    networks:
      - monitoring

  grafana:
    image: grafana/grafana-oss:latest
    container_name: grafana
    ports:
      - "3000:3000"  # Grafana UI
    volumes:
      - grafana-storage:/var/lib/grafana
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=admin123
    restart: unless-stopped
    networks:
      - monitoring

volumes:
  influxdb-data:
  grafana-storage:

networks:
  monitoring:

About

A simple API-client that gets current weather-data from the https://openweathermap.org/ API and stores them into a time-series-database called InfluxDB.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages