pick #40050
This commit is contained in:
@ -228,6 +228,11 @@ public class JsonMetricVisitor extends MetricVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitWorkloadGroup() {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String finish() {
|
||||
if (!closed) {
|
||||
|
||||
@ -686,6 +686,8 @@ public final class MetricRepo {
|
||||
// node info
|
||||
visitor.getNodeInfo();
|
||||
|
||||
visitor.visitWorkloadGroup();
|
||||
|
||||
return visitor.finish();
|
||||
}
|
||||
|
||||
|
||||
@ -44,6 +44,8 @@ public abstract class MetricVisitor {
|
||||
|
||||
public abstract void getNodeInfo();
|
||||
|
||||
public abstract void visitWorkloadGroup();
|
||||
|
||||
public String finish() {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@ -26,11 +26,14 @@ import org.apache.doris.monitor.jvm.JvmStats.Threads;
|
||||
import com.codahale.metrics.Histogram;
|
||||
import com.codahale.metrics.Snapshot;
|
||||
import com.google.common.base.Joiner;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -41,6 +44,9 @@ import java.util.stream.Collectors;
|
||||
* doris_fe_job{job="load", type="mini", state="pending"} 0
|
||||
*/
|
||||
public class PrometheusMetricVisitor extends MetricVisitor {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(PrometheusMetricVisitor.class);
|
||||
|
||||
// jvm
|
||||
private static final String JVM_HEAP_SIZE_BYTES = "jvm_heap_size_bytes";
|
||||
private static final String JVM_NON_HEAP_SIZE_BYTES = "jvm_non_heap_size_bytes";
|
||||
@ -225,4 +231,27 @@ public class PrometheusMetricVisitor extends MetricVisitor {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitWorkloadGroup() {
|
||||
StringBuilder tmpSb = new StringBuilder();
|
||||
try {
|
||||
String counterTitle = "doris_workload_group_query_detail";
|
||||
tmpSb.append("# HELP " + counterTitle + "\n");
|
||||
tmpSb.append("# TYPE " + counterTitle + " counter\n");
|
||||
Map<String, List<String>> workloadGroupMap = Env.getCurrentEnv().getWorkloadGroupMgr()
|
||||
.getWorkloadGroupQueryDetail();
|
||||
for (Map.Entry<String, List<String>> entry : workloadGroupMap.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
List<String> valList = entry.getValue();
|
||||
tmpSb.append(String.format("%s{name=\"%s\", type=\"%s\"} %s\n", counterTitle, name, "running_query_num",
|
||||
valList.get(0)));
|
||||
tmpSb.append(String.format("%s{name=\"%s\", type=\"%s\"} %s\n", counterTitle, name, "waiting_query_num",
|
||||
valList.get(1)));
|
||||
}
|
||||
sb.append(tmpSb);
|
||||
} catch (Exception e) {
|
||||
logger.warn("error happends when get workload group query detail ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,4 +136,9 @@ public class SimpleCoreMetricVisitor extends MetricVisitor {
|
||||
sb.append("doris_fe_backend_dead_num").append(" ").append(beDeadNum).append("\n");
|
||||
sb.append("doris_fe_broker_dead_num").append(" ").append(brokerDeadNum).append("\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitWorkloadGroup() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,6 +301,31 @@ public class WorkloadGroupMgr extends MasterDaemon implements Writable, GsonPost
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getWorkloadGroupQueryDetail() {
|
||||
Map<String, List<String>> ret = Maps.newHashMap();
|
||||
readLock();
|
||||
try {
|
||||
for (Map.Entry<Long, WorkloadGroup> entry : idToWorkloadGroup.entrySet()) {
|
||||
Long wgId = entry.getKey();
|
||||
WorkloadGroup wg = entry.getValue();
|
||||
QueryQueue qq = idToQueryQueue.get(wgId);
|
||||
List<String> valueList = new ArrayList<>(2);
|
||||
if (qq == null) {
|
||||
valueList.add("0");
|
||||
valueList.add("0");
|
||||
} else {
|
||||
Pair<Integer, Integer> qdtail = qq.getQueryQueueDetail();
|
||||
valueList.add(String.valueOf(qdtail.first));
|
||||
valueList.add(String.valueOf(qdtail.second));
|
||||
}
|
||||
ret.put(wg.getName(), valueList);
|
||||
}
|
||||
} finally {
|
||||
readUnlock();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private String getWorkloadGroupNameAndCheckPriv(ConnectContext context) throws AnalysisException {
|
||||
String groupName = context.getSessionVariable().getWorkloadGroup();
|
||||
if (Strings.isNullOrEmpty(groupName)) {
|
||||
|
||||
Reference in New Issue
Block a user