Skip to content

Commit 5327d35

Browse files
committed
Add HTTP metrics and TCP
1 parent 70152fe commit 5327d35

File tree

3 files changed

+61
-8
lines changed

3 files changed

+61
-8
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,14 @@ Further Information
223223
| elasticsearch_thread_pool_queue_count | gauge | 14 | Thread Pool operations queued
224224
| elasticsearch_thread_pool_rejected_count | counter | 14 | Thread Pool operations rejected
225225
| elasticsearch_thread_pool_threads_count | gauge | 14 | Thread Pool current threads count
226+
| elasticsearch_transport_tcp_connections_open_current | gauge | 1 | Number of connections opened for cluster communication
227+
| elasticsearch_transport_outbound_connections_total | counter | 1 | Total number of outbound transport connections
226228
| elasticsearch_transport_rx_packets_total | counter | 1 | Count of packets received
227229
| elasticsearch_transport_rx_size_bytes_total | counter | 1 | Total number of bytes received
228230
| elasticsearch_transport_tx_packets_total | counter | 1 | Count of packets sent
229231
| elasticsearch_transport_tx_size_bytes_total | counter | 1 | Total number of bytes sent
232+
| elasticsearch_http_connections_opened_current | gauge | 1 | Current number of opened connections
233+
| elasticsearch_http_connections_opened_total | counter | 1 | Total number of opened connections
230234
| elasticsearch_clusterinfo_last_retrieval_success_ts | gauge | 1 | Timestamp of the last successful cluster info retrieval
231235
| elasticsearch_clusterinfo_up | gauge | 1 | Up metric for the cluster info collector
232236
| elasticsearch_clusterinfo_version_info | gauge | 6 | Constant metric with ES version information as labels

collector/nodes.go

+49-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func getRoles(node NodeStatsNodeResponse) map[string]bool {
5656
}
5757
}
5858
}
59-
if len(node.HTTP) == 0 {
59+
if node.HTTP == nil {
6060
roles["client"] = false
6161
}
6262
return roles
@@ -1462,6 +1462,30 @@ func NewNodes(logger log.Logger, client *http.Client, url *url.URL, all bool, no
14621462
return defaultNodeLabelValues(cluster, node)
14631463
},
14641464
},
1465+
{
1466+
Type: prometheus.GaugeValue,
1467+
Desc: prometheus.NewDesc(
1468+
prometheus.BuildFQName(namespace, "transport", "tcp_connections_open_current"),
1469+
"Current number of connections open for cluster communication",
1470+
defaultNodeLabels, nil,
1471+
),
1472+
Value: func(node NodeStatsNodeResponse) float64 {
1473+
return float64(node.Transport.ServerOpen)
1474+
},
1475+
Labels: defaultNodeLabelValues,
1476+
},
1477+
{
1478+
Type: prometheus.CounterValue,
1479+
Desc: prometheus.NewDesc(
1480+
prometheus.BuildFQName(namespace, "transport", "outbound_connections_total"),
1481+
"Count of outbound transport connections",
1482+
defaultNodeLabels, nil,
1483+
),
1484+
Value: func(node NodeStatsNodeResponse) float64 {
1485+
return float64(node.Transport.OutboundConn)
1486+
},
1487+
Labels: defaultNodeLabelValues,
1488+
},
14651489
{
14661490
Type: prometheus.CounterValue,
14671491
Desc: prometheus.NewDesc(
@@ -1510,6 +1534,30 @@ func NewNodes(logger log.Logger, client *http.Client, url *url.URL, all bool, no
15101534
},
15111535
Labels: defaultNodeLabelValues,
15121536
},
1537+
{
1538+
Type: prometheus.GaugeValue,
1539+
Desc: prometheus.NewDesc(
1540+
prometheus.BuildFQName(namespace, "http", "connections_opened_current"),
1541+
"Current number of open HTTP connections",
1542+
defaultNodeLabels, nil,
1543+
),
1544+
Value: func(node NodeStatsNodeResponse) float64 {
1545+
return float64(node.HTTP.CurrentOpen)
1546+
},
1547+
Labels: defaultNodeLabelValues,
1548+
},
1549+
{
1550+
Type: prometheus.CounterValue,
1551+
Desc: prometheus.NewDesc(
1552+
prometheus.BuildFQName(namespace, "http", "connections_opened_total"),
1553+
"Total number of HTTP connections opened ",
1554+
defaultNodeLabels, nil,
1555+
),
1556+
Value: func(node NodeStatsNodeResponse) float64 {
1557+
return float64(node.HTTP.TotalOpen)
1558+
},
1559+
Labels: defaultNodeLabelValues,
1560+
},
15131561
},
15141562
gcCollectionMetrics: []*gcCollectionMetric{
15151563
{

collector/nodes_response.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type NodeStatsNodeResponse struct {
3737
ThreadPool map[string]NodeStatsThreadPoolPoolResponse `json:"thread_pool"`
3838
JVM NodeStatsJVMResponse `json:"jvm"`
3939
Breakers map[string]NodeStatsBreakersResponse `json:"breakers"`
40-
HTTP map[string]interface{} `json:"http"`
40+
HTTP *NodeStatsHTTPResponse `json:"http"`
4141
Transport NodeStatsTransportResponse `json:"transport"`
4242
Process NodeStatsProcessResponse `json:"process"`
4343
}
@@ -101,11 +101,12 @@ type NodeStatsNetworkResponse struct {
101101

102102
// NodeStatsTransportResponse is a representation of a transport statistics about sent and received bytes in cluster communication
103103
type NodeStatsTransportResponse struct {
104-
ServerOpen int64 `json:"server_open"`
105-
RxCount int64 `json:"rx_count"`
106-
RxSize int64 `json:"rx_size_in_bytes"`
107-
TxCount int64 `json:"tx_count"`
108-
TxSize int64 `json:"tx_size_in_bytes"`
104+
ServerOpen int64 `json:"server_open"`
105+
OutboundConn int64 `json:"total_outbound_connections"`
106+
RxCount int64 `json:"rx_count"`
107+
RxSize int64 `json:"rx_size_in_bytes"`
108+
TxCount int64 `json:"tx_count"`
109+
TxSize int64 `json:"tx_size_in_bytes"`
109110
}
110111

111112
// NodeStatsThreadPoolPoolResponse is a representation of a statistics about each thread pool, including current size, queue and rejected tasks
@@ -333,7 +334,7 @@ type NodeStatsProcessCPUResponse struct {
333334
// NodeStatsHTTPResponse defines node stats HTTP connections structure
334335
type NodeStatsHTTPResponse struct {
335336
CurrentOpen int64 `json:"current_open"`
336-
TotalOpen int64 `json:"total_open"`
337+
TotalOpen int64 `json:"total_opened"`
337338
}
338339

339340
// NodeStatsFSResponse is a representation of a file system information, data path, free disk space, read/write stats

0 commit comments

Comments
 (0)