Skip to content

Commit

Permalink
hbase_regionserver.py: fix region metrics splitting
Browse files Browse the repository at this point in the history
Signed-off-by: Vasiliy Kiryanov <[email protected]>
  • Loading branch information
Ishan Chhabra authored and vasiliyk committed Apr 17, 2014
1 parent a4e7cdf commit 9eb4a52
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions collectors/0/hbase_regionserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# see <http://www.gnu.org/licenses/>.

import time
import re

try:
import json
Expand All @@ -25,21 +26,22 @@
EMIT_REGION = True

EXCLUDED_CONTEXTS = ("master")
REGION_METRIC_PATTERN = re.compile(r"[N|n]amespace_(.*)_table_(.*)_region_(.*)_metric_(.*)")

class HBaseRegionserver(HadoopHttp):
def __init__(self):
super(HBaseRegionserver, self).__init__("hbase", "regionserver", "localhost", 60030)

def emit_region_metric(self, context, current_time, full_metric_name, value):
split_metric = full_metric_name.split("_")
if len(split_metric) < 7:
match = REGION_METRIC_PATTERN.match(full_metric_name)
if not match:
utils.err("Error splitting %s" % full_metric_name)
return

namespace = split_metric[1]
table = split_metric[3]
region = split_metric[5]
metric_name = "_".join(split_metric[7:])
namespace = match.group(1)
table = match.group(2)
region = match.group(3)
metric_name = match.group(4)
tag_dict = {"namespace": namespace, "table": table, "region": region}

if any( not v for k,v in tag_dict.iteritems()):
Expand Down

0 comments on commit 9eb4a52

Please sign in to comment.