From 3b882720ad196a52974097e25699e1c8ef4a69f5 Mon Sep 17 00:00:00 2001 From: Adam Zegelin Date: Thu, 20 Feb 2020 18:12:29 -0800 Subject: [PATCH 1/6] Fixed issue where reading exclusions from an external file was broken. --- .../exporter/cli/HarvesterOptionsTest.java | 43 +++++++++++++++++++ .../exporter/cli/HarvesterOptions.java | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 agent/src/test/java/com/zegelin/cassandra/exporter/cli/HarvesterOptionsTest.java diff --git a/agent/src/test/java/com/zegelin/cassandra/exporter/cli/HarvesterOptionsTest.java b/agent/src/test/java/com/zegelin/cassandra/exporter/cli/HarvesterOptionsTest.java new file mode 100644 index 0000000..ba2cb59 --- /dev/null +++ b/agent/src/test/java/com/zegelin/cassandra/exporter/cli/HarvesterOptionsTest.java @@ -0,0 +1,43 @@ +package com.zegelin.cassandra.exporter.cli; + +import com.google.common.collect.ImmutableSet; +import com.zegelin.cassandra.exporter.Harvester; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.testng.Assert.*; + +public class HarvesterOptionsTest { + + static Set exclusionStrings = ImmutableSet.of("test_collector", "test:mbean=foo"); + static Set exclusions = exclusionStrings.stream() + .map(Harvester.Exclusion::create) + .collect(Collectors.toSet()); + + @org.testng.annotations.Test + public void testSetExclusions() { + final HarvesterOptions harvesterOptions = new HarvesterOptions(); + + harvesterOptions.setExclusions(exclusionStrings); + + assertEquals(harvesterOptions.exclusions, exclusions); + } + + @Test + public void testSetExclusionsFromFile() throws IOException { + final Path tempFile = Files.createTempFile(null, null); + + Files.write(tempFile, exclusionStrings); + + final HarvesterOptions harvesterOptions = new HarvesterOptions(); + + harvesterOptions.setExclusions(ImmutableSet.of(String.format("@%s", tempFile))); + + assertEquals(harvesterOptions.exclusions, exclusions); + } +} \ No newline at end of file diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java b/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java index 580b0e4..dea9e82 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java @@ -46,7 +46,7 @@ void setExclusions(final Set values) { Files.lines(file) .filter(line -> !line.startsWith("#")) .map(String::trim) - .filter(String::isEmpty) + .filter(line -> !line.isEmpty()) .forEach(line -> this.exclusions.add(Harvester.Exclusion.create(line))); processedExclusionFiles.add(file); From 6a417ae9692e3b0d216d449ea5a30f113e49be5e Mon Sep 17 00:00:00 2001 From: n660955 Date: Wed, 4 Mar 2020 18:38:15 +0530 Subject: [PATCH 2/6] More options added Enhanced code to filter quantiles based on user choice Included --cql-ssl option to crated encrypted native connection Added latest version of jars as the older version are having some vulnerabilities --- common/pom.xml | 2 +- .../exporter/CollectorFunctions.java | 41 +++++++++---- .../cassandra/exporter/FactoriesSupplier.java | 59 ++++++++++--------- .../zegelin/cassandra/exporter/Harvester.java | 7 +++ .../exporter/cli/HarvesterOptions.java | 24 ++++++++ .../LatencyMetricGroupSummaryCollector.java | 32 +++++++--- .../zegelin/prometheus/domain/Interval.java | 12 +++- standalone/pom.xml | 2 +- .../cassandra/exporter/Application.java | 7 ++- 9 files changed, 136 insertions(+), 50 deletions(-) diff --git a/common/pom.xml b/common/pom.xml index 942efd0..3e72a58 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -14,7 +14,7 @@ Cassandra Exporter Common - 3.6.1 + 3.9.5 diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/CollectorFunctions.java b/common/src/main/java/com/zegelin/cassandra/exporter/CollectorFunctions.java index 6455bee..61f1ed5 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/CollectorFunctions.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/CollectorFunctions.java @@ -1,15 +1,24 @@ package com.zegelin.cassandra.exporter; import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import com.zegelin.function.FloatFloatFunction; import com.zegelin.cassandra.exporter.collector.dynamic.FunctionalMetricFamilyCollector.CollectorFunction; import com.zegelin.cassandra.exporter.collector.dynamic.FunctionalMetricFamilyCollector.LabeledObjectGroup; import com.zegelin.prometheus.domain.*; +import com.zegelin.prometheus.domain.Interval.Quantile; + import org.apache.cassandra.metrics.CassandraMetricsRegistry.JmxCounterMBean; import org.apache.cassandra.metrics.CassandraMetricsRegistry.JmxGaugeMBean; import org.apache.cassandra.metrics.CassandraMetricsRegistry.JmxMeterMBean; import org.apache.cassandra.utils.EstimatedHistogram; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; import java.util.stream.Stream; public final class CollectorFunctions { @@ -124,7 +133,8 @@ public static CollectorFunction numericGaugeAsCounter() { /** * Collect a {@link JmxGaugeMBean} with a Cassandra {@link EstimatedHistogram} value as a Prometheus summary */ - public static CollectorFunction histogramGaugeAsSummary(final FloatFloatFunction bucketScaleFunction) { + public static CollectorFunction histogramGaugeAsSummary(final FloatFloatFunction bucketScaleFunction,Set excludeQuantiles) { + Set includedQuantiles =excludeQuantiles==null?Interval.Quantile.STANDARD_PERCENTILES:Sets.difference(Interval.Quantile.STANDARD_PERCENTILES,excludeQuantiles); return group -> { final Stream summaryStream = group.labeledObjects().entrySet().stream() .map(e -> new Object() { @@ -135,12 +145,11 @@ public static CollectorFunction histogramGaugeAsSummary(final Flo final long[] bucketData = (long[]) e.gauge.getValue(); if (bucketData.length == 0) { - return new SummaryMetricFamily.Summary(e.labels, Float.NaN, Float.NaN, Interval.asIntervals(Interval.Quantile.STANDARD_PERCENTILES, q -> Float.NaN)); + return new SummaryMetricFamily.Summary(e.labels, Float.NaN, Float.NaN, Interval.asIntervals(includedQuantiles, q -> Float.NaN)); } final EstimatedHistogram histogram = new EstimatedHistogram(bucketData); - - final Iterable quantiles = Interval.asIntervals(Interval.Quantile.STANDARD_PERCENTILES, q -> bucketScaleFunction.apply((float) histogram.percentile(q.value))); + final Iterable quantiles = Interval.asIntervals(includedQuantiles, q -> bucketScaleFunction.apply((float) histogram.percentile(q.value))); return new SummaryMetricFamily.Summary(e.labels, Float.NaN, histogram.count(), quantiles); }); @@ -149,14 +158,14 @@ public static CollectorFunction histogramGaugeAsSummary(final Flo }; } - public static CollectorFunction histogramGaugeAsSummary() { - return histogramGaugeAsSummary(l -> l); + public static CollectorFunction histogramGaugeAsSummary(Set excludeQuantiles) { + return histogramGaugeAsSummary((l -> l),excludeQuantiles); } /** * Collect a {@link SamplingCounting} as a Prometheus summary */ - protected static CollectorFunction samplingAndCountingAsSummary(final FloatFloatFunction quantileScaleFunction) { + protected static CollectorFunction samplingAndCountingAsSummary(final FloatFloatFunction quantileScaleFunction,Set excludeQuantiles) { return group -> { final Stream summaryStream = group.labeledObjects().entrySet().stream() .map(e -> new Object() { @@ -164,8 +173,18 @@ protected static CollectorFunction samplingAndCountingAsSummar final SamplingCounting samplingCounting = e.getValue(); }) .map(e -> { - final Iterable quantiles = Iterables.transform(e.samplingCounting.getIntervals(), i -> i.transform(quantileScaleFunction)); - + + Iterator itr = e.samplingCounting.getIntervals().iterator(); + ArrayList filtered = Lists.newArrayList(); + while(itr.hasNext()) { + Interval interval = itr.next(); + if(excludeQuantiles.contains(interval.quantile)) { + continue; + } + filtered.add(interval); + } + + final Iterable quantiles = Iterables.transform(filtered, i -> i.transform(quantileScaleFunction)); return new SummaryMetricFamily.Summary(e.labels, Float.NaN, e.samplingCounting.getCount(), quantiles); }); @@ -173,7 +192,7 @@ protected static CollectorFunction samplingAndCountingAsSummar }; } - public static CollectorFunction samplingAndCountingAsSummary() { - return samplingAndCountingAsSummary(FloatFloatFunction.identity()); + public static CollectorFunction samplingAndCountingAsSummary(Set excludeQuantiles) { + return samplingAndCountingAsSummary(FloatFloatFunction.identity(),excludeQuantiles); } } diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/FactoriesSupplier.java b/common/src/main/java/com/zegelin/cassandra/exporter/FactoriesSupplier.java index 5539d2b..93a47e2 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/FactoriesSupplier.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/FactoriesSupplier.java @@ -11,6 +11,7 @@ import com.zegelin.cassandra.exporter.collector.dynamic.FunctionalMetricFamilyCollector; import com.zegelin.cassandra.exporter.collector.jvm.*; import com.zegelin.prometheus.domain.Labels; +import com.zegelin.prometheus.domain.Interval.Quantile; import javax.management.*; import java.util.*; @@ -36,6 +37,7 @@ private static class FactoryBuilder { private final CollectorConstructor collectorConstructor; private final QueryExp objectNameQuery; private final String metricFamilyName; + private Set excludeQuantiles; private String help; @@ -56,10 +58,11 @@ interface LabelMaker extends Function, Map> private final List modifiers = new LinkedList<>(); - FactoryBuilder(final CollectorConstructor collectorConstructor, final QueryExp objectNameQuery, final String metricFamilyName) { + FactoryBuilder(final CollectorConstructor collectorConstructor, final QueryExp objectNameQuery, final String metricFamilyName,Set excludeQuantiles) { this.collectorConstructor = collectorConstructor; this.objectNameQuery = objectNameQuery; this.metricFamilyName = metricFamilyName; + this.excludeQuantiles=excludeQuantiles; } FactoryBuilder withModifier(final Modifier modifier) { @@ -101,13 +104,13 @@ Factory build() { } } - return collectorConstructor.groupCollectorForMBean(name, help, new Labels(rawLabels), mBean); + return collectorConstructor.groupCollectorForMBean(name, help, new Labels(rawLabels), mBean,excludeQuantiles); }; } @FunctionalInterface public interface CollectorConstructor { - MBeanGroupMetricFamilyCollector groupCollectorForMBean(final String name, final String help, final Labels labels, final NamedObject mBean); + MBeanGroupMetricFamilyCollector groupCollectorForMBean(final String name, final String help, final Labels labels, final NamedObject mBean,Set excludeQuantiles); } } @@ -116,6 +119,7 @@ public interface CollectorConstructor { private final Set tableLabels; private final Set excludedKeyspaces; private final Map tableMetricScopeFilters; + private final Set excludeQuantiles; public FactoriesSupplier(final MetadataFactory metadataFactory, final HarvesterOptions options) { @@ -123,6 +127,7 @@ public FactoriesSupplier(final MetadataFactory metadataFactory, final HarvesterO this.perThreadTimingEnabled = options.perThreadTimingEnabled; this.tableLabels = options.tableLabels; this.excludedKeyspaces = options.excludedKeyspaces; + excludeQuantiles=options.excludedHistoQuantiles; this.tableMetricScopeFilters = ImmutableMap.builder() .put(TableMetricScope.NODE, options.nodeMetricsFilter) @@ -136,7 +141,7 @@ private Factory bufferPoolMetricFactory(final FactoryBuilder.CollectorConstructo final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=BufferPool,name=%s", jmxName); final String metricFamilyName = String.format("buffer_pool_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) .withHelp(help) .build(); } @@ -150,7 +155,7 @@ private Factory cqlMetricFactory(final FactoryBuilder.CollectorConstructor colle final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=CQL,name=%s", jmxName); final String metricFamilyName = String.format("cql_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) .withHelp(help) .withLabelMaker(keyPropertyList -> labels) .build(); @@ -161,7 +166,7 @@ private Factory cacheMetricFactory(final FactoryBuilder.CollectorConstructor col final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Cache,scope=*,name=%s", jmxName); final String metricFamilyName = String.format("cache_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) .withHelp(help) .withLabelMaker(keyPropertyList -> ImmutableMap.of( "cache", keyPropertyList.get("scope").replaceAll("Cache", "").toLowerCase() @@ -174,7 +179,7 @@ private Factory clientMetricFactory(final FactoryBuilder.CollectorConstructor co final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Client,name=%s", jmxName); final String metricFamilyName = String.format("client_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) .withHelp(help) .build(); } @@ -183,7 +188,7 @@ private Factory clientRequestMetricFactory(final FactoryBuilder.CollectorConstru final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=ClientRequest,name=%s,scope=*", jmxName); final String metricFamilyName = String.format("client_request_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) .withHelp(help) .withModifier((keyPropertyList, labels) -> { final String scope = keyPropertyList.get("scope"); @@ -216,7 +221,7 @@ private Factory commitLogMetricFactory(final FactoryBuilder.CollectorConstructor final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=CommitLog,name=%s", jmxName); final String metricFamilyName = String.format("commit_log_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) .withHelp(help) .build(); } @@ -225,7 +230,7 @@ private Factory messagingMetricFactory(final FactoryBuilder.CollectorConstructor final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Messaging,name=%s", jmxName); final String metricFamilyName = String.format("messaging_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) .withHelp(help) .withLabelMaker(keyPropertyList -> { final String name = keyPropertyList.get("name"); @@ -245,7 +250,7 @@ private Factory memtablePoolMetricsFactory(final FactoryBuilder.CollectorConstru final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=MemtablePool,name=%s", jmxName); final String metricFamilyName = String.format("memtable_pool_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) .withHelp(help) .build(); } @@ -254,7 +259,7 @@ private Factory storageMetric(final FactoryBuilder.CollectorConstructor collecto final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Storage,name=%s", jmxName); final String metricFamilyName = String.format("storage_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) .withHelp(help) .build(); } @@ -359,7 +364,7 @@ private Iterator tableMetricFactory(final Set tableMe final QueryExp query = scope.query(jmxName); final String metricFamilyName = String.format(scope.metricFamilyNameFormat, familyNameSuffix); - return new FactoryBuilder(collectorConstructor, query, metricFamilyName) + return new FactoryBuilder(collectorConstructor, query, metricFamilyName, excludeQuantiles) .withHelp(help) .withModifier((keyPropertyList, labels) -> { labels.putAll(extraLabels); @@ -425,7 +430,7 @@ private Factory threadPoolMetric(final FactoryBuilder.CollectorConstructor colle final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=ThreadPools,path=*,scope=*,name=%s", jmxName); final String metricFamilyName = String.format("thread_pool_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) .withHelp(help) .withLabelMaker(keyPropertyList -> ImmutableMap.of( "group", keyPropertyList.get("path"), @@ -438,14 +443,14 @@ private Factory rowIndexMetric(final FactoryBuilder.CollectorConstructor collect final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Index,scope=RowIndexEntry,name=%s", jmxName); final String metricFamilyName = String.format("row_index_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName).build(); + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles).build(); } private Factory droppedMessagesMetric(final FactoryBuilder.CollectorConstructor collectorConstructor, final String jmxName, final String familyNameSuffix, final String help) { final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=DroppedMessage,scope=*,name=%s", jmxName); final String metricFamilyName = String.format("dropped_messages_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) .withHelp(help) .withLabelMaker(keyPropertyList -> ImmutableMap.of("message_type", keyPropertyList.get("scope"))) .build(); @@ -455,7 +460,7 @@ private Factory compactionMetric(final FactoryBuilder.CollectorConstructor colle final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Compaction,name=%s", jmxName); final String metricFamilyName = String.format("compaction_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) .withHelp(help) .build(); } @@ -464,7 +469,7 @@ private Factory connectionMetric(final FactoryBuilder.CollectorConstructor colle final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Connection,scope=*,name=%s", jmxName); final String metricFamilyName = String.format("endpoint_connection_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) .withHelp(help) .withLabelMaker(keyPropertyList -> { final HashMap labels = new HashMap<>(); @@ -492,26 +497,26 @@ private Factory connectionMetric(final FactoryBuilder.CollectorConstructor colle } - private static FactoryBuilder.CollectorConstructor timerAsSummaryCollectorConstructor() { - return (name, help, labels, mBean) -> { + private FactoryBuilder.CollectorConstructor timerAsSummaryCollectorConstructor() { + return (name, help, labels, mBean, excludeQuantiles) -> { final NamedObject samplingCountingNamedObject = CassandraMetricsUtilities.jmxTimerMBeanAsSamplingCounting(mBean); return new FunctionalMetricFamilyCollector<>(name, help, ImmutableMap.of(labels, samplingCountingNamedObject), - samplingAndCountingAsSummary(MetricValueConversionFunctions::nanosecondsToSeconds)); + samplingAndCountingAsSummary(MetricValueConversionFunctions::nanosecondsToSeconds,excludeQuantiles)); }; } - private static FactoryBuilder.CollectorConstructor histogramAsSummaryCollectorConstructor() { - return (name, help, labels, mBean) -> { + private FactoryBuilder.CollectorConstructor histogramAsSummaryCollectorConstructor() { + return (name, help, labels, mBean,excludeQuantiles) -> { final NamedObject samplingCountingNamedObject = CassandraMetricsUtilities.jmxHistogramAsSamplingCounting(mBean); - return new FunctionalMetricFamilyCollector<>(name, help, ImmutableMap.of(labels, samplingCountingNamedObject), samplingAndCountingAsSummary()); + return new FunctionalMetricFamilyCollector<>(name, help, ImmutableMap.of(labels, samplingCountingNamedObject), samplingAndCountingAsSummary(excludeQuantiles)); }; } private static FactoryBuilder.CollectorConstructor functionalCollectorConstructor(final FunctionalMetricFamilyCollector.CollectorFunction function) { - return (final String name, final String help, final Labels labels, final NamedObject mBean) -> + return (final String name, final String help, final Labels labels, final NamedObject mBean,Set excludeQuantiles) -> new FunctionalMetricFamilyCollector<>(name, help, ImmutableMap.of(labels, mBean.cast()), function); } @@ -700,10 +705,10 @@ public List get() { builder.addAll(tableMetricFactory(functionalCollectorConstructor(numericGaugeAsGauge(MetricValueConversionFunctions::neg1ToNaN)), "CompressionRatio", "compression_ratio", null)); - builder.addAll(tableMetricFactory(functionalCollectorConstructor(histogramGaugeAsSummary()), "EstimatedPartitionSizeHistogram", "estimated_partition_size_bytes", null)); + builder.addAll(tableMetricFactory(functionalCollectorConstructor(histogramGaugeAsSummary(excludeQuantiles)), "EstimatedPartitionSizeHistogram", "estimated_partition_size_bytes", null)); builder.addAll(tableMetricFactory(functionalCollectorConstructor(numericGaugeAsGauge(MetricValueConversionFunctions::neg1ToNaN)), "EstimatedPartitionCount", "estimated_partitions", null)); - builder.addAll(tableMetricFactory(functionalCollectorConstructor(histogramGaugeAsSummary()), "EstimatedColumnCountHistogram", "estimated_columns", null)); + builder.addAll(tableMetricFactory(functionalCollectorConstructor(histogramGaugeAsSummary(excludeQuantiles)), "EstimatedColumnCountHistogram", "estimated_columns", null)); builder.addAll(tableMetricFactory(histogramAsSummaryCollectorConstructor(), "SSTablesPerReadHistogram", "sstables_per_read", null)); // diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/Harvester.java b/common/src/main/java/com/zegelin/cassandra/exporter/Harvester.java index ae433c9..bb99d28 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/Harvester.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/Harvester.java @@ -7,6 +7,7 @@ import com.zegelin.jmx.NamedObject; import com.zegelin.cassandra.exporter.cli.HarvesterOptions; import com.zegelin.prometheus.domain.CounterMetricFamily; +import com.zegelin.prometheus.domain.Interval.Quantile; import com.zegelin.prometheus.domain.Labels; import com.zegelin.prometheus.domain.MetricFamily; import com.zegelin.prometheus.domain.NumericMetric; @@ -132,6 +133,7 @@ public boolean equals(final Object o) { private final boolean collectorTimingEnabled; private final Map collectionTimes = new ConcurrentHashMap<>(); + private final Set excludedHistoQuantiles; private final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder() .setNameFormat("cassandra-exporter-harvester-defer-%d") @@ -145,6 +147,11 @@ protected Harvester(final MetadataFactory metadataFactory, final HarvesterOption this.exclusions = options.exclusions; this.enabledGlobalLabels = options.globalLabels; this.collectorTimingEnabled = options.collectorTimingEnabled; + this.excludedHistoQuantiles=options.excludedHistoQuantiles; + } + + public Set getExcludedHistoQuantiles() { + return excludedHistoQuantiles; } protected void addCollectorFactory(final MBeanGroupMetricFamilyCollector.Factory factory) { diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java b/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java index dea9e82..a7d97b1 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java @@ -2,6 +2,7 @@ import com.google.common.collect.ImmutableSet; import com.zegelin.netty.Floats; +import com.zegelin.prometheus.domain.Interval.Quantile; import com.zegelin.cassandra.exporter.FactoriesSupplier; import com.zegelin.cassandra.exporter.Harvester; import picocli.CommandLine; @@ -152,4 +153,27 @@ public void setExcludeSystemTables(final boolean excludeSystemTables) { excludedKeyspaces.addAll(CASSANDRA_SYSTEM_KEYSPACES); } + + public Set excludedHistoQuantiles = new HashSet<>(); + @Option(names = {"--exclude-from-histogram"}, paramLabel = "EXCLUSION", arity = "1..*", + description = "Select which quantiles to exclude from histogram metrics. The specified quantiles are excluded from all histogram/summary metrics" + + "Valid options are: P_50, P_75, P_95, P_98, P_99, P_99_9" + + "'P_50' (Quantile .5), " + + "'P_75' (Quantile .75), " + + "'P_95' (Quantile .95), " + + "'P_98' (Quantile .98). " + + "'P_99' (Quantile .99). " + + "'P_99_9' (Quantile .999). " + + "The default is to include all quantiles. " + ) + void setExcludeFromHistogram(final Set values) { + values.forEach(e->{ + Quantile q=Quantile.ALL_PERCENTILES.get(e); + if(q==null) { + throw new IllegalArgumentException(String.format("The specified exlusion quantile '%s' is invalid, value values are '%s'", e,Quantile.ALL_PERCENTILES.keySet())); + } + excludedHistoQuantiles.add(q); + }); + } + } diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/collector/LatencyMetricGroupSummaryCollector.java b/common/src/main/java/com/zegelin/cassandra/exporter/collector/LatencyMetricGroupSummaryCollector.java index c7aacb3..d6520fe 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/collector/LatencyMetricGroupSummaryCollector.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/collector/LatencyMetricGroupSummaryCollector.java @@ -2,11 +2,13 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import com.zegelin.jmx.NamedObject; import com.zegelin.cassandra.exporter.MBeanGroupMetricFamilyCollector; import com.zegelin.cassandra.exporter.MetricValueConversionFunctions; import com.zegelin.cassandra.exporter.SamplingCounting; import com.zegelin.prometheus.domain.Interval; +import com.zegelin.prometheus.domain.Interval.Quantile; import com.zegelin.prometheus.domain.Labels; import com.zegelin.prometheus.domain.MetricFamily; import com.zegelin.prometheus.domain.SummaryMetricFamily; @@ -14,8 +16,12 @@ import org.apache.cassandra.metrics.CassandraMetricsRegistry.JmxTimerMBean; import javax.management.ObjectName; + +import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; +import java.util.Set; import java.util.stream.Stream; import static com.zegelin.cassandra.exporter.CassandraMetricsUtilities.jmxTimerMBeanAsSamplingCounting; @@ -73,21 +79,23 @@ LatencyMetricGroup removeMBean(final ObjectName objectName) { private final String name; private final String help; private final Map latencyMetricGroups; + private final Set excludeQuantiles; - private LatencyMetricGroupSummaryCollector(final String name, final String help, final Map latencyMetricGroups) { + private LatencyMetricGroupSummaryCollector(final String name, final String help, final Map latencyMetricGroups, Set excludeQuantiles) { this.name = name; this.help = help; this.latencyMetricGroups = ImmutableMap.copyOf(latencyMetricGroups); + this.excludeQuantiles=excludeQuantiles; } - public static LatencyMetricGroupSummaryCollector collectorForMBean(final String name, final String help, final Labels labels, final NamedObject mBean) { + public static LatencyMetricGroupSummaryCollector collectorForMBean(final String name, final String help, final Labels labels, final NamedObject mBean,Set excludeQuantiles) { final NamedObject timer = (mBean.object instanceof JmxTimerMBean) ? jmxTimerMBeanAsSamplingCounting(mBean) : null; final NamedObject counter = mBean.map((n, o) -> (o instanceof JmxCounterMBean) ? (JmxCounterMBean) o : null); final LatencyMetricGroup latencyMetricGroup = new LatencyMetricGroup(timer, counter); - return new LatencyMetricGroupSummaryCollector(name, help, ImmutableMap.of(labels, latencyMetricGroup)); + return new LatencyMetricGroupSummaryCollector(name, help, ImmutableMap.of(labels, latencyMetricGroup),excludeQuantiles); } @Override @@ -108,7 +116,7 @@ public MBeanGroupMetricFamilyCollector merge(final MBeanGroupMetricFamilyCollect newLatencyMetricGroups.merge(group.getKey(), group.getValue(), LatencyMetricGroup::merge); } - return new LatencyMetricGroupSummaryCollector(name, help, newLatencyMetricGroups); + return new LatencyMetricGroupSummaryCollector(name, help, newLatencyMetricGroups,excludeQuantiles); } @Override @@ -129,7 +137,7 @@ public MBeanGroupMetricFamilyCollector removeMBean(final ObjectName mBeanName) { return null; } - return new LatencyMetricGroupSummaryCollector(name, help, newLatencyMetricGroups); + return new LatencyMetricGroupSummaryCollector(name, help, newLatencyMetricGroups,excludeQuantiles); } @Override @@ -144,10 +152,20 @@ public Stream collect() { final float count = e.latencyMetricGroup.latencyTimer.object.getCount(); final float sum = microsecondsToSeconds(e.latencyMetricGroup.totalLatencyCounter.object.getCount()); - final Iterable quantiles = Iterables.transform(e.latencyMetricGroup.latencyTimer.object.getIntervals(), + Iterator itr=e.latencyMetricGroup.latencyTimer.object.getIntervals().iterator(); + ArrayList filtered = Lists.newArrayList(); + while(itr.hasNext()) { + Interval interval = itr.next(); + if(excludeQuantiles.contains(interval.quantile)) { + continue; + } + filtered.add(interval); + } + + final Iterable quantiles = Iterables.transform(filtered, i -> i.transform(MetricValueConversionFunctions::nanosecondsToSeconds) ); - + return new SummaryMetricFamily.Summary(e.labels, sum, count, quantiles); }); diff --git a/common/src/main/java/com/zegelin/prometheus/domain/Interval.java b/common/src/main/java/com/zegelin/prometheus/domain/Interval.java index 1394ded..ec9b191 100644 --- a/common/src/main/java/com/zegelin/prometheus/domain/Interval.java +++ b/common/src/main/java/com/zegelin/prometheus/domain/Interval.java @@ -1,13 +1,13 @@ package com.zegelin.prometheus.domain; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.zegelin.function.FloatFloatFunction; +import java.util.Map; import java.util.Set; import java.util.function.Function; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; /* A Summary quanitle or Histogram bucket and associated value. @@ -23,6 +23,14 @@ public static class Quantile { public static final Set STANDARD_PERCENTILES = ImmutableSet.of(P_50, P_75, P_95, P_98, P_99, P_99_9); public static final Quantile POSITIVE_INFINITY = q(Float.POSITIVE_INFINITY); + public static final Map ALL_PERCENTILES = new ImmutableMap.Builder() + .put("P_50",P_50) + .put("P_75",P_75) + .put("P_95",P_95) + .put("P_98",P_98) + .put("P_99",P_99) + .put("P_99_9",P_99_9) + .build(); public final float value; diff --git a/standalone/pom.xml b/standalone/pom.xml index d539c16..7e30203 100644 --- a/standalone/pom.xml +++ b/standalone/pom.xml @@ -16,7 +16,7 @@ 18.0 3.4.0 - 4.0.47.Final + 4.0.56.Final 1.2.3 1.7.16 diff --git a/standalone/src/main/java/com/zegelin/cassandra/exporter/Application.java b/standalone/src/main/java/com/zegelin/cassandra/exporter/Application.java index 4ceb30e..4d1daab 100644 --- a/standalone/src/main/java/com/zegelin/cassandra/exporter/Application.java +++ b/standalone/src/main/java/com/zegelin/cassandra/exporter/Application.java @@ -6,7 +6,6 @@ import com.datastax.driver.core.policies.RoundRobinPolicy; import com.datastax.driver.core.policies.WhiteListPolicy; import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import com.zegelin.picocli.InetSocketAddressTypeConverter; import com.zegelin.picocli.JMXServiceURLTypeConverter; import com.zegelin.cassandra.exporter.cli.HarvesterOptions; @@ -78,6 +77,9 @@ protected int defaultPort() { @Option(names = "--cql-password", paramLabel = "PASSWORD", description = "CQL authentication password.") private String cqlPassword; + + @Option(names = "--cql-ssl", paramLabel = "PASSWORD", description = "Native connection to be encrypted") + private boolean ssl; @Option(names = {"-v", "--verbose"}, description = "Enable verbose logging. Multiple invocations increase the verbosity.") boolean[] verbosity = {}; @@ -145,6 +147,9 @@ private Cluster establishClusterConnection() { if (cqlUser != null && cqlPassword != null) { clusterBuilder.withCredentials(cqlUser, cqlPassword); } + if(ssl) { + clusterBuilder.withSSL(); + } final Cluster cluster = clusterBuilder.build(); From 858f9a5c33b8cead5d252722bb20fbb8441581a3 Mon Sep 17 00:00:00 2001 From: n660955 Date: Wed, 4 Mar 2020 18:49:44 +0530 Subject: [PATCH 3/6] Used netty 4.1.42.Final Used netty 4.1.42.Final to be inline with another PR --- standalone/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/standalone/pom.xml b/standalone/pom.xml index 7e30203..fc6ea01 100644 --- a/standalone/pom.xml +++ b/standalone/pom.xml @@ -16,7 +16,7 @@ 18.0 3.4.0 - 4.0.56.Final + 4.1.42.Final 1.2.3 1.7.16 From b5b15ed538aa8bb18718ac584a411efe4bb58919 Mon Sep 17 00:00:00 2001 From: n660955 Date: Thu, 5 Mar 2020 10:50:00 +0530 Subject: [PATCH 4/6] Addressed all review comments Applied quantile filtering while writing metrics into socket. Corrected formating. Reverted netty jar version changes. --- .../exporter/CollectorFunctions.java | 43 ++++--------- .../cassandra/exporter/FactoriesSupplier.java | 61 +++++++++---------- .../zegelin/cassandra/exporter/Harvester.java | 2 +- .../exporter/cli/HarvesterOptions.java | 2 +- .../LatencyMetricGroupSummaryCollector.java | 34 +++-------- .../cassandra/exporter/netty/HttpHandler.java | 2 +- .../exposition/text/TextFormatExposition.java | 11 ++-- .../text/TextFormatMetricFamilyWriter.java | 15 ++++- standalone/pom.xml | 2 +- .../cassandra/exporter/Application.java | 2 +- 10 files changed, 72 insertions(+), 102 deletions(-) diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/CollectorFunctions.java b/common/src/main/java/com/zegelin/cassandra/exporter/CollectorFunctions.java index 61f1ed5..b48d498 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/CollectorFunctions.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/CollectorFunctions.java @@ -1,24 +1,15 @@ package com.zegelin.cassandra.exporter; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; import com.zegelin.function.FloatFloatFunction; import com.zegelin.cassandra.exporter.collector.dynamic.FunctionalMetricFamilyCollector.CollectorFunction; import com.zegelin.cassandra.exporter.collector.dynamic.FunctionalMetricFamilyCollector.LabeledObjectGroup; import com.zegelin.prometheus.domain.*; -import com.zegelin.prometheus.domain.Interval.Quantile; - import org.apache.cassandra.metrics.CassandraMetricsRegistry.JmxCounterMBean; import org.apache.cassandra.metrics.CassandraMetricsRegistry.JmxGaugeMBean; import org.apache.cassandra.metrics.CassandraMetricsRegistry.JmxMeterMBean; import org.apache.cassandra.utils.EstimatedHistogram; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; import java.util.stream.Stream; public final class CollectorFunctions { @@ -133,8 +124,7 @@ public static CollectorFunction numericGaugeAsCounter() { /** * Collect a {@link JmxGaugeMBean} with a Cassandra {@link EstimatedHistogram} value as a Prometheus summary */ - public static CollectorFunction histogramGaugeAsSummary(final FloatFloatFunction bucketScaleFunction,Set excludeQuantiles) { - Set includedQuantiles =excludeQuantiles==null?Interval.Quantile.STANDARD_PERCENTILES:Sets.difference(Interval.Quantile.STANDARD_PERCENTILES,excludeQuantiles); + public static CollectorFunction histogramGaugeAsSummary(final FloatFloatFunction bucketScaleFunction) { return group -> { final Stream summaryStream = group.labeledObjects().entrySet().stream() .map(e -> new Object() { @@ -145,11 +135,12 @@ public static CollectorFunction histogramGaugeAsSummary(final Flo final long[] bucketData = (long[]) e.gauge.getValue(); if (bucketData.length == 0) { - return new SummaryMetricFamily.Summary(e.labels, Float.NaN, Float.NaN, Interval.asIntervals(includedQuantiles, q -> Float.NaN)); + return new SummaryMetricFamily.Summary(e.labels, Float.NaN, Float.NaN, Interval.asIntervals(Interval.Quantile.STANDARD_PERCENTILES, q -> Float.NaN)); } final EstimatedHistogram histogram = new EstimatedHistogram(bucketData); - final Iterable quantiles = Interval.asIntervals(includedQuantiles, q -> bucketScaleFunction.apply((float) histogram.percentile(q.value))); + + final Iterable quantiles = Interval.asIntervals(Interval.Quantile.STANDARD_PERCENTILES, q -> bucketScaleFunction.apply((float) histogram.percentile(q.value))); return new SummaryMetricFamily.Summary(e.labels, Float.NaN, histogram.count(), quantiles); }); @@ -158,14 +149,14 @@ public static CollectorFunction histogramGaugeAsSummary(final Flo }; } - public static CollectorFunction histogramGaugeAsSummary(Set excludeQuantiles) { - return histogramGaugeAsSummary((l -> l),excludeQuantiles); + public static CollectorFunction histogramGaugeAsSummary() { + return histogramGaugeAsSummary(l -> l); } /** * Collect a {@link SamplingCounting} as a Prometheus summary */ - protected static CollectorFunction samplingAndCountingAsSummary(final FloatFloatFunction quantileScaleFunction,Set excludeQuantiles) { + protected static CollectorFunction samplingAndCountingAsSummary(final FloatFloatFunction quantileScaleFunction) { return group -> { final Stream summaryStream = group.labeledObjects().entrySet().stream() .map(e -> new Object() { @@ -173,18 +164,8 @@ protected static CollectorFunction samplingAndCountingAsSummar final SamplingCounting samplingCounting = e.getValue(); }) .map(e -> { - - Iterator itr = e.samplingCounting.getIntervals().iterator(); - ArrayList filtered = Lists.newArrayList(); - while(itr.hasNext()) { - Interval interval = itr.next(); - if(excludeQuantiles.contains(interval.quantile)) { - continue; - } - filtered.add(interval); - } - - final Iterable quantiles = Iterables.transform(filtered, i -> i.transform(quantileScaleFunction)); + final Iterable quantiles = Iterables.transform(e.samplingCounting.getIntervals(), i -> i.transform(quantileScaleFunction)); + return new SummaryMetricFamily.Summary(e.labels, Float.NaN, e.samplingCounting.getCount(), quantiles); }); @@ -192,7 +173,7 @@ protected static CollectorFunction samplingAndCountingAsSummar }; } - public static CollectorFunction samplingAndCountingAsSummary(Set excludeQuantiles) { - return samplingAndCountingAsSummary(FloatFloatFunction.identity(),excludeQuantiles); + public static CollectorFunction samplingAndCountingAsSummary() { + return samplingAndCountingAsSummary(FloatFloatFunction.identity()); } -} +} \ No newline at end of file diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/FactoriesSupplier.java b/common/src/main/java/com/zegelin/cassandra/exporter/FactoriesSupplier.java index e143907..36ef59e 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/FactoriesSupplier.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/FactoriesSupplier.java @@ -11,7 +11,6 @@ import com.zegelin.cassandra.exporter.collector.dynamic.FunctionalMetricFamilyCollector; import com.zegelin.cassandra.exporter.collector.jvm.*; import com.zegelin.prometheus.domain.Labels; -import com.zegelin.prometheus.domain.Interval.Quantile; import javax.management.*; import java.util.*; @@ -37,7 +36,6 @@ private static class FactoryBuilder { private final CollectorConstructor collectorConstructor; private final QueryExp objectNameQuery; private final String metricFamilyName; - private Set excludeQuantiles; private String help; @@ -58,11 +56,10 @@ interface LabelMaker extends Function, Map> private final List modifiers = new LinkedList<>(); - FactoryBuilder(final CollectorConstructor collectorConstructor, final QueryExp objectNameQuery, final String metricFamilyName,Set excludeQuantiles) { + FactoryBuilder(final CollectorConstructor collectorConstructor, final QueryExp objectNameQuery, final String metricFamilyName) { this.collectorConstructor = collectorConstructor; this.objectNameQuery = objectNameQuery; this.metricFamilyName = metricFamilyName; - this.excludeQuantiles=excludeQuantiles; } FactoryBuilder withModifier(final Modifier modifier) { @@ -104,13 +101,13 @@ Factory build() { } } - return collectorConstructor.groupCollectorForMBean(name, help, new Labels(rawLabels), mBean,excludeQuantiles); + return collectorConstructor.groupCollectorForMBean(name, help, new Labels(rawLabels), mBean); }; } @FunctionalInterface public interface CollectorConstructor { - MBeanGroupMetricFamilyCollector groupCollectorForMBean(final String name, final String help, final Labels labels, final NamedObject mBean,Set excludeQuantiles); + MBeanGroupMetricFamilyCollector groupCollectorForMBean(final String name, final String help, final Labels labels, final NamedObject mBean); } } @@ -119,7 +116,6 @@ public interface CollectorConstructor { private final Set tableLabels; private final Set excludedKeyspaces; private final Map tableMetricScopeFilters; - private final Set excludeQuantiles; public FactoriesSupplier(final MetadataFactory metadataFactory, final HarvesterOptions options) { @@ -127,7 +123,6 @@ public FactoriesSupplier(final MetadataFactory metadataFactory, final HarvesterO this.perThreadTimingEnabled = options.perThreadTimingEnabled; this.tableLabels = options.tableLabels; this.excludedKeyspaces = options.excludedKeyspaces; - excludeQuantiles=options.excludedHistoQuantiles; this.tableMetricScopeFilters = ImmutableMap.builder() .put(TableMetricScope.NODE, options.nodeMetricsFilter) @@ -141,7 +136,7 @@ private Factory bufferPoolMetricFactory(final FactoryBuilder.CollectorConstructo final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=BufferPool,name=%s", jmxName); final String metricFamilyName = String.format("buffer_pool_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) .withHelp(help) .build(); } @@ -155,7 +150,7 @@ private Factory cqlMetricFactory(final FactoryBuilder.CollectorConstructor colle final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=CQL,name=%s", jmxName); final String metricFamilyName = String.format("cql_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) .withHelp(help) .withLabelMaker(keyPropertyList -> labels) .build(); @@ -166,7 +161,7 @@ private Factory cacheMetricFactory(final FactoryBuilder.CollectorConstructor col final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Cache,scope=*,name=%s", jmxName); final String metricFamilyName = String.format("cache_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) .withHelp(help) .withLabelMaker(keyPropertyList -> ImmutableMap.of( "cache", keyPropertyList.get("scope").replaceAll("Cache", "").toLowerCase() @@ -179,7 +174,7 @@ private Factory clientMetricFactory(final FactoryBuilder.CollectorConstructor co final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Client,name=%s", jmxName); final String metricFamilyName = String.format("client_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) .withHelp(help) .build(); } @@ -188,7 +183,7 @@ private Factory clientRequestMetricFactory(final FactoryBuilder.CollectorConstru final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=ClientRequest,name=%s,scope=*", jmxName); final String metricFamilyName = String.format("client_request_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) .withHelp(help) .withModifier((keyPropertyList, labels) -> { final String scope = keyPropertyList.get("scope"); @@ -221,7 +216,7 @@ private Factory commitLogMetricFactory(final FactoryBuilder.CollectorConstructor final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=CommitLog,name=%s", jmxName); final String metricFamilyName = String.format("commit_log_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) .withHelp(help) .build(); } @@ -230,7 +225,7 @@ private Factory messagingMetricFactory(final FactoryBuilder.CollectorConstructor final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Messaging,name=%s", jmxName); final String metricFamilyName = String.format("messaging_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) .withHelp(help) .withLabelMaker(keyPropertyList -> { final String name = keyPropertyList.get("name"); @@ -250,7 +245,7 @@ private Factory memtablePoolMetricsFactory(final FactoryBuilder.CollectorConstru final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=MemtablePool,name=%s", jmxName); final String metricFamilyName = String.format("memtable_pool_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) .withHelp(help) .build(); } @@ -259,7 +254,7 @@ private Factory storageMetric(final FactoryBuilder.CollectorConstructor collecto final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Storage,name=%s", jmxName); final String metricFamilyName = String.format("storage_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) .withHelp(help) .build(); } @@ -364,7 +359,7 @@ private Iterator tableMetricFactory(final Set tableMe final QueryExp query = scope.query(jmxName); final String metricFamilyName = String.format(scope.metricFamilyNameFormat, familyNameSuffix); - return new FactoryBuilder(collectorConstructor, query, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, query, metricFamilyName) .withHelp(help) .withModifier((keyPropertyList, labels) -> { labels.putAll(extraLabels); @@ -430,7 +425,7 @@ private Factory threadPoolMetric(final FactoryBuilder.CollectorConstructor colle final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=ThreadPools,path=*,scope=*,name=%s", jmxName); final String metricFamilyName = String.format("thread_pool_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) .withHelp(help) .withLabelMaker(keyPropertyList -> ImmutableMap.of( "group", keyPropertyList.get("path"), @@ -443,14 +438,14 @@ private Factory rowIndexMetric(final FactoryBuilder.CollectorConstructor collect final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Index,scope=RowIndexEntry,name=%s", jmxName); final String metricFamilyName = String.format("row_index_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles).build(); + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName).build(); } private Factory droppedMessagesMetric(final FactoryBuilder.CollectorConstructor collectorConstructor, final String jmxName, final String familyNameSuffix, final String help) { final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=DroppedMessage,scope=*,name=%s", jmxName); final String metricFamilyName = String.format("dropped_messages_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) .withHelp(help) .withLabelMaker(keyPropertyList -> ImmutableMap.of("message_type", keyPropertyList.get("scope"))) .build(); @@ -460,7 +455,7 @@ private Factory compactionMetric(final FactoryBuilder.CollectorConstructor colle final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Compaction,name=%s", jmxName); final String metricFamilyName = String.format("compaction_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) .withHelp(help) .build(); } @@ -469,7 +464,7 @@ private Factory connectionMetric(final FactoryBuilder.CollectorConstructor colle final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=Connection,scope=*,name=%s", jmxName); final String metricFamilyName = String.format("endpoint_connection_%s", familyNameSuffix); - return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName, excludeQuantiles) + return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) .withHelp(help) .withLabelMaker(keyPropertyList -> { final HashMap labels = new HashMap<>(); @@ -497,26 +492,26 @@ private Factory connectionMetric(final FactoryBuilder.CollectorConstructor colle } - private FactoryBuilder.CollectorConstructor timerAsSummaryCollectorConstructor() { - return (name, help, labels, mBean, excludeQuantiles) -> { + private static FactoryBuilder.CollectorConstructor timerAsSummaryCollectorConstructor() { + return (name, help, labels, mBean) -> { final NamedObject samplingCountingNamedObject = CassandraMetricsUtilities.jmxTimerMBeanAsSamplingCounting(mBean); return new FunctionalMetricFamilyCollector<>(name, help, ImmutableMap.of(labels, samplingCountingNamedObject), - samplingAndCountingAsSummary(MetricValueConversionFunctions::nanosecondsToSeconds,excludeQuantiles)); + samplingAndCountingAsSummary(MetricValueConversionFunctions::nanosecondsToSeconds)); }; } - private FactoryBuilder.CollectorConstructor histogramAsSummaryCollectorConstructor() { - return (name, help, labels, mBean,excludeQuantiles) -> { + private static FactoryBuilder.CollectorConstructor histogramAsSummaryCollectorConstructor() { + return (name, help, labels, mBean) -> { final NamedObject samplingCountingNamedObject = CassandraMetricsUtilities.jmxHistogramAsSamplingCounting(mBean); - return new FunctionalMetricFamilyCollector<>(name, help, ImmutableMap.of(labels, samplingCountingNamedObject), samplingAndCountingAsSummary(excludeQuantiles)); + return new FunctionalMetricFamilyCollector<>(name, help, ImmutableMap.of(labels, samplingCountingNamedObject), samplingAndCountingAsSummary()); }; } private static FactoryBuilder.CollectorConstructor functionalCollectorConstructor(final FunctionalMetricFamilyCollector.CollectorFunction function) { - return (final String name, final String help, final Labels labels, final NamedObject mBean,Set excludeQuantiles) -> + return (final String name, final String help, final Labels labels, final NamedObject mBean) -> new FunctionalMetricFamilyCollector<>(name, help, ImmutableMap.of(labels, mBean.cast()), function); } @@ -705,10 +700,10 @@ public List get() { builder.addAll(tableMetricFactory(functionalCollectorConstructor(numericGaugeAsGauge(MetricValueConversionFunctions::neg1ToNaN)), "CompressionRatio", "compression_ratio", null)); - builder.addAll(tableMetricFactory(functionalCollectorConstructor(histogramGaugeAsSummary(excludeQuantiles)), "EstimatedPartitionSizeHistogram", "estimated_partition_size_bytes", null)); + builder.addAll(tableMetricFactory(functionalCollectorConstructor(histogramGaugeAsSummary()), "EstimatedPartitionSizeHistogram", "estimated_partition_size_bytes", null)); builder.addAll(tableMetricFactory(functionalCollectorConstructor(numericGaugeAsGauge(MetricValueConversionFunctions::neg1ToNaN)), "EstimatedPartitionCount", "estimated_partitions", null)); - builder.addAll(tableMetricFactory(functionalCollectorConstructor(histogramGaugeAsSummary(excludeQuantiles)), "EstimatedColumnCountHistogram", "estimated_columns", null)); + builder.addAll(tableMetricFactory(functionalCollectorConstructor(histogramGaugeAsSummary()), "EstimatedColumnCountHistogram", "estimated_columns", null)); builder.addAll(tableMetricFactory(histogramAsSummaryCollectorConstructor(), "SSTablesPerReadHistogram", "sstables_per_read", null)); // @@ -809,4 +804,4 @@ public List get() { return builder.build(); } -} +} \ No newline at end of file diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/Harvester.java b/common/src/main/java/com/zegelin/cassandra/exporter/Harvester.java index bb99d28..0a86995 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/Harvester.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/Harvester.java @@ -147,7 +147,7 @@ protected Harvester(final MetadataFactory metadataFactory, final HarvesterOption this.exclusions = options.exclusions; this.enabledGlobalLabels = options.globalLabels; this.collectorTimingEnabled = options.collectorTimingEnabled; - this.excludedHistoQuantiles=options.excludedHistoQuantiles; + this.excludedHistoQuantiles = options.excludedHistoQuantiles; } public Set getExcludedHistoQuantiles() { diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java b/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java index a7d97b1..bbf646f 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java @@ -154,7 +154,7 @@ public void setExcludeSystemTables(final boolean excludeSystemTables) { excludedKeyspaces.addAll(CASSANDRA_SYSTEM_KEYSPACES); } - public Set excludedHistoQuantiles = new HashSet<>(); + public final Set excludedHistoQuantiles = new HashSet<>(); @Option(names = {"--exclude-from-histogram"}, paramLabel = "EXCLUSION", arity = "1..*", description = "Select which quantiles to exclude from histogram metrics. The specified quantiles are excluded from all histogram/summary metrics" + "Valid options are: P_50, P_75, P_95, P_98, P_99, P_99_9" + diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/collector/LatencyMetricGroupSummaryCollector.java b/common/src/main/java/com/zegelin/cassandra/exporter/collector/LatencyMetricGroupSummaryCollector.java index d6520fe..24fed37 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/collector/LatencyMetricGroupSummaryCollector.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/collector/LatencyMetricGroupSummaryCollector.java @@ -2,13 +2,11 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import com.zegelin.jmx.NamedObject; import com.zegelin.cassandra.exporter.MBeanGroupMetricFamilyCollector; import com.zegelin.cassandra.exporter.MetricValueConversionFunctions; import com.zegelin.cassandra.exporter.SamplingCounting; import com.zegelin.prometheus.domain.Interval; -import com.zegelin.prometheus.domain.Interval.Quantile; import com.zegelin.prometheus.domain.Labels; import com.zegelin.prometheus.domain.MetricFamily; import com.zegelin.prometheus.domain.SummaryMetricFamily; @@ -16,12 +14,8 @@ import org.apache.cassandra.metrics.CassandraMetricsRegistry.JmxTimerMBean; import javax.management.ObjectName; - -import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; -import java.util.Set; import java.util.stream.Stream; import static com.zegelin.cassandra.exporter.CassandraMetricsUtilities.jmxTimerMBeanAsSamplingCounting; @@ -79,23 +73,21 @@ LatencyMetricGroup removeMBean(final ObjectName objectName) { private final String name; private final String help; private final Map latencyMetricGroups; - private final Set excludeQuantiles; - private LatencyMetricGroupSummaryCollector(final String name, final String help, final Map latencyMetricGroups, Set excludeQuantiles) { + private LatencyMetricGroupSummaryCollector(final String name, final String help, final Map latencyMetricGroups) { this.name = name; this.help = help; this.latencyMetricGroups = ImmutableMap.copyOf(latencyMetricGroups); - this.excludeQuantiles=excludeQuantiles; } - public static LatencyMetricGroupSummaryCollector collectorForMBean(final String name, final String help, final Labels labels, final NamedObject mBean,Set excludeQuantiles) { + public static LatencyMetricGroupSummaryCollector collectorForMBean(final String name, final String help, final Labels labels, final NamedObject mBean) { final NamedObject timer = (mBean.object instanceof JmxTimerMBean) ? jmxTimerMBeanAsSamplingCounting(mBean) : null; final NamedObject counter = mBean.map((n, o) -> (o instanceof JmxCounterMBean) ? (JmxCounterMBean) o : null); final LatencyMetricGroup latencyMetricGroup = new LatencyMetricGroup(timer, counter); - return new LatencyMetricGroupSummaryCollector(name, help, ImmutableMap.of(labels, latencyMetricGroup),excludeQuantiles); + return new LatencyMetricGroupSummaryCollector(name, help, ImmutableMap.of(labels, latencyMetricGroup)); } @Override @@ -116,7 +108,7 @@ public MBeanGroupMetricFamilyCollector merge(final MBeanGroupMetricFamilyCollect newLatencyMetricGroups.merge(group.getKey(), group.getValue(), LatencyMetricGroup::merge); } - return new LatencyMetricGroupSummaryCollector(name, help, newLatencyMetricGroups,excludeQuantiles); + return new LatencyMetricGroupSummaryCollector(name, help, newLatencyMetricGroups); } @Override @@ -137,7 +129,7 @@ public MBeanGroupMetricFamilyCollector removeMBean(final ObjectName mBeanName) { return null; } - return new LatencyMetricGroupSummaryCollector(name, help, newLatencyMetricGroups,excludeQuantiles); + return new LatencyMetricGroupSummaryCollector(name, help, newLatencyMetricGroups); } @Override @@ -152,24 +144,14 @@ public Stream collect() { final float count = e.latencyMetricGroup.latencyTimer.object.getCount(); final float sum = microsecondsToSeconds(e.latencyMetricGroup.totalLatencyCounter.object.getCount()); - Iterator itr=e.latencyMetricGroup.latencyTimer.object.getIntervals().iterator(); - ArrayList filtered = Lists.newArrayList(); - while(itr.hasNext()) { - Interval interval = itr.next(); - if(excludeQuantiles.contains(interval.quantile)) { - continue; - } - filtered.add(interval); - } - - final Iterable quantiles = Iterables.transform(filtered, + final Iterable quantiles = Iterables.transform(e.latencyMetricGroup.latencyTimer.object.getIntervals(), i -> i.transform(MetricValueConversionFunctions::nanosecondsToSeconds) ); - + return new SummaryMetricFamily.Summary(e.labels, sum, count, quantiles); }); return Stream.of(new SummaryMetricFamily(this.name, this.help, summaryStream)); } -} +} \ No newline at end of file diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/netty/HttpHandler.java b/common/src/main/java/com/zegelin/cassandra/exporter/netty/HttpHandler.java index e065f1d..02c9ca9 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/netty/HttpHandler.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/netty/HttpHandler.java @@ -299,7 +299,7 @@ private ChannelFuture sendMetrics(final ChannelHandlerContext ctx, final FullHtt lastWriteFuture = ctx.writeAndFlush(response); if (request.getMethod() == HttpMethod.GET) { - ReadableByteChannel byteChannel = new FormattedByteChannel(new TextFormatExposition(metricFamilyStream, timestamp, globalLabels, includeHelp)); + ReadableByteChannel byteChannel = new FormattedByteChannel(new TextFormatExposition(metricFamilyStream, timestamp, globalLabels, includeHelp, harvester.getExcludedHistoQuantiles())); lastWriteFuture = ctx.writeAndFlush(new HttpChunkedInput(new ChunkedNioStream(byteChannel, FormattedByteChannel.MAX_CHUNK_SIZE))); } diff --git a/common/src/main/java/com/zegelin/prometheus/exposition/text/TextFormatExposition.java b/common/src/main/java/com/zegelin/prometheus/exposition/text/TextFormatExposition.java index 4c53c6f..bd4040f 100644 --- a/common/src/main/java/com/zegelin/prometheus/exposition/text/TextFormatExposition.java +++ b/common/src/main/java/com/zegelin/prometheus/exposition/text/TextFormatExposition.java @@ -3,12 +3,14 @@ import com.google.common.base.Stopwatch; import com.zegelin.netty.Resources; import com.zegelin.prometheus.domain.*; +import com.zegelin.prometheus.domain.Interval.Quantile; import com.zegelin.prometheus.exposition.ExpositionSink; import com.zegelin.prometheus.exposition.FormattedExposition; import io.netty.buffer.ByteBuf; import java.time.Instant; import java.util.Iterator; +import java.util.Set; import java.util.stream.Stream; public class TextFormatExposition implements FormattedExposition { @@ -35,13 +37,14 @@ private enum State { private int metricCount = 0; private final Stopwatch stopwatch = Stopwatch.createUnstarted(); - - - public TextFormatExposition(final Stream metricFamilies, final Instant timestamp, final Labels globalLabels, final boolean includeHelp) { + private final Set excludedHistoQuantiles; + + public TextFormatExposition(final Stream metricFamilies, final Instant timestamp, final Labels globalLabels, final boolean includeHelp, final Set excludedHistoQuantiles) { this.metricFamiliesIterator = metricFamilies.iterator(); this.timestamp = timestamp; this.globalLabels = globalLabels; this.includeHelp = includeHelp; + this.excludedHistoQuantiles = excludedHistoQuantiles; } @Override @@ -70,7 +73,7 @@ public void nextSlice(final ExpositionSink chunkBuffer) { final MetricFamily metricFamily = metricFamiliesIterator.next(); - metricFamilyWriter = new TextFormatMetricFamilyWriter(timestamp, globalLabels, includeHelp, metricFamily); + metricFamilyWriter = new TextFormatMetricFamilyWriter(timestamp, globalLabels, includeHelp, metricFamily, excludedHistoQuantiles); metricFamilyWriter.writeFamilyHeader(chunkBuffer); diff --git a/common/src/main/java/com/zegelin/prometheus/exposition/text/TextFormatMetricFamilyWriter.java b/common/src/main/java/com/zegelin/prometheus/exposition/text/TextFormatMetricFamilyWriter.java index e0209f7..017f01b 100644 --- a/common/src/main/java/com/zegelin/prometheus/exposition/text/TextFormatMetricFamilyWriter.java +++ b/common/src/main/java/com/zegelin/prometheus/exposition/text/TextFormatMetricFamilyWriter.java @@ -3,10 +3,12 @@ import com.google.common.escape.CharEscaperBuilder; import com.google.common.escape.Escaper; import com.zegelin.prometheus.domain.*; +import com.zegelin.prometheus.domain.Interval.Quantile; import com.zegelin.prometheus.exposition.ExpositionSink; import java.time.Instant; import java.util.Iterator; +import java.util.Set; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; @@ -41,14 +43,16 @@ void write(final ExpositionSink buffer) { private final Consumer> headerWriter; private final Function, Boolean> metricWriter; + private final Set excludedHistoQuantiles; - TextFormatMetricFamilyWriter(final Instant timestamp, final Labels globalLabels, final boolean includeHelp, final MetricFamily metricFamily) { + TextFormatMetricFamilyWriter(final Instant timestamp, final Labels globalLabels, final boolean includeHelp, final MetricFamily metricFamily, final Set excludedHistoQuantiles) { this.timestamp = " " + timestamp.toEpochMilli(); this.globalLabels = globalLabels; this.includeHelp = includeHelp; this.headerWriter = metricFamily.accept(new HeaderVisitor()); this.metricWriter = metricFamily.accept(new MetricVisitor()); + this.excludedHistoQuantiles=excludedHistoQuantiles; } class HeaderVisitor implements MetricFamilyVisitor>> { @@ -182,7 +186,9 @@ public Function, Boolean> visit(final SummaryMetricFamily metr writeMetric(buffer, metricFamily, "_count", summary.count, summary.labels); summary.quantiles.forEach(interval -> { - writeMetric(buffer, metricFamily, null, interval.value, summary.labels, interval.quantile.asSummaryLabel()); + if (!excludedHistoQuantiles.contains(interval.quantile)) { + writeMetric(buffer, metricFamily, null, interval.value, summary.labels, interval.quantile.asSummaryLabel()); + } }); }); } @@ -194,7 +200,10 @@ public Function, Boolean> visit(final HistogramMetricFamily me writeMetric(buffer, metricFamily, "_count", histogram.count, histogram.labels); histogram.buckets.forEach(interval -> { - writeMetric(buffer, metricFamily, "_bucket", interval.value, histogram.labels, interval.quantile.asHistogramLabel()); + if (!excludedHistoQuantiles.contains(interval.quantile)) { + writeMetric(buffer, metricFamily, "_bucket", interval.value, histogram.labels, interval.quantile.asHistogramLabel()); + } + }); writeMetric(buffer, metricFamily, "_bucket", histogram.count, histogram.labels, Interval.Quantile.POSITIVE_INFINITY.asHistogramLabel()); diff --git a/standalone/pom.xml b/standalone/pom.xml index fc6ea01..d539c16 100644 --- a/standalone/pom.xml +++ b/standalone/pom.xml @@ -16,7 +16,7 @@ 18.0 3.4.0 - 4.1.42.Final + 4.0.47.Final 1.2.3 1.7.16 diff --git a/standalone/src/main/java/com/zegelin/cassandra/exporter/Application.java b/standalone/src/main/java/com/zegelin/cassandra/exporter/Application.java index 6a602ec..61eaecb 100644 --- a/standalone/src/main/java/com/zegelin/cassandra/exporter/Application.java +++ b/standalone/src/main/java/com/zegelin/cassandra/exporter/Application.java @@ -78,7 +78,7 @@ protected int defaultPort() { @Option(names = "--cql-password", paramLabel = "PASSWORD", description = "CQL authentication password.") private String cqlPassword; - @Option(names = "--cql-ssl", paramLabel = "PASSWORD", description = "Native connection to be encrypted") + @Option(names = "--cql-ssl", paramLabel = "SSL", description = "Creates enctrypted DB connections.") private boolean ssl; @Option(names = {"-v", "--verbose"}, description = "Enable verbose logging. Multiple invocations increase the verbosity.") From a3c581c20ea62aa2f4dddc3cac33134373aae753 Mon Sep 17 00:00:00 2001 From: n660955 Date: Thu, 5 Mar 2020 10:56:54 +0530 Subject: [PATCH 5/6] Formatting Appended the new line at the end of files which removed while restoring previous changes from repo. --- .../java/com/zegelin/cassandra/exporter/CollectorFunctions.java | 2 +- .../java/com/zegelin/cassandra/exporter/FactoriesSupplier.java | 2 +- .../exporter/collector/LatencyMetricGroupSummaryCollector.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/CollectorFunctions.java b/common/src/main/java/com/zegelin/cassandra/exporter/CollectorFunctions.java index b48d498..6455bee 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/CollectorFunctions.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/CollectorFunctions.java @@ -176,4 +176,4 @@ protected static CollectorFunction samplingAndCountingAsSummar public static CollectorFunction samplingAndCountingAsSummary() { return samplingAndCountingAsSummary(FloatFloatFunction.identity()); } -} \ No newline at end of file +} diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/FactoriesSupplier.java b/common/src/main/java/com/zegelin/cassandra/exporter/FactoriesSupplier.java index 36ef59e..2d88503 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/FactoriesSupplier.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/FactoriesSupplier.java @@ -804,4 +804,4 @@ public List get() { return builder.build(); } -} \ No newline at end of file +} diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/collector/LatencyMetricGroupSummaryCollector.java b/common/src/main/java/com/zegelin/cassandra/exporter/collector/LatencyMetricGroupSummaryCollector.java index 24fed37..c7aacb3 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/collector/LatencyMetricGroupSummaryCollector.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/collector/LatencyMetricGroupSummaryCollector.java @@ -154,4 +154,4 @@ public Stream collect() { return Stream.of(new SummaryMetricFamily(this.name, this.help, summaryStream)); } -} \ No newline at end of file +} From 9f9823c9fc27f191c3859a7e67e5b34a66bd112d Mon Sep 17 00:00:00 2001 From: n660955 Date: Fri, 6 Mar 2020 09:36:54 +0530 Subject: [PATCH 6/6] Corrected formatting issues --- .../zegelin/cassandra/exporter/cli/HarvesterOptions.java | 8 ++++---- .../java/com/zegelin/cassandra/exporter/Application.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java b/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java index bbf646f..1b228e0 100644 --- a/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java +++ b/common/src/main/java/com/zegelin/cassandra/exporter/cli/HarvesterOptions.java @@ -167,10 +167,10 @@ public void setExcludeSystemTables(final boolean excludeSystemTables) { "The default is to include all quantiles. " ) void setExcludeFromHistogram(final Set values) { - values.forEach(e->{ - Quantile q=Quantile.ALL_PERCENTILES.get(e); - if(q==null) { - throw new IllegalArgumentException(String.format("The specified exlusion quantile '%s' is invalid, value values are '%s'", e,Quantile.ALL_PERCENTILES.keySet())); + values.forEach( e -> { + Quantile q = Quantile.ALL_PERCENTILES.get(e); + if(q == null) { + throw new IllegalArgumentException(String.format("The specified exlusion quantile '%s' is invalid, value values are '%s'", e, Quantile.ALL_PERCENTILES.keySet())); } excludedHistoQuantiles.add(q); }); diff --git a/standalone/src/main/java/com/zegelin/cassandra/exporter/Application.java b/standalone/src/main/java/com/zegelin/cassandra/exporter/Application.java index 61eaecb..4d33f08 100644 --- a/standalone/src/main/java/com/zegelin/cassandra/exporter/Application.java +++ b/standalone/src/main/java/com/zegelin/cassandra/exporter/Application.java @@ -147,7 +147,7 @@ private Cluster establishClusterConnection() { if (cqlUser != null && cqlPassword != null) { clusterBuilder.withCredentials(cqlUser, cqlPassword); } - if(ssl) { + if (ssl) { clusterBuilder.withSSL(); }