Skip to content

Commit

Permalink
Add HTTP metrics and TCP
Browse files Browse the repository at this point in the history
  • Loading branch information
toufreach5 committed Oct 14, 2022
1 parent 70152fe commit 5327d35
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,14 @@ Further Information
| elasticsearch_thread_pool_queue_count | gauge | 14 | Thread Pool operations queued
| elasticsearch_thread_pool_rejected_count | counter | 14 | Thread Pool operations rejected
| elasticsearch_thread_pool_threads_count | gauge | 14 | Thread Pool current threads count
| elasticsearch_transport_tcp_connections_open_current | gauge | 1 | Number of connections opened for cluster communication
| elasticsearch_transport_outbound_connections_total | counter | 1 | Total number of outbound transport connections
| elasticsearch_transport_rx_packets_total | counter | 1 | Count of packets received
| elasticsearch_transport_rx_size_bytes_total | counter | 1 | Total number of bytes received
| elasticsearch_transport_tx_packets_total | counter | 1 | Count of packets sent
| elasticsearch_transport_tx_size_bytes_total | counter | 1 | Total number of bytes sent
| elasticsearch_http_connections_opened_current | gauge | 1 | Current number of opened connections
| elasticsearch_http_connections_opened_total | counter | 1 | Total number of opened connections
| elasticsearch_clusterinfo_last_retrieval_success_ts | gauge | 1 | Timestamp of the last successful cluster info retrieval
| elasticsearch_clusterinfo_up | gauge | 1 | Up metric for the cluster info collector
| elasticsearch_clusterinfo_version_info | gauge | 6 | Constant metric with ES version information as labels
Expand Down
50 changes: 49 additions & 1 deletion collector/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func getRoles(node NodeStatsNodeResponse) map[string]bool {
}
}
}
if len(node.HTTP) == 0 {
if node.HTTP == nil {
roles["client"] = false
}
return roles
Expand Down Expand Up @@ -1462,6 +1462,30 @@ func NewNodes(logger log.Logger, client *http.Client, url *url.URL, all bool, no
return defaultNodeLabelValues(cluster, node)
},
},
{
Type: prometheus.GaugeValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "transport", "tcp_connections_open_current"),
"Current number of connections open for cluster communication",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.Transport.ServerOpen)
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.CounterValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "transport", "outbound_connections_total"),
"Count of outbound transport connections",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.Transport.OutboundConn)
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.CounterValue,
Desc: prometheus.NewDesc(
Expand Down Expand Up @@ -1510,6 +1534,30 @@ func NewNodes(logger log.Logger, client *http.Client, url *url.URL, all bool, no
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.GaugeValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "http", "connections_opened_current"),
"Current number of open HTTP connections",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.HTTP.CurrentOpen)
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.CounterValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "http", "connections_opened_total"),
"Total number of HTTP connections opened ",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.HTTP.TotalOpen)
},
Labels: defaultNodeLabelValues,
},
},
gcCollectionMetrics: []*gcCollectionMetric{
{
Expand Down
15 changes: 8 additions & 7 deletions collector/nodes_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type NodeStatsNodeResponse struct {
ThreadPool map[string]NodeStatsThreadPoolPoolResponse `json:"thread_pool"`
JVM NodeStatsJVMResponse `json:"jvm"`
Breakers map[string]NodeStatsBreakersResponse `json:"breakers"`
HTTP map[string]interface{} `json:"http"`
HTTP *NodeStatsHTTPResponse `json:"http"`
Transport NodeStatsTransportResponse `json:"transport"`
Process NodeStatsProcessResponse `json:"process"`
}
Expand Down Expand Up @@ -101,11 +101,12 @@ type NodeStatsNetworkResponse struct {

// NodeStatsTransportResponse is a representation of a transport statistics about sent and received bytes in cluster communication
type NodeStatsTransportResponse struct {
ServerOpen int64 `json:"server_open"`
RxCount int64 `json:"rx_count"`
RxSize int64 `json:"rx_size_in_bytes"`
TxCount int64 `json:"tx_count"`
TxSize int64 `json:"tx_size_in_bytes"`
ServerOpen int64 `json:"server_open"`
OutboundConn int64 `json:"total_outbound_connections"`
RxCount int64 `json:"rx_count"`
RxSize int64 `json:"rx_size_in_bytes"`
TxCount int64 `json:"tx_count"`
TxSize int64 `json:"tx_size_in_bytes"`
}

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

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

0 comments on commit 5327d35

Please sign in to comment.