vattenfall-to-influxdb

command module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 12 Imported by: 0

README

Vattenfall to InfluxDB exporter

This is a simple exporter that scrapes the Vattenfall API and exports the prices to InfluxDB. It fetches the prices for the previous 24h and next 24h.

Usage with Docker compose

Docker-compose snippet:

version: '3.8'
services:
  influxdb:
    image: influxdb:2.5
    environment:
      DOCKER_INFLUXDB_INIT_MODE: setup
      DOCKER_INFLUXDB_INIT_USERNAME: admin
      DOCKER_INFLUXDB_INIT_PASSWORD: some_password
      DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: some_password
      DOCKER_INFLUXDB_INIT_ORG: iot
      DOCKER_INFLUXDB_INIT_BUCKET: elprice
    ports:
      - '127.0.0.1:8086:8086'

  grafana:
    image: grafana/grafana:9.2.4
    depends_on:
      - influxdb
    links:
      - influxdb
    ports:
      - '127.0.0.1:3000:3000'

  vattenfall:
    image: rvoitenko/vattenfall-to-influxdb:0.0.1
    environment:
      INFLUXDB_URL: 'http://influxdb:8086'
      INFLUXDB_TOKEN: 'some_password'
      INFLUXDB_BUCKET: 'elprice'
      INFLUXDB_ORG: 'iot'
      PRICE_AREA: 'SE3'

Then you add InfluxDB as a datasource in Grafana(choose Flux as query language):

Add a new panel and run the following query against the InfluxDB datasource:

from(bucket: "elprice")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "current")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "last")

Here is an example of the Grafana bar chart panel(works best with time range from ´now-1h´ to ´now+24h´, so it will show the data from the current hour to 24 hours ahead):

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL