@@ -20,6 +20,7 @@ import (
20
20
"net/http"
21
21
"net/url"
22
22
"path"
23
+ "time"
23
24
24
25
"github.com/go-kit/log"
25
26
"github.com/go-kit/log/level"
@@ -165,11 +166,12 @@ type filesystemIODeviceMetric struct {
165
166
166
167
// Nodes information struct
167
168
type Nodes struct {
168
- logger log.Logger
169
- client * http.Client
170
- url * url.URL
171
- all bool
172
- node string
169
+ logger log.Logger
170
+ client * http.Client
171
+ url * url.URL
172
+ all bool
173
+ node string
174
+ timeout time.Duration
173
175
174
176
up prometheus.Gauge
175
177
totalScrapes , jsonParseFailures prometheus.Counter
@@ -183,13 +185,14 @@ type Nodes struct {
183
185
}
184
186
185
187
// NewNodes defines Nodes Prometheus metrics
186
- func NewNodes (logger log.Logger , client * http.Client , url * url.URL , all bool , node string ) * Nodes {
188
+ func NewNodes (logger log.Logger , client * http.Client , url * url.URL , all bool , node string , timeout time. Duration ) * Nodes {
187
189
return & Nodes {
188
- logger : logger ,
189
- client : client ,
190
- url : url ,
191
- all : all ,
192
- node : node ,
190
+ logger : logger ,
191
+ client : client ,
192
+ url : url ,
193
+ all : all ,
194
+ node : node ,
195
+ timeout : timeout ,
193
196
194
197
up : prometheus .NewGauge (prometheus.GaugeOpts {
195
198
Name : prometheus .BuildFQName (namespace , "node_stats" , "up" ),
@@ -1788,13 +1791,14 @@ func (c *Nodes) fetchAndDecodeNodeStats() (nodeStatsResponse, error) {
1788
1791
var nsr nodeStatsResponse
1789
1792
1790
1793
u := * c .url
1791
-
1792
1794
if c .all {
1793
1795
u .Path = path .Join (u .Path , "/_nodes/stats" )
1794
1796
} else {
1795
1797
u .Path = path .Join (u .Path , "_nodes" , c .node , "stats" )
1796
1798
}
1797
1799
1800
+ u .RawQuery = fmt .Sprintf ("timeout=%s" , c .timeout .String ())
1801
+
1798
1802
res , err := c .client .Get (u .String ())
1799
1803
if err != nil {
1800
1804
return nsr , fmt .Errorf ("failed to get cluster health from %s://%s:%s%s: %s" ,
0 commit comments