[ https://issues.apache.org/jira/browse/TC-270?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15998445#comment-15998445 ]
ASF GitHub Bot commented on TC-270: ----------------------------------- Github user mitchell852 commented on a diff in the pull request: https://github.com/apache/incubator-trafficcontrol/pull/545#discussion_r115017970 --- Diff: 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" --- End diff -- The RT name is also hard-coded in the deliveryservice_stats endpoint - https://github.com/apache/incubator-trafficcontrol/blob/master/traffic_ops/app/lib/Extensions/TrafficStats/Builder/DeliveryServiceStatsBuilder.pm#L81 How about I create a new Jira and a subsequent PR that removes hardcoded RT references from both cache_stats and deliveryservice_stats endpoints and maybe puts the RT names in this file: https://github.com/apache/incubator-trafficcontrol/blob/master/traffic_ops/app/conf/production/influxdb.conf > GET api/cache_stats needs to query summarized influx data rather than raw data > ------------------------------------------------------------------------------ > > Key: TC-270 > URL: https://issues.apache.org/jira/browse/TC-270 > Project: Traffic Control > Issue Type: Improvement > Components: Traffic Ops, Traffic Stats > Reporter: Jeremy Mitchell > Assignee: Jeremy Mitchell > Priority: Minor > Fix For: 2.1.0 > > > The following API queries raw influx data causing it to be slow and thus it > times out: > GET api/1.2/cache_stats > That API endpoint currently runs 2 queries like such: > series query: > SELECT sum(value)*1000/6 FROM "metricName" WHERE time > > '2017-05-03T09:22:00-06:00' AND time < '2017-05-04T09:22:00-06:00' AND cdn = > 'cdn1' GROUP BY time(60s), cdn ORDER BY asc > summary query: > SELECT mean(value), percentile(value, 5), percentile(value, 95), > percentile(value, 98), min(value), max(value), sum(value), count(value) FROM > "metricName" WHERE cdn = 'cdn1' AND time > '2017-05-03T09:22:00-06:00' AND > time < '2017-05-04T09:22:00-06:00' GROUP BY time(60s), cdn > Those queries should leverage the summarized data and look like this instead: > series query: > SELECT sum(value)/count(value) FROM "monthly"."metricName.cdn.1min" WHERE cdn > = 'cdn1' AND time > '2017-05-03T09:22:00-06:00' AND time < > '2017-05-04T09:22:00-06:00' GROUP BY time(60s), cdn ORDER BY asc > summary query: > SELECT mean(value), percentile(value, 5), percentile(value, 95), > percentile(value, 98), min(value), max(value), sum(value), count(value) FROM > "monthly"."metricName.cdn.1min" WHERE cdn = 'cdn1' AND time > > '2017-05-03T09:22:00-06:00' AND time < '2017-05-04T09:22:00-06:00' GROUP BY > time(60s), cdn -- This message was sent by Atlassian JIRA (v6.3.15#6346)