mirror of
https://github.com/RWejlgaard/octopus_exporter.git
synced 2026-05-06 04:14:44 +00:00
initial
This commit is contained in:
commit
81fdf27759
5 changed files with 113 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
.env
|
||||
octopus_exporter
|
||||
11
Dockerfile
Normal file
11
Dockerfile
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
FROM golang:1.22-alpine AS builder
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY cmd/ cmd/
|
||||
RUN CGO_ENABLED=0 go build -o /octopus_exporter ./cmd/octopus_exporter
|
||||
|
||||
FROM scratch
|
||||
COPY --from=builder /octopus_exporter /octopus_exporter
|
||||
EXPOSE 9359
|
||||
ENTRYPOINT ["/octopus_exporter"]
|
||||
65
README.md
Normal file
65
README.md
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# octopus_exporter
|
||||
|
||||
A Prometheus exporter for live electricity consumption data from [Octopus Energy](https://octopus.energy), using the Kraken GraphQL API.
|
||||
|
||||
## Metrics
|
||||
|
||||
| Metric | Description |
|
||||
|---|---|
|
||||
| `octopus_live_consumption` | Live electricity demand in watts |
|
||||
| `octopus_live_consumption_last_read` | Timestamp of the last meter reading (Unix epoch) |
|
||||
|
||||
Metrics are updated every 60 seconds.
|
||||
|
||||
## Configuration
|
||||
|
||||
| Variable | Required | Description |
|
||||
|---|---|---|
|
||||
| `OCTOPUS_API_KEY` | Yes | Your Octopus Energy API key |
|
||||
| `OCTOPUS_MPAN` | No | Filter by MPAN (recommended if you have multiple meters) |
|
||||
| `OCTOPUS_SERIAL` | No | Filter by meter serial number |
|
||||
| `OCTOPUS_DEVICE_ID` | No | Use a specific smart device ID directly |
|
||||
| `PORT` | No | Port to expose metrics on (default: `9359`) |
|
||||
|
||||
If none of `OCTOPUS_MPAN`, `OCTOPUS_SERIAL`, or `OCTOPUS_DEVICE_ID` are set, the exporter will automatically select the first smart meter found on your account. For accounts with multiple meters, use `OCTOPUS_MPAN` or `OCTOPUS_SERIAL` to pin to a specific one.
|
||||
|
||||
Your API key can be found in the [Octopus Energy developer dashboard](https://octopus.energy/dashboard/new/accounts/personal-details/api-access).
|
||||
|
||||
## Docker
|
||||
|
||||
```sh
|
||||
docker run -d \
|
||||
-e OCTOPUS_API_KEY=sk_live_... \
|
||||
-e OCTOPUS_MPAN=1234567890123 \
|
||||
-p 9359:9359 \
|
||||
rwejlgaard/octopus_exporter
|
||||
```
|
||||
|
||||
## Running from source
|
||||
|
||||
Requires Go 1.22+.
|
||||
|
||||
```sh
|
||||
git clone https://github.com/rwejlgaard/octopus_exporter
|
||||
cd octopus_exporter
|
||||
OCTOPUS_API_KEY=sk_live_... go run ./cmd/octopus_exporter
|
||||
```
|
||||
|
||||
## Prometheus configuration
|
||||
|
||||
```yaml
|
||||
scrape_configs:
|
||||
- job_name: octopus
|
||||
static_configs:
|
||||
- targets: ['localhost:9359']
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
```sh
|
||||
go build ./cmd/octopus_exporter
|
||||
```
|
||||
|
||||
```sh
|
||||
docker build -t rwejlgaard/octopus_exporter .
|
||||
```
|
||||
15
go.mod
Normal file
15
go.mod
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
module github.com/pez/octopus_exporter
|
||||
|
||||
go 1.22
|
||||
|
||||
require github.com/prometheus/client_golang v1.19.1
|
||||
|
||||
require (
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/prometheus/client_model v0.5.0 // indirect
|
||||
github.com/prometheus/common v0.48.0 // indirect
|
||||
github.com/prometheus/procfs v0.12.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
)
|
||||
20
go.sum
Normal file
20
go.sum
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
|
||||
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
|
||||
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
|
||||
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
|
||||
github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE=
|
||||
github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc=
|
||||
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
|
||||
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
|
||||
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
Loading…
Add table
Reference in a new issue