This is an automated email from the ASF dual-hosted git repository. lide pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 42f9c217f93 [Metric](FE) add slow query metric (#41800) 42f9c217f93 is described below commit 42f9c217f935ac621aa0d28256b0ece622655c02 Author: shee <13843187+qz...@users.noreply.github.com> AuthorDate: Thu Nov 28 14:45:07 2024 +0800 [Metric](FE) add slow query metric (#41800) --- .../src/main/java/org/apache/doris/metric/MetricCalculator.java | 8 ++++++++ fe/fe-core/src/main/java/org/apache/doris/metric/MetricRepo.java | 6 ++++++ fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java | 1 + 3 files changed, 15 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/metric/MetricCalculator.java b/fe/fe-core/src/main/java/org/apache/doris/metric/MetricCalculator.java index f4beed94b0c..06d206377d7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/metric/MetricCalculator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/metric/MetricCalculator.java @@ -33,6 +33,7 @@ public class MetricCalculator extends TimerTask { private long lastQueryCounter = -1; private long lastRequestCounter = -1; private long lastQueryErrCounter = -1; + private long lastQuerySlowCounter = -1; private Map<String, Long> clusterLastRequestCounter = new HashMap<>(); private Map<String, Long> clusterLastQueryCounter = new HashMap<>(); @@ -50,6 +51,7 @@ public class MetricCalculator extends TimerTask { lastQueryCounter = MetricRepo.COUNTER_QUERY_ALL.getValue(); lastRequestCounter = MetricRepo.COUNTER_REQUEST_ALL.getValue(); lastQueryErrCounter = MetricRepo.COUNTER_QUERY_ERR.getValue(); + lastQuerySlowCounter = MetricRepo.COUNTER_QUERY_SLOW.getValue(); initCloudMetrics(); return; } @@ -74,6 +76,12 @@ public class MetricCalculator extends TimerTask { MetricRepo.GAUGE_QUERY_ERR_RATE.setValue(errRate < 0 ? 0.0 : errRate); lastQueryErrCounter = currentErrCounter; + // slow rate + long currentSlowCounter = MetricRepo.COUNTER_QUERY_SLOW.getValue(); + double slowRate = (double) (currentSlowCounter - lastQuerySlowCounter) / interval; + MetricRepo.GAUGE_QUERY_SLOW_RATE.setValue(slowRate < 0 ? 0.0 : slowRate); + lastQuerySlowCounter = currentSlowCounter; + updateCloudMetrics(interval); lastTs = currentTs; diff --git a/fe/fe-core/src/main/java/org/apache/doris/metric/MetricRepo.java b/fe/fe-core/src/main/java/org/apache/doris/metric/MetricRepo.java index 86741758250..ca731eacf4b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/metric/MetricRepo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/metric/MetricRepo.java @@ -74,6 +74,7 @@ public final class MetricRepo { public static LongCounterMetric COUNTER_REQUEST_ALL; public static LongCounterMetric COUNTER_QUERY_ALL; public static LongCounterMetric COUNTER_QUERY_ERR; + public static LongCounterMetric COUNTER_QUERY_SLOW; public static LongCounterMetric COUNTER_QUERY_TABLE; public static LongCounterMetric COUNTER_QUERY_OLAP_TABLE; public static LongCounterMetric COUNTER_QUERY_HIVE_TABLE; @@ -142,6 +143,7 @@ public final class MetricRepo { public static GaugeMetricImpl<Double> GAUGE_QUERY_PER_SECOND; public static GaugeMetricImpl<Double> GAUGE_REQUEST_PER_SECOND; public static GaugeMetricImpl<Double> GAUGE_QUERY_ERR_RATE; + public static GaugeMetricImpl<Double> GAUGE_QUERY_SLOW_RATE; public static GaugeMetricImpl<Long> GAUGE_MAX_TABLET_COMPACTION_SCORE; private static Map<Pair<EtlJobType, JobState>, Long> loadJobNum = Maps.newHashMap(); @@ -292,6 +294,8 @@ public final class MetricRepo { 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); @@ -303,6 +307,8 @@ public final class MetricRepo { 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, diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java b/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java index 12958d53390..903b72898c9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java @@ -249,6 +249,7 @@ public class AuditLogHelper { if (elapseMs > Config.qe_slow_log_ms) { String sqlDigest = DigestUtils.md5Hex(((Queriable) parsedStmt).toDigest()); auditEventBuilder.setSqlDigest(sqlDigest); + MetricRepo.COUNTER_QUERY_SLOW.increase(1L); } } auditEventBuilder.setIsQuery(true) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org