in fe/fe-core/src/main/java/org/apache/doris/metric/MetricRepo.java [183:634]
public static synchronized void init() {
if (isInit) {
return;
}
// version
GaugeMetric<Long> feVersion = new GaugeMetric<Long>("version", MetricUnit.NOUNIT, "") {
@Override
public Long getValue() {
try {
return Long.parseLong("" + Version.DORIS_BUILD_VERSION_MAJOR + "0"
+ Version.DORIS_BUILD_VERSION_MINOR + "0"
+ Version.DORIS_BUILD_VERSION_PATCH
+ (Version.DORIS_BUILD_VERSION_HOTFIX > 0
? ("0" + Version.DORIS_BUILD_VERSION_HOTFIX)
: ""));
} catch (Throwable t) {
LOG.warn("failed to init version metrics", t);
return 0L;
}
}
};
DORIS_METRIC_REGISTER.addMetrics(feVersion);
// load jobs
for (EtlJobType jobType : EtlJobType.values()) {
if (jobType == EtlJobType.UNKNOWN) {
continue;
}
for (JobState state : JobState.values()) {
GaugeMetric<Long> gauge = new GaugeMetric<Long>("job", MetricUnit.NOUNIT, "job statistics") {
@Override
public Long getValue() {
if (!Env.getCurrentEnv().isMaster()) {
return 0L;
}
return MetricRepo.getLoadJobNum(jobType, state);
}
};
gauge.addLabel(new MetricLabel("job", "load")).addLabel(new MetricLabel("type", jobType.name()))
.addLabel(new MetricLabel("state", state.name()));
DORIS_METRIC_REGISTER.addMetrics(gauge);
}
}
initRoutineLoadJobMetrics();
// running alter job
Alter alter = Env.getCurrentEnv().getAlterInstance();
for (JobType jobType : JobType.values()) {
if (jobType != JobType.SCHEMA_CHANGE && jobType != JobType.ROLLUP) {
continue;
}
GaugeMetric<Long> gauge = new GaugeMetric<Long>("job", MetricUnit.NOUNIT, "job statistics") {
@Override
public Long getValue() {
if (!Env.getCurrentEnv().isMaster()) {
return 0L;
}
if (jobType == JobType.SCHEMA_CHANGE) {
return alter.getSchemaChangeHandler()
.getAlterJobV2Num(org.apache.doris.alter.AlterJobV2.JobState.RUNNING);
} else {
return alter.getMaterializedViewHandler().getAlterJobV2Num(
org.apache.doris.alter.AlterJobV2.JobState.RUNNING);
}
}
};
gauge.addLabel(new MetricLabel("job", "alter")).addLabel(new MetricLabel("type", jobType.name()))
.addLabel(new MetricLabel("state", "running"));
DORIS_METRIC_REGISTER.addMetrics(gauge);
}
// capacity
generateBackendsTabletMetrics();
// connections
USER_GAUGE_CONNECTIONS = addLabeledMetrics("user", () ->
new GaugeMetricImpl<>("connection_total", MetricUnit.CONNECTIONS,
"total connections", 0));
GaugeMetric<Integer> connections = new GaugeMetric<Integer>("connection_total",
MetricUnit.CONNECTIONS, "total connections") {
@Override
public Integer getValue() {
ExecuteEnv.getInstance().getScheduler().getUserConnectionMap()
.forEach((k, v) -> USER_GAUGE_CONNECTIONS.getOrAdd(k).setValue(v.get()));
return ExecuteEnv.getInstance().getScheduler().getConnectionNum();
}
};
DORIS_METRIC_REGISTER.addMetrics(connections);
// journal id
GaugeMetric<Long> maxJournalId = new GaugeMetric<Long>("max_journal_id", MetricUnit.NOUNIT,
"max journal id of this frontends") {
@Override
public Long getValue() {
EditLog editLog = Env.getCurrentEnv().getEditLog();
if (editLog == null) {
return -1L;
}
return editLog.getMaxJournalId();
}
};
DORIS_METRIC_REGISTER.addMetrics(maxJournalId);
// scheduled tablet num
GaugeMetric<Long> scheduledTabletNum = new GaugeMetric<Long>("scheduled_tablet_num", MetricUnit.NOUNIT,
"number of tablets being scheduled") {
@Override
public Long getValue() {
if (!Env.getCurrentEnv().isMaster()) {
return 0L;
}
return (long) Env.getCurrentEnv().getTabletScheduler().getTotalNum();
}
};
DORIS_METRIC_REGISTER.addMetrics(scheduledTabletNum);
// txn status
for (TransactionStatus status : TransactionStatus.values()) {
GaugeMetric<Long> gauge = new GaugeMetric<Long>("txn_status", MetricUnit.NOUNIT, "txn statistics") {
@Override
public Long getValue() {
if (!Env.getCurrentEnv().isMaster()) {
return 0L;
}
return Env.getCurrentGlobalTransactionMgr().getTxnNumByStatus(status);
}
};
gauge.addLabel(new MetricLabel("type", status.name().toLowerCase()));
DORIS_METRIC_REGISTER.addMetrics(gauge);
}
// qps, rps and error rate
// these metrics should be set an init value, in case that metric calculator is not running
GAUGE_QUERY_PER_SECOND = new GaugeMetricImpl<>("qps", MetricUnit.NOUNIT, "query per second", 0.0);
DORIS_METRIC_REGISTER.addMetrics(GAUGE_QUERY_PER_SECOND);
GAUGE_REQUEST_PER_SECOND = new GaugeMetricImpl<>("rps", MetricUnit.NOUNIT, "request per second", 0.0);
DORIS_METRIC_REGISTER.addMetrics(GAUGE_REQUEST_PER_SECOND);
GAUGE_QUERY_ERR_RATE = new GaugeMetricImpl<>("query_err_rate", MetricUnit.NOUNIT, "query error rate", 0.0);
DORIS_METRIC_REGISTER.addMetrics(GAUGE_QUERY_ERR_RATE);
GAUGE_QUERY_SLOW_RATE = new GaugeMetricImpl<>("query_slow_rate", MetricUnit.NOUNIT, "query slow rate", 0.0);
DORIS_METRIC_REGISTER.addMetrics(GAUGE_QUERY_SLOW_RATE);
GAUGE_MAX_TABLET_COMPACTION_SCORE = new GaugeMetricImpl<>("max_tablet_compaction_score", MetricUnit.NOUNIT,
"max tablet compaction score of all backends", 0L);
DORIS_METRIC_REGISTER.addMetrics(GAUGE_MAX_TABLET_COMPACTION_SCORE);
// query
COUNTER_REQUEST_ALL = new LongCounterMetric("request_total", MetricUnit.REQUESTS, "total request");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_REQUEST_ALL);
COUNTER_QUERY_ALL = new LongCounterMetric("query_total", MetricUnit.REQUESTS, "total query");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_QUERY_ALL);
COUNTER_QUERY_ERR = new LongCounterMetric("query_err", MetricUnit.REQUESTS, "total error query");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_QUERY_ERR);
COUNTER_QUERY_SLOW = new LongCounterMetric("query_slow", MetricUnit.REQUESTS, "total slow query");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_QUERY_SLOW);
COUNTER_QUERY_TABLE = new LongCounterMetric("query_table", MetricUnit.REQUESTS, "total query from table");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_QUERY_TABLE);
COUNTER_QUERY_OLAP_TABLE = new LongCounterMetric("query_olap_table", MetricUnit.REQUESTS,
"total query from olap table");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_QUERY_OLAP_TABLE);
COUNTER_QUERY_HIVE_TABLE = new LongCounterMetric("query_hive_table", MetricUnit.REQUESTS,
"total query from hive table");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_QUERY_HIVE_TABLE);
USER_COUNTER_QUERY_ALL = new AutoMappedMetric<>(name -> {
LongCounterMetric userCountQueryAll = new LongCounterMetric("query_total", MetricUnit.REQUESTS,
"total query for single user");
userCountQueryAll.addLabel(new MetricLabel("user", name));
DORIS_METRIC_REGISTER.addMetrics(userCountQueryAll);
return userCountQueryAll;
});
USER_COUNTER_QUERY_ERR = new AutoMappedMetric<>(name -> {
LongCounterMetric userCountQueryErr = new LongCounterMetric("query_err", MetricUnit.REQUESTS,
"total error query for single user");
userCountQueryErr.addLabel(new MetricLabel("user", name));
DORIS_METRIC_REGISTER.addMetrics(userCountQueryErr);
return userCountQueryErr;
});
HISTO_QUERY_LATENCY = METRIC_REGISTER.histogram(
MetricRegistry.name("query", "latency", "ms"));
USER_HISTO_QUERY_LATENCY = new AutoMappedMetric<>(name -> {
String metricName = MetricRegistry.name("query", "latency", "ms", "user=" + name);
return METRIC_REGISTER.histogram(metricName);
});
USER_COUNTER_QUERY_INSTANCE_BEGIN = addLabeledMetrics("user", () ->
new LongCounterMetric("query_instance_begin", MetricUnit.NOUNIT,
"number of query instance begin"));
USER_GAUGE_QUERY_INSTANCE_NUM = addLabeledMetrics("user", () ->
new GaugeMetricImpl<>("query_instance_num", MetricUnit.NOUNIT,
"number of running query instances of current user", 0L));
GaugeMetric<Long> queryInstanceNum = new GaugeMetric<Long>("query_instance_num",
MetricUnit.NOUNIT, "number of query instances of all current users") {
@Override
public Long getValue() {
QeProcessorImpl qe = ((QeProcessorImpl) QeProcessorImpl.INSTANCE);
long totalInstanceNum = 0;
for (Map.Entry<String, Integer> e : qe.getInstancesNumPerUser().entrySet()) {
long value = e.getValue() == null ? 0L : e.getValue().longValue();
totalInstanceNum += value;
USER_GAUGE_QUERY_INSTANCE_NUM.getOrAdd(e.getKey()).setValue(value);
}
return totalInstanceNum;
}
};
DORIS_METRIC_REGISTER.addMetrics(queryInstanceNum);
BE_COUNTER_QUERY_RPC_ALL = addLabeledMetrics("be", () ->
new LongCounterMetric("query_rpc_total", MetricUnit.NOUNIT, ""));
BE_COUNTER_QUERY_RPC_FAILED = addLabeledMetrics("be", () ->
new LongCounterMetric("query_rpc_failed", MetricUnit.NOUNIT, ""));
BE_COUNTER_QUERY_RPC_SIZE = addLabeledMetrics("be", () ->
new LongCounterMetric("query_rpc_size", MetricUnit.BYTES, ""));
// cache
COUNTER_CACHE_ADDED_SQL = new LongCounterMetric("cache_added", MetricUnit.REQUESTS,
"Number of SQL mode cache added");
COUNTER_CACHE_ADDED_SQL.addLabel(new MetricLabel("type", "sql"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_CACHE_ADDED_SQL);
COUNTER_CACHE_ADDED_PARTITION = new LongCounterMetric("cache_added", MetricUnit.REQUESTS,
"Number of Partition mode cache added");
COUNTER_CACHE_ADDED_PARTITION.addLabel(new MetricLabel("type", "partition"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_CACHE_ADDED_PARTITION);
COUNTER_CACHE_HIT_SQL = new LongCounterMetric("cache_hit", MetricUnit.REQUESTS,
"total hits query by sql model");
COUNTER_CACHE_HIT_SQL.addLabel(new MetricLabel("type", "sql"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_CACHE_HIT_SQL);
COUNTER_CACHE_HIT_PARTITION = new LongCounterMetric("cache_hit", MetricUnit.REQUESTS,
"total hits query by partition model");
COUNTER_CACHE_HIT_PARTITION.addLabel(new MetricLabel("type", "partition"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_CACHE_HIT_PARTITION);
// edit log
COUNTER_EDIT_LOG_WRITE = new LongCounterMetric("edit_log", MetricUnit.OPERATIONS,
"counter of edit log write into bdbje");
COUNTER_EDIT_LOG_WRITE.addLabel(new MetricLabel("type", "write"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_EDIT_LOG_WRITE);
COUNTER_EDIT_LOG_READ = new LongCounterMetric("edit_log", MetricUnit.OPERATIONS,
"counter of edit log read from bdbje");
COUNTER_EDIT_LOG_READ.addLabel(new MetricLabel("type", "read"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_EDIT_LOG_READ);
COUNTER_EDIT_LOG_CURRENT = new LongCounterMetric("edit_log", MetricUnit.OPERATIONS,
"counter of current edit log in bdbje");
COUNTER_EDIT_LOG_CURRENT.addLabel(new MetricLabel("type", "current"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_EDIT_LOG_CURRENT);
COUNTER_EDIT_LOG_SIZE_BYTES = new LongCounterMetric("edit_log", MetricUnit.BYTES,
"size of accumulated edit log");
COUNTER_EDIT_LOG_SIZE_BYTES.addLabel(new MetricLabel("type", "accumulated_bytes"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_EDIT_LOG_SIZE_BYTES);
COUNTER_CURRENT_EDIT_LOG_SIZE_BYTES = new LongCounterMetric("edit_log", MetricUnit.BYTES,
"size of current edit log");
COUNTER_CURRENT_EDIT_LOG_SIZE_BYTES.addLabel(new MetricLabel("type", "current_bytes"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_CURRENT_EDIT_LOG_SIZE_BYTES);
COUNTER_LARGE_EDIT_LOG = new LongCounterMetric("edit_log", MetricUnit.OPERATIONS,
"counter of large edit log write into bdbje");
COUNTER_LARGE_EDIT_LOG.addLabel(new MetricLabel("type", "large_write"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_LARGE_EDIT_LOG);
HISTO_EDIT_LOG_WRITE_LATENCY = METRIC_REGISTER.histogram(
MetricRegistry.name("editlog", "write", "latency", "ms"));
HISTO_JOURNAL_BATCH_SIZE = METRIC_REGISTER.histogram(
MetricRegistry.name("journal", "write", "batch_size"));
HISTO_JOURNAL_BATCH_DATA_SIZE = METRIC_REGISTER.histogram(
MetricRegistry.name("journal", "write", "batch_data_size"));
// edit log clean
COUNTER_EDIT_LOG_CLEAN_SUCCESS = new LongCounterMetric("edit_log_clean", MetricUnit.OPERATIONS,
"counter of edit log succeed in cleaning");
COUNTER_EDIT_LOG_CLEAN_SUCCESS.addLabel(new MetricLabel("type", "success"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_EDIT_LOG_CLEAN_SUCCESS);
COUNTER_EDIT_LOG_CLEAN_FAILED = new LongCounterMetric("edit_log_clean", MetricUnit.OPERATIONS,
"counter of edit log failed to clean");
COUNTER_EDIT_LOG_CLEAN_FAILED.addLabel(new MetricLabel("type", "failed"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_EDIT_LOG_CLEAN_FAILED);
// image generate
COUNTER_IMAGE_WRITE_SUCCESS = new LongCounterMetric("image_write", MetricUnit.OPERATIONS,
"counter of image succeed in write");
COUNTER_IMAGE_WRITE_SUCCESS.addLabel(new MetricLabel("type", "success"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_IMAGE_WRITE_SUCCESS);
COUNTER_IMAGE_WRITE_FAILED = new LongCounterMetric("image_write", MetricUnit.OPERATIONS,
"counter of image failed to write");
COUNTER_IMAGE_WRITE_FAILED.addLabel(new MetricLabel("type", "failed"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_IMAGE_WRITE_FAILED);
COUNTER_IMAGE_PUSH_SUCCESS = new LongCounterMetric("image_push", MetricUnit.OPERATIONS,
"counter of image succeeded in pushing to other frontends");
COUNTER_IMAGE_PUSH_SUCCESS.addLabel(new MetricLabel("type", "success"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_IMAGE_PUSH_SUCCESS);
COUNTER_IMAGE_PUSH_FAILED = new LongCounterMetric("image_push", MetricUnit.OPERATIONS,
"counter of image failed to other frontends");
COUNTER_IMAGE_PUSH_FAILED.addLabel(new MetricLabel("type", "failed"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_IMAGE_PUSH_FAILED);
// image clean
COUNTER_IMAGE_CLEAN_SUCCESS = new LongCounterMetric("image_clean", MetricUnit.OPERATIONS,
"counter of image succeeded in cleaning");
COUNTER_IMAGE_CLEAN_SUCCESS.addLabel(new MetricLabel("type", "success"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_IMAGE_CLEAN_SUCCESS);
COUNTER_IMAGE_CLEAN_FAILED = new LongCounterMetric("image_clean", MetricUnit.OPERATIONS,
"counter of image failed to clean");
COUNTER_IMAGE_CLEAN_FAILED.addLabel(new MetricLabel("type", "failed"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_IMAGE_CLEAN_FAILED);
// txn
COUNTER_TXN_REJECT = new LongCounterMetric("txn_counter", MetricUnit.REQUESTS,
"counter of rejected transactions");
COUNTER_TXN_REJECT.addLabel(new MetricLabel("type", "reject"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_TXN_REJECT);
COUNTER_TXN_BEGIN = new LongCounterMetric("txn_counter", MetricUnit.REQUESTS,
"counter of beginning transactions");
COUNTER_TXN_BEGIN.addLabel(new MetricLabel("type", "begin"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_TXN_BEGIN);
COUNTER_TXN_SUCCESS = new LongCounterMetric("txn_counter", MetricUnit.REQUESTS,
"counter of success transactions");
COUNTER_TXN_SUCCESS.addLabel(new MetricLabel("type", "success"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_TXN_SUCCESS);
COUNTER_TXN_FAILED = new LongCounterMetric("txn_counter", MetricUnit.REQUESTS,
"counter of failed transactions");
COUNTER_TXN_FAILED.addLabel(new MetricLabel("type", "failed"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_TXN_FAILED);
COUNTER_UPDATE_TABLET_STAT_FAILED = new LongCounterMetric("update_tablet_stat_failed", MetricUnit.REQUESTS,
"counter of failed to update tablet stat");
COUNTER_UPDATE_TABLET_STAT_FAILED.addLabel(new MetricLabel("type", "failed"));
DORIS_METRIC_REGISTER.addMetrics(COUNTER_UPDATE_TABLET_STAT_FAILED);
HISTO_TXN_EXEC_LATENCY = METRIC_REGISTER.histogram(
MetricRegistry.name("txn", "exec", "latency", "ms"));
HISTO_TXN_PUBLISH_LATENCY = METRIC_REGISTER.histogram(
MetricRegistry.name("txn", "publish", "latency", "ms"));
GaugeMetric<Long> txnNum = new GaugeMetric<Long>("txn_num", MetricUnit.NOUNIT,
"number of running transactions") {
@Override
public Long getValue() {
return Env.getCurrentGlobalTransactionMgr().getAllRunningTxnNum();
}
};
DORIS_METRIC_REGISTER.addMetrics(txnNum);
DB_GAUGE_TXN_NUM = addLabeledMetrics("db", () ->
new GaugeMetricImpl<>("txn_num", MetricUnit.NOUNIT, "number of running transactions", 0L));
GaugeMetric<Long> publishTxnNum = new GaugeMetric<Long>("publish_txn_num", MetricUnit.NOUNIT,
"number of publish transactions") {
@Override
public Long getValue() {
return Env.getCurrentGlobalTransactionMgr().getAllPublishTxnNum();
}
};
DORIS_METRIC_REGISTER.addMetrics(publishTxnNum);
DB_GAUGE_PUBLISH_TXN_NUM = addLabeledMetrics("db",
() -> new GaugeMetricImpl<>("publish_txn_num", MetricUnit.NOUNIT,
"number of publish transactions", 0L));
COUNTER_ROUTINE_LOAD_ROWS = new LongCounterMetric("routine_load_rows", MetricUnit.ROWS,
"total rows of routine load");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_ROUTINE_LOAD_ROWS);
COUNTER_ROUTINE_LOAD_RECEIVED_BYTES = new LongCounterMetric("routine_load_receive_bytes", MetricUnit.BYTES,
"total received bytes of routine load");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_ROUTINE_LOAD_RECEIVED_BYTES);
COUNTER_ROUTINE_LOAD_ERROR_ROWS = new LongCounterMetric("routine_load_error_rows", MetricUnit.ROWS,
"total error rows of routine load");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_ROUTINE_LOAD_ERROR_ROWS);
COUNTER_ROUTINE_LOAD_GET_META_LANTENCY = new LongCounterMetric("routine_load_get_meta_latency",
MetricUnit.MILLISECONDS, "get meta lantency of routine load");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_ROUTINE_LOAD_GET_META_LANTENCY);
COUNTER_ROUTINE_LOAD_GET_META_COUNT = new LongCounterMetric("routine_load_get_meta_count", MetricUnit.NOUNIT,
"get meta count of routine load");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_ROUTINE_LOAD_GET_META_COUNT);
COUNTER_ROUTINE_LOAD_GET_META_FAIL_COUNT = new LongCounterMetric("routine_load_get_meta_fail_count",
MetricUnit.NOUNIT, "get meta fail count of routine load");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_ROUTINE_LOAD_GET_META_FAIL_COUNT);
COUNTER_ROUTINE_LOAD_TASK_EXECUTE_TIME = new LongCounterMetric("routine_load_task_execute_time",
MetricUnit.MILLISECONDS, "task execute time of routine load");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_ROUTINE_LOAD_TASK_EXECUTE_TIME);
COUNTER_ROUTINE_LOAD_TASK_EXECUTE_COUNT = new LongCounterMetric("routine_load_task_execute_count",
MetricUnit.MILLISECONDS, "task execute count of routine load");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_ROUTINE_LOAD_TASK_EXECUTE_COUNT);
COUNTER_HIT_SQL_BLOCK_RULE = new LongCounterMetric("counter_hit_sql_block_rule", MetricUnit.ROWS,
"total hit sql block rule query");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_HIT_SQL_BLOCK_RULE);
THRIFT_COUNTER_RPC_ALL = addLabeledMetrics("method", () ->
new LongCounterMetric("thrift_rpc_total", MetricUnit.NOUNIT, ""));
THRIFT_COUNTER_RPC_LATENCY = addLabeledMetrics("method", () ->
new LongCounterMetric("thrift_rpc_latency_ms", MetricUnit.MILLISECONDS, ""));
// copy into
HTTP_COUNTER_COPY_INFO_UPLOAD_REQUEST = new LongCounterMetric("http_copy_into_upload_request_total",
MetricUnit.REQUESTS, "http copy into upload total request");
DORIS_METRIC_REGISTER.addMetrics(HTTP_COUNTER_COPY_INFO_UPLOAD_REQUEST);
HTTP_COUNTER_COPY_INFO_UPLOAD_ERR = new LongCounterMetric("http_copy_into_upload_err_total",
MetricUnit.REQUESTS, "http copy into upload err request");
DORIS_METRIC_REGISTER.addMetrics(HTTP_COUNTER_COPY_INFO_UPLOAD_ERR);
HTTP_COUNTER_COPY_INFO_QUERY_REQUEST = new LongCounterMetric("http_copy_into_query_request_total",
MetricUnit.REQUESTS, "http copy into total query request");
DORIS_METRIC_REGISTER.addMetrics(HTTP_COUNTER_COPY_INFO_QUERY_REQUEST);
HTTP_COUNTER_COPY_INFO_QUERY_ERR = new LongCounterMetric("http_copy_into_upload_err_total",
MetricUnit.REQUESTS, "http copy into err query request");
DORIS_METRIC_REGISTER.addMetrics(HTTP_COUNTER_COPY_INFO_QUERY_ERR);
HISTO_HTTP_COPY_INTO_UPLOAD_LATENCY = METRIC_REGISTER.histogram(
MetricRegistry.name("http_copy_into_upload", "latency", "ms"));
HISTO_HTTP_COPY_INTO_QUERY_LATENCY = METRIC_REGISTER.histogram(
MetricRegistry.name("http_copy_into_query", "latency", "ms"));
HISTO_COMMIT_AND_PUBLISH_LATENCY = METRIC_REGISTER.histogram(
MetricRegistry.name("txn_commit_and_publish", "latency", "ms"));
GAUGE_CATALOG_NUM = new GaugeMetric<Integer>("catalog_num",
MetricUnit.NOUNIT, "total catalog num") {
@Override
public Integer getValue() {
return Env.getCurrentEnv().getCatalogMgr().getCatalogNum();
}
};
DORIS_METRIC_REGISTER.addMetrics(GAUGE_CATALOG_NUM);
GAUGE_INTERNAL_DATABASE_NUM = new GaugeMetric<Integer>("internal_database_num",
MetricUnit.NOUNIT, "total internal database num") {
@Override
public Integer getValue() {
return Env.getCurrentEnv().getCatalogMgr().getInternalCatalog().getDbNum();
}
};
DORIS_METRIC_REGISTER.addMetrics(GAUGE_INTERNAL_DATABASE_NUM);
GAUGE_INTERNAL_TABLE_NUM = new GaugeMetric<Integer>("internal_table_num",
MetricUnit.NOUNIT, "total internal table num") {
@Override
public Integer getValue() {
return Env.getCurrentEnv().getCatalogMgr().getInternalCatalog().getAllDbs().stream()
.map(d -> (Database) d).map(Database::getTableNum).reduce(0, Integer::sum);
}
};
DORIS_METRIC_REGISTER.addMetrics(GAUGE_INTERNAL_TABLE_NUM);
COUNTER_AGENT_TASK_REQUEST_TOTAL = new LongCounterMetric("agent_task_request_total", MetricUnit.NOUNIT,
"total agent batch task request send to BE");
DORIS_METRIC_REGISTER.addMetrics(COUNTER_AGENT_TASK_REQUEST_TOTAL);
COUNTER_AGENT_TASK_TOTAL = addLabeledMetrics("task", () ->
new LongCounterMetric("agent_task_total", MetricUnit.NOUNIT, "total agent task"));
COUNTER_AGENT_TASK_RESEND_TOTAL = addLabeledMetrics("task", () ->
new LongCounterMetric("agent_task_resend_total", MetricUnit.NOUNIT, "total agent task resend"));
// init system metrics
initSystemMetrics();
CloudMetrics.init();
updateMetrics();
isInit = true;
if (Config.enable_metric_calculator) {
metricTimer.scheduleAtFixedRate(metricCalculator, 0, 15 * 1000L, TimeUnit.MILLISECONDS);
}
}