Skip to content

Commit ff571ce

Browse files
Update main.go
1 parent de70e43 commit ff571ce

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cmd/fa-om-exporter/main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ func main() {
111111
}
112112

113113
func metricsHandler(w http.ResponseWriter, r *http.Request) {
114+
if debug {
115+
log.Printf("%s %s %s %s\n", r.RemoteAddr, r.Method, r.URL, r.Header.Get("User-Agent"))
116+
}
114117
params := r.URL.Query()
115118
path := strings.Split(r.URL.Path, "/")
116119
metrics := ""
@@ -130,6 +133,7 @@ func metricsHandler(w http.ResponseWriter, r *http.Request) {
130133
}
131134
endpoint := params.Get("endpoint")
132135
if endpoint == "" {
136+
log.Printf("[ERROR] %s %s %s HTTP REQUEST ERROR: Endpoint parameter is missing\n", r.RemoteAddr, r.Method, r.URL)
133137
http.Error(w, "Endpoint parameter is missing", http.StatusBadRequest)
134138
return
135139
}
@@ -146,6 +150,7 @@ func metricsHandler(w http.ResponseWriter, r *http.Request) {
146150
address = endpoint
147151
}
148152
if apitoken == "" {
153+
log.Printf("[ERROR] %s %s %s HTTP REQUEST ERROR: Target authorization token is missing\n", r.RemoteAddr, r.Method, r.URL)
149154
http.Error(w, "Target authorization token is missing", http.StatusBadRequest)
150155
return
151156
}
@@ -156,7 +161,8 @@ func metricsHandler(w http.ResponseWriter, r *http.Request) {
156161
registry := prometheus.NewRegistry()
157162
faclient := client.NewRestClient(address, apitoken, apiver, uagent, rid, debug)
158163
if faclient.Error != nil {
159-
http.Error(w, "Error connecting to FlashArray. Check your management endpoint and/or api token are correct.", http.StatusBadRequest)
164+
log.Printf("[ERROR] %s %s %s %s FACLIENT ERROR: %s\n", r.RemoteAddr, r.Method, r.URL, r.Header.Get("User-Agent"), faclient.Error.Error())
165+
http.Error(w, faclient.Error.Error(), http.StatusBadRequest)
160166
return
161167
}
162168
collectors.Collector(context.TODO(), metrics, registry, faclient)

0 commit comments

Comments
 (0)