Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metrics] Add tablet count on different status metrics #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/clone/TabletChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
import org.apache.doris.common.DdlException;
import org.apache.doris.common.Pair;
import org.apache.doris.common.util.MasterDaemon;
import org.apache.doris.metric.GaugeMetric;
import org.apache.doris.metric.Metric;
import org.apache.doris.metric.MetricLabel;
import org.apache.doris.metric.MetricRepo;
import org.apache.doris.system.SystemInfoService;

import com.google.common.base.Preconditions;
Expand All @@ -46,10 +50,12 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;

/*
Expand All @@ -66,6 +72,14 @@ public class TabletChecker extends MasterDaemon {
private TabletScheduler tabletScheduler;
private TabletSchedulerStat stat;

HashMap<String, AtomicLong> tabletCountByStatus = new HashMap<String, AtomicLong>(){{
put("total", new AtomicLong(0L));
put("unhealthy", new AtomicLong(0L));
put("added", new AtomicLong(0L));
put("in_sched", new AtomicLong(0L));
put("not_ready", new AtomicLong(0L));
}};

// db id -> (tbl id -> PrioPart)
// priority of replicas of partitions in this table will be set to VERY_HIGH if not healthy
private com.google.common.collect.Table<Long, Long, Set<PrioPart>> prios = HashBasedTable.create();
Expand Down Expand Up @@ -119,6 +133,22 @@ public TabletChecker(Catalog catalog, SystemInfoService infoService, TabletSched
this.infoService = infoService;
this.tabletScheduler = tabletScheduler;
this.stat = stat;

initMetrics();
}

private void initMetrics() {
for (String status : tabletCountByStatus.keySet()) {
GaugeMetric<Long> gauge = new GaugeMetric<Long>("tablet_status_count",
Metric.MetricUnit.NOUNIT, "tablet count on different status") {
@Override
public Long getValue() {
return tabletCountByStatus.get(status).get();
}
};
gauge.addLabel(new MetricLabel("type", status));
MetricRepo.PALO_METRIC_REGISTER.addPaloMetrics(gauge);
}
}

private void addPrios(RepairTabletInfo repairTabletInfo, long timeoutMs) {
Expand Down Expand Up @@ -272,6 +302,7 @@ private void checkTablets() {
if (isInPrios(db.getId(), tbl.getId(), partition.getId())) {
continue;
}

LoopControlStatus st = handlePartitionTablet(db, tbl, partition, false,
aliveBeIdsInCluster, start, counter);
if (st == LoopControlStatus.BREAK_OUT) {
Expand All @@ -292,6 +323,12 @@ private void checkTablets() {
stat.counterUnhealthyTabletNum.addAndGet(counter.unhealthyTabletNum);
stat.counterTabletAddToBeScheduled.addAndGet(counter.addToSchedulerTabletNum);

tabletCountByStatus.get("unhealthy").set(counter.unhealthyTabletNum);
tabletCountByStatus.get("total").set(counter.totalTabletNum);
tabletCountByStatus.get("added").set(counter.addToSchedulerTabletNum);
tabletCountByStatus.get("in_sched").set(counter.tabletInScheduler);
tabletCountByStatus.get("not_ready").set(counter.tabletNotReady);

LOG.info("finished to check tablets. unhealth/total/added/in_sched/not_ready: {}/{}/{}/{}/{}, cost: {} ms",
counter.unhealthyTabletNum, counter.totalTabletNum, counter.addToSchedulerTabletNum,
counter.tabletInScheduler, counter.tabletNotReady, cost);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public final class MetricRepo {
private static final Logger LOG = LogManager.getLogger(MetricRepo.class);

private static final MetricRegistry METRIC_REGISTER = new MetricRegistry();
private static final DorisMetricRegistry PALO_METRIC_REGISTER = new DorisMetricRegistry();
public static final DorisMetricRegistry PALO_METRIC_REGISTER = new DorisMetricRegistry();

public static volatile boolean isInit = false;
public static final SystemMetrics SYSTEM_METRICS = new SystemMetrics();
Expand Down