Skip to content

Commit

Permalink
add ingest total metrics
Browse files Browse the repository at this point in the history
Signed-off-by: zengxilong <zengxilonglh@gmail.com>
  • Loading branch information
zengxilong committed Aug 28, 2022
1 parent f6480d1 commit 0926b4d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ elasticsearch_exporter
*-stamp
.tarballs
/vendor
.idea
48 changes: 48 additions & 0 deletions collector/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,54 @@ func NewNodes(logger log.Logger, client *http.Client, url *url.URL, all bool, no
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.CounterValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "ingest", "total_count"),
"Total number of ingest count",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.Ingest.Total.Count)
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.CounterValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "ingest", "total_time_in_millis"),
"Total number of ingest time in millis",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.Ingest.Total.TimeInMillis)
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.CounterValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "ingest", "total_current"),
"Total number of current ingest docs",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.Ingest.Total.Current)
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.CounterValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "ingest", "total_failed"),
"Total number of ingest failed docs",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.Ingest.Total.Failed)
},
Labels: defaultNodeLabelValues,
},
},
gcCollectionMetrics: []*gcCollectionMetric{
{
Expand Down
14 changes: 14 additions & 0 deletions collector/nodes_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type NodeStatsNodeResponse struct {
HTTP map[string]interface{} `json:"http"`
Transport NodeStatsTransportResponse `json:"transport"`
Process NodeStatsProcessResponse `json:"process"`
Ingest NodeIngestResponse `json:"ingest"`
}

// NodeStatsBreakersResponse is a representation of a statistics about the field data circuit breaker
Expand Down Expand Up @@ -384,3 +385,16 @@ type ClusterHealthResponse struct {
TimedOut bool `json:"timed_out"`
UnassignedShards int64 `json:"unassigned_shards"`
}

// NodeIngestResponse is a representation of a node ingest stats
type NodeIngestResponse struct {
Total NodeIngestStatsResponse `json:"total"`
}

// NodeIngestStatsResponse is a representation of a node ingest stats
type NodeIngestStatsResponse struct {
Count int64 `json:"count"`
TimeInMillis int64 `json:"time_in_millis"`
Current int64 `json:"current"`
Failed int64 `json:"failed"`
}

0 comments on commit 0926b4d

Please sign in to comment.