Skip to content

Commit

Permalink
fix: better label names
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmalkmus committed Dec 20, 2022
1 parent 03738e7 commit e963e78
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ Docker images are available on the [GitHub Package Registry].
docker run -p9386:9386/tcp --env-file=.env ghcr.io/lukasmalkmus/tankerkoenig-exporter:0.10.0 --tankerkoenig.stations="51d4b55e-a095-1aa0-e100-80009459e03a"
```

## Querying

The exporter exposes the following Tankerkoenig API related metrics (there are
a handful of exporter related metrics as well, like `up`, etc.):

- `tk_station_price_euro{id, product}`: The fuel price in euro per liter.
- `tk_station_open{id}`: Whether the station is open (`1`) or not (`0`).
- `tk_station_details{id, name, address, city, geohash, brand}`: Details of the station.

If you want to add station details when querying the price metric, you can join
the two metrics like this:

```promql
tk_station_price_euro * on (id) group_left(brand, address) tk_station_details
```

## Contributing

Feel free to submit PRs or to fill Issues. Every kind of help is appreciated.
Expand All @@ -83,8 +99,8 @@ See [LICENSE](LICENSE) for more information.

<!-- Links -->

[tankerkoenig api]: https://creativecommons.tankerkoenig.de/#usage
[tankerkoenig site]: https://creativecommons.tankerkoenig.de/#usage
[tankerkoenig api]: https://creativecommons.tankerkoenig.de/home
[tankerkoenig site]: https://creativecommons.tankerkoenig.de/api-key
[tankstellen finder]: https://creativecommons.tankerkoenig.de/TankstellenFinder/index.html
[github package registry]: https://github.com/lukasmalkmus/tankerkoenig_exporter/pkgs/container/tankerkoenig_exporter

Expand Down
22 changes: 21 additions & 1 deletion cmd/tankerkoenig_exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,27 @@ Example:
$ tankerkoenig_exporter --tankerkoenig.stations 51d4b55e-a095-1aa0-e100-80009459e03a
$ tankerkoenig_exporter --tankerkoenig.location u0yjjd6jk0zj7 --tankerkoenig.radius=3 --tankerkoenig.product=e5
The --tankerkoenig.stations flag is mutually exclusive with the --tankerkoenig.location flag.
The --tankerkoenig.stations flag is mutually exclusive with the
--tankerkoenig.location, --tankerkoenig.radius and --tankerkoenig.product flags.
KEY can be obtained from https://creativecommons.tankerkoenig.de/api-key.
UUID is the unique identifier of a station. It can be obtained from the
Tankerkoenig API or by using the Tankstellen Finder:
https://creativecommons.tankerkoenig.de/TankstellenFinder/index.html.
GEOHASH is the geohash of a location. It can easily be obtained from the
internet.
KM is the search radius in kilometers. Must be a positive integer.
PRODUCT is the fuel type. Must be one of e5, e10, diesel or all to include all
products.
ADDRESS is the listen address for the web server. It must be in the form of
[HOST]:PORT.
PATH is the path under which to expose metrics. It must start with a slash.
`

type stringSliceValue []string
Expand Down
6 changes: 3 additions & 3 deletions internal/exporter/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,19 @@ func newExporter(logger *log.Logger, apiClient *client.Client) *Exporter {
priceDesc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "station", "price_euro"),
"Gas prices in EURO (€).",
[]string{"station_id", "product"},
[]string{"id", "product"},
nil,
),
openDesc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "station", "open"),
"Status of the station. 1 for OPEN, 0 for CLOSED.",
[]string{"station_id"},
[]string{"id"},
nil,
),
detailsDesc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "station", "details"),
"Associated details of a station. Always 1.",
[]string{"station_id", "station_name", "address", "city", "geohash", "station_brand"},
[]string{"id", "name", "address", "city", "geohash", "brand"},
nil,
),
}
Expand Down

0 comments on commit e963e78

Please sign in to comment.