diff --git a/puppet/manifests/init.pp b/puppet/manifests/init.pp index 53a5e6f3..b491a5f4 100644 --- a/puppet/manifests/init.pp +++ b/puppet/manifests/init.pp @@ -9,6 +9,7 @@ $reader_port = '8080', $reader_threads = '16', $reader_request_timeout = '30', + $reader_max_points = '60000000', $reader_rollups = ['60s:5356800s','900s:62208000s'], $store_cluster = [$::ipaddress], diff --git a/puppet/templates/disthene-reader.yaml.erb b/puppet/templates/disthene-reader.yaml.erb index df70de76..450eb415 100644 --- a/puppet/templates/disthene-reader.yaml.erb +++ b/puppet/templates/disthene-reader.yaml.erb @@ -3,6 +3,7 @@ reader: port: <%= @reader_port %> threads: <%= @reader_threads %> requestTimeout: <%= @reader_request_timeout %> + maxPoints: <%= @reader_max_points %> rollups: <% @reader_rollups.each do |rollup| -%> - <%= rollup %> diff --git a/src/main/java/net/iponweb/disthene/reader/config/ReaderConfiguration.java b/src/main/java/net/iponweb/disthene/reader/config/ReaderConfiguration.java index 12faa7c0..1bb03f49 100644 --- a/src/main/java/net/iponweb/disthene/reader/config/ReaderConfiguration.java +++ b/src/main/java/net/iponweb/disthene/reader/config/ReaderConfiguration.java @@ -11,6 +11,7 @@ public class ReaderConfiguration { private int port; private int threads = 32; private int requestTimeout = 30; + private int maxPoints = 60_000_000; private List rollups = new ArrayList<>(); public String getBind() { @@ -53,6 +54,14 @@ public void setRequestTimeout(int requestTimeout) { this.requestTimeout = requestTimeout; } + public int getMaxPoints() { + return maxPoints; + } + + public void setMaxPoints(int maxPoints) { + this.maxPoints = maxPoints; + } + @Override public String toString() { return "ReaderConfiguration{" + @@ -60,6 +69,7 @@ public String toString() { ", port=" + port + ", threads=" + threads + ", requestTimeout=" + requestTimeout + + ", maxPoints=" + maxPoints + ", rollups=" + rollups + '}'; } diff --git a/src/main/java/net/iponweb/disthene/reader/service/metric/MetricService.java b/src/main/java/net/iponweb/disthene/reader/service/metric/MetricService.java index 9ccd93e6..ea977d76 100644 --- a/src/main/java/net/iponweb/disthene/reader/service/metric/MetricService.java +++ b/src/main/java/net/iponweb/disthene/reader/service/metric/MetricService.java @@ -140,6 +140,11 @@ public List getMetricsAsList(String tenant, List wildcards, logger.debug("Expected number of data points in series is " + length); logger.debug("Expected number of series is " + paths.size()); + // Fail (return empty list) right away if we exceed maximum number of points + if (paths.size() * length > distheneReaderConfiguration.getReader().getMaxPoints()) { + logger.debug("Expected total number of data points exceeds the limit: " + paths.size() * length); + return Collections.emptyList(); + } // Now let's query C* List> futures = Lists.newArrayListWithExpectedSize(paths.size());