From 39c17f655786811a10368abff382a7534083daee Mon Sep 17 00:00:00 2001 From: Aleksey Korsakov Date: Tue, 4 Nov 2025 16:14:04 +0300 Subject: [PATCH 1/2] Add uri to log when 'error getting stats' occured --- client/nginx.go | 4 ++++ collector/nginx.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/client/nginx.go b/client/nginx.go index c47dfec85..9fba4d14b 100644 --- a/client/nginx.go +++ b/client/nginx.go @@ -93,3 +93,7 @@ func parseStubStats(r io.Reader) (*StubStats, error) { } return &s, nil } + +func (client *NginxClient) GetApiEndpoint() string { + return client.apiEndpoint +} diff --git a/collector/nginx.go b/collector/nginx.go index e7cc1b1bc..a6796356c 100644 --- a/collector/nginx.go +++ b/collector/nginx.go @@ -54,7 +54,7 @@ func (c *NginxCollector) Collect(ch chan<- prometheus.Metric) { if err != nil { c.upMetric.Set(nginxDown) ch <- c.upMetric - c.logger.Error("error getting stats", "error", err.Error()) + c.logger.Error("error getting stats", "uri", c.nginxClient.GetApiEndpoint(), "error", err) return } From 5098840a374af7021b9fd28772784a1a9433323b Mon Sep 17 00:00:00 2001 From: Aleksey Korsakov Date: Mon, 10 Nov 2025 19:25:50 +0300 Subject: [PATCH 2/2] Fix naming of GetAPIEndpoint --- client/nginx.go | 2 +- collector/nginx.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/nginx.go b/client/nginx.go index 9fba4d14b..510f25a29 100644 --- a/client/nginx.go +++ b/client/nginx.go @@ -94,6 +94,6 @@ func parseStubStats(r io.Reader) (*StubStats, error) { return &s, nil } -func (client *NginxClient) GetApiEndpoint() string { +func (client *NginxClient) GetAPIEndpoint() string { return client.apiEndpoint } diff --git a/collector/nginx.go b/collector/nginx.go index a6796356c..79975e179 100644 --- a/collector/nginx.go +++ b/collector/nginx.go @@ -54,7 +54,7 @@ func (c *NginxCollector) Collect(ch chan<- prometheus.Metric) { if err != nil { c.upMetric.Set(nginxDown) ch <- c.upMetric - c.logger.Error("error getting stats", "uri", c.nginxClient.GetApiEndpoint(), "error", err) + c.logger.Error("error getting stats", "uri", c.nginxClient.GetAPIEndpoint(), "error", err) return }