Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add elasticsearch_jvm_uptime gauge #537

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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