Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: better label names #9

Merged
merged 1 commit into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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