Skip to content
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
10 changes: 10 additions & 0 deletions fe/fe-core/src/main/java/com/starrocks/metric/MetricRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import com.starrocks.proto.PKafkaOffsetProxyRequest;
import com.starrocks.proto.PKafkaOffsetProxyResult;
import com.starrocks.qe.ConnectContext;
import com.starrocks.qe.QeProcessorImpl;
import com.starrocks.qe.scheduler.slot.BaseSlotManager;
import com.starrocks.server.GlobalStateMgr;
import com.starrocks.server.RunMode;
Expand Down Expand Up @@ -518,6 +519,15 @@ public Long getValue() {
};
STARROCKS_METRIC_REGISTER.addMetric(totalTabletCount);

GaugeMetric<Long> runningSlowQueriesCount = new GaugeMetric<Long>(
"running_slow_query", MetricUnit.NOUNIT, "counter running slow query") {
@Override
public Long getValue() {
return QeProcessorImpl.INSTANCE.runningSlowQueries();
}
};
STARROCKS_METRIC_REGISTER.addMetric(runningSlowQueriesCount);

// 2. counter
COUNTER_REQUEST_ALL = new LongCounterMetric("request_total", MetricUnit.REQUESTS, "total request");
STARROCKS_METRIC_REGISTER.addMetric(COUNTER_REQUEST_ALL);
Expand Down
13 changes: 12 additions & 1 deletion fe/fe-core/src/main/java/com/starrocks/qe/QeProcessorImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ private void scanMonitorQueries() {
}
}

public long runningSlowQueries() {
long slowCount = 0;
long now = System.currentTimeMillis();
for (Map.Entry<TUniqueId, QueryInfo> entry : coordinatorMap.entrySet()) {
if (now - entry.getValue().getStartExecTime() > Config.qe_slow_log_ms) {
slowCount ++;
}
}
return slowCount;
}

@Override
public void monitorQuery(TUniqueId queryId, long expireTime) {
monitorQueryMap.put(queryId, expireTime);
Expand Down Expand Up @@ -365,7 +376,7 @@ public static final class QueryInfo {

private boolean isMVJob = false;

// from Export, Pull load, Insert
// from Export, Pull load, Insert
public QueryInfo(Coordinator coord) {
this(null, null, coord);
}
Expand Down
Loading