Skip to content

Commit 0926b4d

Browse files
committed
add ingest total metrics
Signed-off-by: zengxilong <[email protected]>
1 parent f6480d1 commit 0926b4d

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ elasticsearch_exporter
44
*-stamp
55
.tarballs
66
/vendor
7+
.idea

collector/nodes.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,54 @@ func NewNodes(logger log.Logger, client *http.Client, url *url.URL, all bool, no
15101510
},
15111511
Labels: defaultNodeLabelValues,
15121512
},
1513+
{
1514+
Type: prometheus.CounterValue,
1515+
Desc: prometheus.NewDesc(
1516+
prometheus.BuildFQName(namespace, "ingest", "total_count"),
1517+
"Total number of ingest count",
1518+
defaultNodeLabels, nil,
1519+
),
1520+
Value: func(node NodeStatsNodeResponse) float64 {
1521+
return float64(node.Ingest.Total.Count)
1522+
},
1523+
Labels: defaultNodeLabelValues,
1524+
},
1525+
{
1526+
Type: prometheus.CounterValue,
1527+
Desc: prometheus.NewDesc(
1528+
prometheus.BuildFQName(namespace, "ingest", "total_time_in_millis"),
1529+
"Total number of ingest time in millis",
1530+
defaultNodeLabels, nil,
1531+
),
1532+
Value: func(node NodeStatsNodeResponse) float64 {
1533+
return float64(node.Ingest.Total.TimeInMillis)
1534+
},
1535+
Labels: defaultNodeLabelValues,
1536+
},
1537+
{
1538+
Type: prometheus.CounterValue,
1539+
Desc: prometheus.NewDesc(
1540+
prometheus.BuildFQName(namespace, "ingest", "total_current"),
1541+
"Total number of current ingest docs",
1542+
defaultNodeLabels, nil,
1543+
),
1544+
Value: func(node NodeStatsNodeResponse) float64 {
1545+
return float64(node.Ingest.Total.Current)
1546+
},
1547+
Labels: defaultNodeLabelValues,
1548+
},
1549+
{
1550+
Type: prometheus.CounterValue,
1551+
Desc: prometheus.NewDesc(
1552+
prometheus.BuildFQName(namespace, "ingest", "total_failed"),
1553+
"Total number of ingest failed docs",
1554+
defaultNodeLabels, nil,
1555+
),
1556+
Value: func(node NodeStatsNodeResponse) float64 {
1557+
return float64(node.Ingest.Total.Failed)
1558+
},
1559+
Labels: defaultNodeLabelValues,
1560+
},
15131561
},
15141562
gcCollectionMetrics: []*gcCollectionMetric{
15151563
{

collector/nodes_response.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type NodeStatsNodeResponse struct {
4040
HTTP map[string]interface{} `json:"http"`
4141
Transport NodeStatsTransportResponse `json:"transport"`
4242
Process NodeStatsProcessResponse `json:"process"`
43+
Ingest NodeIngestResponse `json:"ingest"`
4344
}
4445

4546
// NodeStatsBreakersResponse is a representation of a statistics about the field data circuit breaker
@@ -384,3 +385,16 @@ type ClusterHealthResponse struct {
384385
TimedOut bool `json:"timed_out"`
385386
UnassignedShards int64 `json:"unassigned_shards"`
386387
}
388+
389+
// NodeIngestResponse is a representation of a node ingest stats
390+
type NodeIngestResponse struct {
391+
Total NodeIngestStatsResponse `json:"total"`
392+
}
393+
394+
// NodeIngestStatsResponse is a representation of a node ingest stats
395+
type NodeIngestStatsResponse struct {
396+
Count int64 `json:"count"`
397+
TimeInMillis int64 `json:"time_in_millis"`
398+
Current int64 `json:"current"`
399+
Failed int64 `json:"failed"`
400+
}

0 commit comments

Comments
 (0)