From 1d55196bdf328b6efe67349acb7d107b505c2988 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sun, 20 Nov 2022 00:53:34 +0100 Subject: [PATCH] Add health-check endpoint Signed-off-by: Knut Ahlers --- README.md | 1 + main.go | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 27f3fe8..707b480 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ In all cases specify one or more `--vehicle-id` (`VEHICLE_ID=WDB111111ZZZ22222,W When everything is running you should be able to access the exporter: - `https://exporter.example.com/auth` - Redirect to authorize your project to access your car(s) +- `https://exporter.example.com/healthz` - Health-Check endpoint - `https://exporter.example.com/metrics` - Text-version of exported metrics You need to access the `/auth` route once to fetch access- and refresh-keys. If something wents wrong with those keys you can re-authorize the app using this route. diff --git a/main.go b/main.go index 9b6d5b3..14928fc 100644 --- a/main.go +++ b/main.go @@ -76,6 +76,7 @@ func main() { // Register HTTP handlers http.DefaultServeMux.HandleFunc("/auth", getAuthRedirectHandler(mClient)) http.DefaultServeMux.HandleFunc("/store-token", getAuthStoreTokenHandler(mClient, creds)) + http.DefaultServeMux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("OK")) }) http.DefaultServeMux.Handle("/metrics", promhttp.Handler()) scheduler := cron.New()