Skip to content

Commit

Permalink
Add elasticsearch_jvm_uptime gauge (#537)
Browse files Browse the repository at this point in the history
Signed-off-by: Per Lundberg <per.lundberg@hibox.tv>
  • Loading branch information
perlun authored Apr 13, 2022
1 parent 24c8f9c commit e5fb0a3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions collector/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,20 @@ func NewNodes(logger log.Logger, client *http.Client, url *url.URL, all bool, no
return append(defaultNodeLabelValues(cluster, node), "mapped")
},
},
{
Type: prometheus.GaugeValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "jvm", "uptime_seconds"),
"JVM process uptime in seconds",
append(defaultNodeLabels, "type"), nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.JVM.Uptime) / 1000
},
Labels: func(cluster string, node NodeStatsNodeResponse) []string {
return append(defaultNodeLabelValues(cluster, node), "mapped")
},
},
{
Type: prometheus.GaugeValue,
Desc: prometheus.NewDesc(
Expand Down
3 changes: 2 additions & 1 deletion collector/nodes_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package collector

import "encoding/json"

// nodeStatsResponse is a representation of a Elasticsearch Node Stats
// nodeStatsResponse is a representation of an Elasticsearch Node Stats
type nodeStatsResponse struct {
ClusterName string `json:"cluster_name"`
Nodes map[string]NodeStatsNodeResponse
Expand Down Expand Up @@ -55,6 +55,7 @@ type NodeStatsJVMResponse struct {
BufferPools map[string]NodeStatsJVMBufferPoolResponse `json:"buffer_pools"`
GC NodeStatsJVMGCResponse `json:"gc"`
Mem NodeStatsJVMMemResponse `json:"mem"`
Uptime int64 `json:"uptime_in_millis"`
}

// NodeStatsJVMGCResponse defines node stats JVM garbage collector information structure
Expand Down

0 comments on commit e5fb0a3

Please sign in to comment.