use of alluxio.metrics.aggregator.SingleTagValueAggregator in project alluxio by Alluxio.
the class MetricsMasterTest method testMultiValueAggregator.
@Test
public void testMultiValueAggregator() throws Exception {
// Add user tag
String masterMetricName = "Master.TestMetric";
String clusterMetricName = "Cluster.TestMetric";
mMetricsMaster.addAggregator(new SingleTagValueAggregator(clusterMetricName, masterMetricName, MetricInfo.TAG_UFS));
String ufsOne = MetricsSystem.escape(new AlluxioURI("/path/to/ufs"));
String counterNameOne = Metric.getMetricNameWithTags(masterMetricName, MetricInfo.TAG_UFS, ufsOne);
Counter counterOne = MetricsSystem.counter(counterNameOne);
counterOne.inc(10);
String clusterMetricNameOne = Metric.getMetricNameWithTags(clusterMetricName, MetricInfo.TAG_UFS, ufsOne);
assertTrue(MetricsSystem.getMetricValue(clusterMetricNameOne) == null);
HeartbeatScheduler.execute(HeartbeatContext.MASTER_CLUSTER_METRICS_UPDATER);
Metric clusterMetricOne = MetricsSystem.getMetricValue(clusterMetricNameOne);
assertNotNull(clusterMetricOne);
assertEquals(10, (long) clusterMetricOne.getValue());
counterOne.inc(7);
String ufsTwo = MetricsSystem.escape(new AlluxioURI("s3://alluxio-test-metrics/metrics"));
String counterNameTwo = Metric.getMetricNameWithTags(masterMetricName, MetricInfo.TAG_UFS, ufsTwo);
Counter counterTwo = MetricsSystem.counter(counterNameTwo);
counterTwo.inc(50);
HeartbeatScheduler.execute(HeartbeatContext.MASTER_CLUSTER_METRICS_UPDATER);
Metric clusterMetricOne2 = MetricsSystem.getMetricValue(clusterMetricNameOne);
assertNotNull(clusterMetricOne2);
assertEquals(17, (long) clusterMetricOne2.getValue());
Metric clusterMetricTwo = MetricsSystem.getMetricValue(Metric.getMetricNameWithTags(clusterMetricName, MetricInfo.TAG_UFS, ufsTwo));
assertNotNull(clusterMetricTwo);
assertEquals(50, (long) clusterMetricTwo.getValue());
}
use of alluxio.metrics.aggregator.SingleTagValueAggregator in project alluxio by Alluxio.
the class DefaultMetricsMaster method registerAggregators.
private void registerAggregators() {
// worker metrics
registerThroughputGauge(MetricKey.CLUSTER_BYTES_READ_DIRECT.getName(), MetricKey.CLUSTER_BYTES_READ_DIRECT_THROUGHPUT.getName());
registerThroughputGauge(MetricKey.CLUSTER_BYTES_READ_REMOTE.getName(), MetricKey.CLUSTER_BYTES_READ_REMOTE_THROUGHPUT.getName());
registerThroughputGauge(MetricKey.CLUSTER_BYTES_READ_DOMAIN.getName(), MetricKey.CLUSTER_BYTES_READ_DOMAIN_THROUGHPUT.getName());
registerThroughputGauge(MetricKey.CLUSTER_BYTES_WRITTEN_REMOTE.getName(), MetricKey.CLUSTER_BYTES_WRITTEN_REMOTE_THROUGHPUT.getName());
registerThroughputGauge(MetricKey.CLUSTER_BYTES_WRITTEN_DOMAIN.getName(), MetricKey.CLUSTER_BYTES_WRITTEN_DOMAIN_THROUGHPUT.getName());
registerThroughputGauge(MetricKey.CLUSTER_BYTES_READ_UFS_ALL.getName(), MetricKey.CLUSTER_BYTES_READ_UFS_THROUGHPUT.getName());
registerThroughputGauge(MetricKey.CLUSTER_BYTES_WRITTEN_UFS_ALL.getName(), MetricKey.CLUSTER_BYTES_WRITTEN_UFS_THROUGHPUT.getName());
// client metrics
registerThroughputGauge(MetricKey.CLUSTER_BYTES_READ_LOCAL.getName(), MetricKey.CLUSTER_BYTES_READ_LOCAL_THROUGHPUT.getName());
registerThroughputGauge(MetricKey.CLUSTER_BYTES_WRITTEN_LOCAL.getName(), MetricKey.CLUSTER_BYTES_WRITTEN_LOCAL_THROUGHPUT.getName());
// TODO(lu) Create a template for dynamically construct MetricKey
for (MetricInfo.UfsOps ufsOp : MetricInfo.UfsOps.values()) {
addAggregator(new SingleTagValueAggregator(MetricInfo.UFS_OP_PREFIX + ufsOp, MetricsSystem.getMasterMetricName(ufsOp.toString()), MetricInfo.TAG_UFS));
}
}
Aggregations