ainsey11 / octopusenergy-consumption-metrics

A utility written in nodejs to pull energy consumption from the Octopus Energy API for tracking usage in grafana.
23 stars 13 forks source link

How do I run this with Docker-compose #1

Closed techcubs closed 2 years ago

techcubs commented 2 years ago

Hi, thanks for publishing this exporter. I am having a hard time figuring out how to run this with docker-compose.

a-lagopus commented 2 years ago

Hi! There is a docker-compose.yml example file posted on the author's blog post here:

version: "3.7"

services:  
  octopus-energy-monitor:
    image: octopusenergy-consumption-metrics:latest
    environment:
      - OCTO_API_KEY="XXXXXXXXX"
      - OCTO_ELECTRIC_MPAN="XXXXXXXXX"
      - OCTO_ELECTRIC_SN="XXXXXXXXX"
      - OCTO_GAS_MPRN="XXXXXXXXX"
      - OCTO_GAS_SN="XXXXXXXXX"
      - OCTO_GAS_COST=3.27
      - OCTO_ELECTRIC_COST=18.78
      - INFLUXDB_URL="https://XXXXXXXXX.XXXXXXXXX.XXXXXXXXX"
      - INFLUXDB_TOKEN="XXXXXXXXX"
      - INFLUXDB_ORG="XXXXXXXXX"
      - INFLUXDB_BUCKET="octopus"
      - LOOP_TIME=600
      - PAGE_SIZE=100
      - 
ainsey11 commented 2 years ago

Somehow I missed this issue, thanks for the reply @a-lagopus - that would be the correct way to run the exporter

techcubs commented 2 years ago

I have done this but i still dont get anything in the octopus bucket. This is my config.

  octopus_energy_monitor:
    image: threesquared/octopusenergy-consumption-metrics
    container_name: octopus_energy_monitor
    logging:
      driver: json-file 
      options:
        tag: "{{.Name}}"
    environment:
      - OCTO_API_KEY=${OCTO_API_KEY}
      - OCTO_ELECTRIC_MPAN=${OCTO_ELECTRIC_MPAN}
      - OCTO_ELECTRIC_SN=${OCTO_ELECTRIC_SN}
      - OCTO_GAS_MPRN=${OCTO_GAS_MPRN}
      - OCTO_GAS_SN=${OCTO_GAS_SN}
      - OCTO_GAS_COST=3.31
      - OCTO_ELECTRIC_COST=18.98
      - INFLUXDB_URL=${INFLUXDB_URL}
      - INFLUXDB_TOKEN=${INFLUXDB_OCTOPUS_TOKEN}
      - INFLUXDB_ORG=${DOCKER_INFLUXDB_INIT_ORG}
      - INFLUXDB_BUCKET=octopus
      - LOOP_TIME=600
      - PAGE_SIZE=100

in the log file I keep getting:

Polling data from octopus API
WARN: Write to InfluxDB failed (attempt: 1). d [HttpError]: 502 Bad Gateway : Bad Gateway
    at IncomingMessage.<anonymous> (/usr/src/app/node_modules/@influxdata/influxdb-client/dist/index.js:16:10464)
    at IncomingMessage.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1334:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  statusCode: 502,
  statusMessage: 'Bad Gateway',
  body: 'Bad Gateway',
  contentType: 'text/plain; charset=utf-8',
  _retryAfter: 0
}
ERROR: Retry buffer closed with 400 items that were not written to InfluxDB!
d [HttpError]: 502 Bad Gateway : Bad Gateway
    at IncomingMessage.<anonymous> (/usr/src/app/node_modules/@influxdata/influxdb-client/dist/index.js:16:10464)
    at IncomingMessage.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1334:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  statusCode: 502,
  statusMessage: 'Bad Gateway',
  body: 'Bad Gateway',
  contentType: 'text/plain; charset=utf-8',
  _retryAfter: 0
}
Error submitting data to InfluxDB
Sleeping for: 600