Skip to content

Commit 200cac8

Browse files
yuriymalyginmtulio
authored andcommitted
Add more NameNode metrics.
1 parent 7340fcd commit 200cac8

1 file changed

Lines changed: 143 additions & 21 deletions

File tree

cmd/namenode-exporter/namenode_exporter.go

Lines changed: 143 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,39 @@ var (
2222
)
2323

2424
type Exporter struct {
25-
url string
26-
MissingBlocks prometheus.Gauge
27-
CapacityTotal prometheus.Gauge
28-
CapacityUsed prometheus.Gauge
29-
CapacityRemaining prometheus.Gauge
30-
CapacityUsedNonDFS prometheus.Gauge
31-
BlocksTotal prometheus.Gauge
32-
FilesTotal prometheus.Gauge
33-
CorruptBlocks prometheus.Gauge
34-
ExcessBlocks prometheus.Gauge
35-
StaleDataNodes prometheus.Gauge
36-
pnGcCount prometheus.Gauge
37-
pnGcTime prometheus.Gauge
38-
cmsGcCount prometheus.Gauge
39-
cmsGcTime prometheus.Gauge
40-
heapMemoryUsageCommitted prometheus.Gauge
41-
heapMemoryUsageInit prometheus.Gauge
42-
heapMemoryUsageMax prometheus.Gauge
43-
heapMemoryUsageUsed prometheus.Gauge
44-
isActive prometheus.Gauge
25+
url string
26+
MissingBlocks prometheus.Gauge
27+
CapacityTotal prometheus.Gauge
28+
CapacityUsed prometheus.Gauge
29+
CapacityRemaining prometheus.Gauge
30+
CapacityUsedNonDFS prometheus.Gauge
31+
BlocksTotal prometheus.Gauge
32+
FilesTotal prometheus.Gauge
33+
CorruptBlocks prometheus.Gauge
34+
ExcessBlocks prometheus.Gauge
35+
StaleDataNodes prometheus.Gauge
36+
pnGcCount prometheus.Gauge
37+
pnGcTime prometheus.Gauge
38+
cmsGcCount prometheus.Gauge
39+
cmsGcTime prometheus.Gauge
40+
heapMemoryUsageCommitted prometheus.Gauge
41+
heapMemoryUsageInit prometheus.Gauge
42+
heapMemoryUsageMax prometheus.Gauge
43+
heapMemoryUsageUsed prometheus.Gauge
44+
isActive prometheus.Gauge
45+
BlockCapacity prometheus.Gauge
46+
TotalLoad prometheus.Gauge
47+
UnderReplicatedBlocks prometheus.Gauge
48+
VolumeFailuresTotal prometheus.Gauge
49+
NumLiveDataNodes prometheus.Gauge
50+
NumDeadDataNodes prometheus.Gauge
51+
GcCountConcurrentMarkSweep prometheus.Gauge
52+
GcTimeMillisConcurrentMarkSweep prometheus.Gauge
53+
MemNonHeapUsedM prometheus.Gauge
54+
MemNonHeapCommittedM prometheus.Gauge
55+
MemHeapUsedM prometheus.Gauge
56+
MemHeapCommittedM prometheus.Gauge
57+
MemHeapMaxM prometheus.Gauge
4558
}
4659

4760
func NewExporter(url string) *Exporter {
@@ -142,6 +155,71 @@ func NewExporter(url string) *Exporter {
142155
Name: "isActive",
143156
Help: "isActive",
144157
}),
158+
BlockCapacity: prometheus.NewGauge(prometheus.GaugeOpts{
159+
Namespace: namespace,
160+
Name: "BlockCapacity",
161+
Help: "BlockCapacity",
162+
}),
163+
TotalLoad: prometheus.NewGauge(prometheus.GaugeOpts{
164+
Namespace: namespace,
165+
Name: "TotalLoad",
166+
Help: "TotalLoad",
167+
}),
168+
UnderReplicatedBlocks: prometheus.NewGauge(prometheus.GaugeOpts{
169+
Namespace: namespace,
170+
Name: "UnderReplicatedBlocks",
171+
Help: "UnderReplicatedBlocks",
172+
}),
173+
VolumeFailuresTotal: prometheus.NewGauge(prometheus.GaugeOpts{
174+
Namespace: namespace,
175+
Name: "VolumeFailuresTotal",
176+
Help: "VolumeFailuresTotal",
177+
}),
178+
NumLiveDataNodes: prometheus.NewGauge(prometheus.GaugeOpts{
179+
Namespace: namespace,
180+
Name: "NumLiveDataNodes",
181+
Help: "NumLiveDataNodes",
182+
}),
183+
NumDeadDataNodes: prometheus.NewGauge(prometheus.GaugeOpts{
184+
Namespace: namespace,
185+
Name: "NumDeadDataNodes",
186+
Help: "NumDeadDataNodes",
187+
}),
188+
GcCountConcurrentMarkSweep: prometheus.NewGauge(prometheus.GaugeOpts{
189+
Namespace: namespace,
190+
Name: "GcCountConcurrentMarkSweep",
191+
Help: "GcCountConcurrentMarkSweep",
192+
}),
193+
GcTimeMillisConcurrentMarkSweep: prometheus.NewGauge(prometheus.GaugeOpts{
194+
Namespace: namespace,
195+
Name: "GcTimeMillisConcurrentMarkSweep",
196+
Help: "GcTimeMillisConcurrentMarkSweep",
197+
}),
198+
MemNonHeapUsedM: prometheus.NewGauge(prometheus.GaugeOpts{
199+
Namespace: namespace,
200+
Name: "MemNonHeapUsedM",
201+
Help: "MemNonHeapUsedM",
202+
}),
203+
MemNonHeapCommittedM: prometheus.NewGauge(prometheus.GaugeOpts{
204+
Namespace: namespace,
205+
Name: "MemNonHeapCommittedM",
206+
Help: "MemNonHeapCommittedM",
207+
}),
208+
MemHeapUsedM: prometheus.NewGauge(prometheus.GaugeOpts{
209+
Namespace: namespace,
210+
Name: "MemHeapUsedM",
211+
Help: "MemHeapUsedM",
212+
}),
213+
MemHeapCommittedM: prometheus.NewGauge(prometheus.GaugeOpts{
214+
Namespace: namespace,
215+
Name: "MemHeapCommittedM",
216+
Help: "MemHeapCommittedM",
217+
}),
218+
MemHeapMaxM: prometheus.NewGauge(prometheus.GaugeOpts{
219+
Namespace: namespace,
220+
Name: "MemHeapMaxM",
221+
Help: "MemHeapMaxM",
222+
}),
145223
}
146224
}
147225

@@ -166,6 +244,19 @@ func (e *Exporter) Describe(ch chan<- *prometheus.Desc) {
166244
e.heapMemoryUsageMax.Describe(ch)
167245
e.heapMemoryUsageUsed.Describe(ch)
168246
e.isActive.Describe(ch)
247+
e.BlockCapacity.Describe(ch)
248+
e.TotalLoad.Describe(ch)
249+
e.UnderReplicatedBlocks.Describe(ch)
250+
e.VolumeFailuresTotal.Describe(ch)
251+
e.NumLiveDataNodes.Describe(ch)
252+
e.NumDeadDataNodes.Describe(ch)
253+
e.GcCountConcurrentMarkSweep.Describe(ch)
254+
e.GcTimeMillisConcurrentMarkSweep.Describe(ch)
255+
e.MemNonHeapUsedM.Describe(ch)
256+
e.MemNonHeapCommittedM.Describe(ch)
257+
e.MemHeapUsedM.Describe(ch)
258+
e.MemHeapCommittedM.Describe(ch)
259+
e.MemHeapMaxM.Describe(ch)
169260
}
170261

171262
// Collect implements the prometheus.Collector interface.
@@ -248,6 +339,23 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
248339
e.CorruptBlocks.Set(nameDataMap["CorruptBlocks"].(float64))
249340
e.ExcessBlocks.Set(nameDataMap["ExcessBlocks"].(float64))
250341
e.StaleDataNodes.Set(nameDataMap["StaleDataNodes"].(float64))
342+
e.BlockCapacity.Set(nameDataMap["BlockCapacity"].(float64))
343+
e.TotalLoad.Set(nameDataMap["TotalLoad"].(float64))
344+
e.UnderReplicatedBlocks.Set(nameDataMap["UnderReplicatedBlocks"].(float64))
345+
}
346+
if nameDataMap["name"] == "Hadoop:service=NameNode,name=FSNamesystemState" {
347+
e.VolumeFailuresTotal.Set(nameDataMap["VolumeFailuresTotal"].(float64))
348+
e.NumLiveDataNodes.Set(nameDataMap["NumLiveDataNodes"].(float64))
349+
e.NumDeadDataNodes.Set(nameDataMap["NumDeadDataNodes"].(float64))
350+
}
351+
if nameDataMap["name"] == "Hadoop:service=NameNode,name=JvmMetrics" {
352+
e.GcCountConcurrentMarkSweep.Set(nameDataMap["GcCountConcurrentMarkSweep"].(float64))
353+
e.GcTimeMillisConcurrentMarkSweep.Set(nameDataMap["GcTimeMillisConcurrentMarkSweep"].(float64))
354+
e.MemNonHeapUsedM.Set(nameDataMap["MemNonHeapUsedM"].(float64))
355+
e.MemNonHeapCommittedM.Set(nameDataMap["MemNonHeapCommittedM"].(float64))
356+
e.MemHeapUsedM.Set(nameDataMap["MemHeapUsedM"].(float64))
357+
e.MemHeapCommittedM.Set(nameDataMap["MemHeapCommittedM"].(float64))
358+
e.MemHeapMaxM.Set(nameDataMap["MemHeapMaxM"].(float64))
251359
}
252360
if nameDataMap["name"] == "java.lang:type=GarbageCollector,name=ParNew" {
253361
e.pnGcCount.Set(nameDataMap["CollectionCount"].(float64))
@@ -303,6 +411,19 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
303411
e.heapMemoryUsageMax.Collect(ch)
304412
e.heapMemoryUsageUsed.Collect(ch)
305413
e.isActive.Collect(ch)
414+
e.BlockCapacity.Collect(ch)
415+
e.TotalLoad.Collect(ch)
416+
e.UnderReplicatedBlocks.Collect(ch)
417+
e.VolumeFailuresTotal.Collect(ch)
418+
e.NumLiveDataNodes.Collect(ch)
419+
e.NumDeadDataNodes.Collect(ch)
420+
e.GcCountConcurrentMarkSweep.Collect(ch)
421+
e.GcTimeMillisConcurrentMarkSweep.Collect(ch)
422+
e.MemNonHeapUsedM.Collect(ch)
423+
e.MemNonHeapCommittedM.Collect(ch)
424+
e.MemHeapUsedM.Collect(ch)
425+
e.MemHeapCommittedM.Collect(ch)
426+
e.MemHeapMaxM.Collect(ch)
306427
}
307428

308429
func main() {
@@ -318,6 +439,7 @@ func main() {
318439
<head><title>NameNode Exporter</title></head>
319440
<body>
320441
<h1>NameNode Exporter</h1>
442+
<p>Parsing JMX counters over HTTP/HTTPS.</p>
321443
<p><a href="` + *metricsPath + `">Metrics</a></p>
322444
</body>
323445
</html>`))
@@ -326,4 +448,4 @@ func main() {
326448
if err != nil {
327449
log.Fatal(err)
328450
}
329-
}
451+
}

0 commit comments

Comments
 (0)