diff --git a/README.md b/README.md index 1fe8640..9b96c56 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ IMAP_PASSWORD="" ### Probe ```txt -http://127.0.0.1:9101/probe?mailbox=INBOX +http://127.0.0.1:9101/probe?target=INBOX ``` ### Provided metrics diff --git a/main.go b/main.go index 35cb16c..cd7c280 100644 --- a/main.go +++ b/main.go @@ -81,12 +81,18 @@ func main() { }) http.HandleFunc("/probe", func(w http.ResponseWriter, r *http.Request) { - mailbox := r.URL.Query().Get("mailbox") - if mailbox == "" { - http.Error(w, "Mailbox parameter is missing", http.StatusBadRequest) - return + // Maily use the target parameter, but support mailbox as a fallback. + target := r.URL.Query().Get("target") + if target == "" { + target = r.URL.Query().Get("mailbox") + if target == "" { + http.Error(w, "Mailbox parameter is missing", http.StatusBadRequest) + return + } } + mailbox := target + probeCountGauge := prometheus.NewGauge(prometheus.GaugeOpts{ Name: "probe_mailbox_count", Help: "Displays the count of mails found in the mailbox",