trafficcontrol-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neu...@apache.org
Subject [1/2] incubator-trafficcontrol git commit: query from summarized data (continuous queries) instead of raw data
Date Fri, 05 May 2017 15:48:27 GMT
Repository: incubator-trafficcontrol
Updated Branches:
  refs/heads/master b4ced6beb -> 63f6abf26


query from summarized data (continuous queries) instead of raw data


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/80b9f61f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/80b9f61f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/80b9f61f

Branch: refs/heads/master
Commit: 80b9f61f3875a7baf9e6b2537f69612adabc8cc7
Parents: b4ced6b
Author: Jeremy Mitchell <mitchell852@gmail.com>
Authored: Thu May 4 14:09:56 2017 -0600
Committer: David Neuman <david.neuman64@gmail.com>
Committed: Fri May 5 09:35:42 2017 -0600

----------------------------------------------------------------------
 .../TrafficStats/Builder/CacheStatsBuilder.pm   | 32 ++++++++------------
 1 file changed, 13 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/80b9f61f/traffic_ops/app/lib/Extensions/TrafficStats/Builder/CacheStatsBuilder.pm
----------------------------------------------------------------------
diff --git a/traffic_ops/app/lib/Extensions/TrafficStats/Builder/CacheStatsBuilder.pm b/traffic_ops/app/lib/Extensions/TrafficStats/Builder/CacheStatsBuilder.pm
index 55f11f9..87d0035 100755
--- a/traffic_ops/app/lib/Extensions/TrafficStats/Builder/CacheStatsBuilder.pm
+++ b/traffic_ops/app/lib/Extensions/TrafficStats/Builder/CacheStatsBuilder.pm
@@ -74,14 +74,12 @@ sub summary_query {
 	if ( $self->validate_keys() ) {
 
 		#'summary' section
-		my $query = sprintf(
-			'%s "%s" %s',
-			"SELECT mean(value), percentile(value, 5), percentile(value, 95), percentile(value, 98),
min(value), max(value), sum(value), count(value) FROM",
-			$args->{series_name}, "WHERE cdn = '$args->{cdn_name}' AND
-			                             time > '$args->{start_date}' AND
-		                                 time < '$args->{end_date}' 
-		                                 GROUP BY time($args->{interval}), cdn"
-		);
+		my $query = qq[SELECT mean(value), percentile(value, 5), percentile(value, 95), percentile(value,
98), min(value), max(value), sum(value), count(value)
+				FROM "monthly"."$args->{series_name}.cdn.1min"
+				WHERE cdn = '$args->{cdn_name}'
+					AND time > '$args->{start_date}'
+					AND time < '$args->{end_date}'
+					GROUP BY time($args->{interval}), cdn];
 
 		$query = Extensions::TrafficStats::Builder::BaseBuilder->append_clauses( $query, $args
);
 
@@ -93,17 +91,13 @@ sub summary_query {
 sub series_query {
 	my $self = shift;
 
-	# TODO: drichardson - make the sum more dynamic based upon the interval
-	my $query = sprintf(
-		'%s "%s" %s',
-		"SELECT sum(value)*1000/6 FROM",
-		$args->{series_name}, "WHERE 
-							   time > '$args->{start_date}' AND 
-                               time < '$args->{end_date}' AND 
-                               cdn = '$args->{cdn_name}'
-                               GROUP BY time($args->{interval}),
-							   cdn ORDER BY asc"
-	);
+	my $query = qq[SELECT sum(value)/count(value)
+			FROM "monthly"."$args->{series_name}.cdn.1min"
+			WHERE cdn = '$args->{cdn_name}'
+				AND time > '$args->{start_date}'
+				AND time < '$args->{end_date}'
+				GROUP BY time($args->{interval}), cdn
+				ORDER BY asc];
 
 	$query = Extensions::TrafficStats::Builder::BaseBuilder->append_clauses( $query, $args
);
 


Mime
View raw message