forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature](merge-cloud) Add several cloud metrics
- Loading branch information
1 parent
5fcc563
commit 61e62b1
Showing
14 changed files
with
388 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
fe/fe-core/src/main/java/org/apache/doris/metric/CloudMetrics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.apache.doris.metric; | ||
|
||
import org.apache.doris.common.Config; | ||
import org.apache.doris.metric.Metric.MetricUnit; | ||
|
||
import com.codahale.metrics.Histogram; | ||
import com.codahale.metrics.MetricRegistry; | ||
|
||
public class CloudMetrics { | ||
protected static String CLOUD_CLUSTER_DELIMITER = "@delimiter#"; | ||
protected static AutoMappedMetric<LongCounterMetric> CLUSTER_REQUEST_ALL_COUNTER; | ||
protected static AutoMappedMetric<LongCounterMetric> CLUSTER_QUERY_ALL_COUNTER; | ||
protected static AutoMappedMetric<LongCounterMetric> CLUSTER_QUERY_ERR_COUNTER; | ||
|
||
protected static AutoMappedMetric<GaugeMetricImpl<Double>> CLUSTER_REQUEST_PER_SECOND_GAUGE; | ||
protected static AutoMappedMetric<GaugeMetricImpl<Double>> CLUSTER_QUERY_PER_SECOND_GAUGE; | ||
protected static AutoMappedMetric<GaugeMetricImpl<Double>> CLUSTER_QUERY_ERR_RATE_GAUGE; | ||
|
||
protected static AutoMappedMetric<Histogram> CLUSTER_QUERY_LATENCY_HISTO; | ||
|
||
protected static AutoMappedMetric<GaugeMetricImpl<Integer>> CLUSTER_BACKEND_ALIVE; | ||
protected static AutoMappedMetric<GaugeMetricImpl<Integer>> CLUSTER_BACKEND_ALIVE_TOTAL; | ||
|
||
protected static void init() { | ||
if (!Config.isCloudMode()) { | ||
return; | ||
} | ||
CLUSTER_REQUEST_ALL_COUNTER = new AutoMappedMetric<>(name -> { | ||
LongCounterMetric counter = new LongCounterMetric("request_total", MetricUnit.REQUESTS, | ||
"total request"); | ||
MetricRepo.DORIS_METRIC_REGISTER.addMetrics(counter); | ||
return counter; | ||
}); | ||
|
||
CLUSTER_QUERY_ALL_COUNTER = new AutoMappedMetric<>(name -> { | ||
LongCounterMetric counter = new LongCounterMetric("query_total", MetricUnit.REQUESTS, | ||
"total query"); | ||
MetricRepo.DORIS_METRIC_REGISTER.addMetrics(counter); | ||
return counter; | ||
}); | ||
|
||
CLUSTER_QUERY_ERR_COUNTER = new AutoMappedMetric<>(name -> { | ||
LongCounterMetric counter = new LongCounterMetric("query_err", MetricUnit.REQUESTS, | ||
"total error query"); | ||
MetricRepo.DORIS_METRIC_REGISTER.addMetrics(counter); | ||
return counter; | ||
}); | ||
|
||
CLUSTER_REQUEST_PER_SECOND_GAUGE = new AutoMappedMetric<>(name -> { | ||
GaugeMetricImpl<Double> gauge = new GaugeMetricImpl<Double>("rps", MetricUnit.NOUNIT, | ||
"request per second"); | ||
MetricRepo.DORIS_METRIC_REGISTER.addMetrics(gauge); | ||
return gauge; | ||
}); | ||
|
||
CLUSTER_QUERY_PER_SECOND_GAUGE = new AutoMappedMetric<>(name -> { | ||
GaugeMetricImpl<Double> gauge = new GaugeMetricImpl<Double>("qps", MetricUnit.NOUNIT, | ||
"query per second"); | ||
MetricRepo.DORIS_METRIC_REGISTER.addMetrics(gauge); | ||
return gauge; | ||
}); | ||
|
||
CLUSTER_QUERY_ERR_RATE_GAUGE = new AutoMappedMetric<>(name -> { | ||
GaugeMetricImpl<Double> gauge = new GaugeMetricImpl<Double>("query_err_rate", MetricUnit.NOUNIT, | ||
"query error rate"); | ||
MetricRepo.DORIS_METRIC_REGISTER.addMetrics(gauge); | ||
return gauge; | ||
}); | ||
|
||
CLUSTER_BACKEND_ALIVE = new AutoMappedMetric<>(name -> { | ||
GaugeMetricImpl<Integer> gauge = new GaugeMetricImpl<Integer>("backend_alive", MetricUnit.NOUNIT, | ||
"backend alive or not"); | ||
MetricRepo.DORIS_METRIC_REGISTER.addMetrics(gauge); | ||
return gauge; | ||
}); | ||
|
||
CLUSTER_BACKEND_ALIVE_TOTAL = new AutoMappedMetric<>(name -> { | ||
GaugeMetricImpl<Integer> gauge = new GaugeMetricImpl<Integer>("backend_alive_total", MetricUnit.NOUNIT, | ||
"backend alive num in cluster"); | ||
MetricRepo.DORIS_METRIC_REGISTER.addMetrics(gauge); | ||
return gauge; | ||
}); | ||
|
||
CLUSTER_QUERY_LATENCY_HISTO = new AutoMappedMetric<>(key -> { | ||
String[] values = key.split(CLOUD_CLUSTER_DELIMITER); | ||
String clusterId = values[0]; | ||
String clusterName = values[1]; | ||
String metricName = MetricRegistry.name("query", "latency", "ms", "cluster_id=" | ||
+ clusterId, "cluster_name=" + clusterName); | ||
return MetricRepo.METRIC_REGISTER.histogram(metricName); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.