From e963e78e1f22c9fffd3ac2ddbd403b3c44253e20 Mon Sep 17 00:00:00 2001 From: Lukas Malkmus Date: Tue, 20 Dec 2022 13:12:00 +0100 Subject: [PATCH] fix: better label names --- README.md | 20 ++++++++++++++++++-- cmd/tankerkoenig_exporter/main.go | 22 +++++++++++++++++++++- internal/exporter/exporter.go | 6 +++--- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7b28c2d..edc5716 100644 --- a/README.md +++ b/README.md @@ -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. @@ -83,8 +99,8 @@ See [LICENSE](LICENSE) for more information. -[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 diff --git a/cmd/tankerkoenig_exporter/main.go b/cmd/tankerkoenig_exporter/main.go index be57257..718276b 100644 --- a/cmd/tankerkoenig_exporter/main.go +++ b/cmd/tankerkoenig_exporter/main.go @@ -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 diff --git a/internal/exporter/exporter.go b/internal/exporter/exporter.go index 5b112d1..49ed2ba 100644 --- a/internal/exporter/exporter.go +++ b/internal/exporter/exporter.go @@ -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, ), }