Add per-region details to hbase collector
@@ -17,6 +17,7 @@ import (
var (
hbURL = "/jmx?qry=Hadoop:service=HBase,name=RegionServer,sub=Server"
+ hbRegURL = "/jmx?qry=Hadoop:service=HBase,name=RegionServer,sub=Regions"
hbRepURL = "/jmx?qry=Hadoop:service=HBase,name=RegionServer,sub=Replication"
hbGCURL = "/jmx?qry=java.lang:type=GarbageCollector,name=*"
)
@@ -30,9 +31,11 @@ func init() {
host = "http://localhost:60030"
}
hbURL = host + hbURL
+ hbRegURL = host + hbRegURL
hbRepURL = host + hbRepURL
hbGCURL = host + hbGCURL
collectors = append(collectors, &IntervalCollector{F: c_hbase_region, Enable: enableURL(hbURL)})
+ collectors = append(collectors, &IntervalCollector{F: c_hbase_regions, Enable: enableURL(hbRegURL)})
collectors = append(collectors, &IntervalCollector{F: c_hbase_replication, Enable: enableURL(hbRepURL)})
collectors = append(collectors, &IntervalCollector{F: c_hbase_gc, Enable: enableURL(hbGCURL)})
})
@@ -72,6 +75,38 @@ func c_hbase_region() (opentsdb.MultiDataPoint, error) {
return md, nil
}
+func c_hbase_regions() (opentsdb.MultiDataPoint, error) {
+ var j jmx
+ if err := getBeans(hbRegURL, &j); err != nil {
+ return nil, err
+ }
+ var md opentsdb.MultiDataPoint
+ if len(j.Beans) > 0 && len(j.Beans[0]) > 0 {
+ for k, v := range j.Beans[0] {
+ if vv, ok := v.(float64); ok {
+ if vv > math.MaxInt64 {
+ continue
+ }
+ kParts := strings.Split(k, "_")
+ t := make(opentsdb.TagSet)
+ var m string
+ for i := 0; i+1 < len(kParts); i += 2 {
+ if kParts[i] == "metric" {
+ m = strings.Join(kParts[i+1:], "_")
+ break
+ }
+ t[kParts[i]] = kParts[i+1]
+ }
+ if m == "" {
+ continue
+ }
+ Add(&md, "hbase.regions."+m, v, t, metadata.Unknown, metadata.None, "")
+ }
+ }
+ }
+ return md, nil
+}
+
func c_hbase_gc() (opentsdb.MultiDataPoint, error) {
var j jmx
if err := getBeans(hbGCURL, &j); err != nil {
