query:=fmt.Sprintf("SELECT serviceName, quantile(0.99)(durationNano) as p99, avg(durationNano) as avgDuration, count(*) as numCalls FROM %s WHERE timestamp>='%s' AND timestamp<='%s' AND kind='2' GROUP BY serviceName",r.indexTable,strconv.FormatInt(queryParams.Start.UnixNano(),10),strconv.FormatInt(queryParams.End.UnixNano(),10))
query:=fmt.Sprintf("SELECT toStartOfInterval(timestamp, INTERVAL %s minute) as time, quantile(0.99)(durationNano) as p99, quantile(0.95)(durationNano) as p95,quantile(0.50)(durationNano) as p50, count(*) as numCalls FROM %s WHERE timestamp>='%s' AND timestamp<='%s' AND kind='2' AND serviceName='%s' GROUP BY time ORDER BY time DESC",strconv.Itoa(int(queryParams.StepSeconds/60)),r.indexTable,strconv.FormatInt(queryParams.Start.UnixNano(),10),strconv.FormatInt(queryParams.End.UnixNano(),10),queryParams.ServiceName)
err:=r.db.Select(&serviceOverviewItems,query)
zap.S().Info(query)
iferr!=nil{
zap.S().Debug("Error in processing sql query: ",err)
returnnil,fmt.Errorf("Error in processing sql query")
query:=fmt.Sprintf("SELECT toStartOfInterval(timestamp, INTERVAL %s minute) as time, avg(durationNano) as avgDuration, count(1) as numCalls, dbSystem FROM %s WHERE serviceName='%s' AND timestamp>='%s' AND timestamp<='%s' AND kind='3' AND dbName IS NOT NULL GROUP BY time, dbSystem ORDER BY time DESC",strconv.Itoa(int(queryParams.StepSeconds/60)),r.indexTable,queryParams.ServiceName,strconv.FormatInt(queryParams.Start.UnixNano(),10),strconv.FormatInt(queryParams.End.UnixNano(),10))
query:=fmt.Sprintf("SELECT toStartOfInterval(timestamp, INTERVAL %s minute) as time, avg(durationNano) as avgDuration FROM %s WHERE serviceName='%s' AND timestamp>='%s' AND timestamp<='%s' AND kind='3' AND externalHttpUrl IS NOT NULL GROUP BY time ORDER BY time DESC",strconv.Itoa(int(queryParams.StepSeconds/60)),r.indexTable,queryParams.ServiceName,strconv.FormatInt(queryParams.Start.UnixNano(),10),strconv.FormatInt(queryParams.End.UnixNano(),10))
err:=r.db.Select(&serviceExternalItems,query)
zap.S().Info(query)
iferr!=nil{
zap.S().Debug("Error in processing sql query: ",err)
returnnil,fmt.Errorf("Error in processing sql query")
query:=fmt.Sprintf("SELECT toStartOfInterval(timestamp, INTERVAL %s minute) as time, avg(durationNano) as avgDuration, count(1) as numCalls, externalHttpUrl FROM %s WHERE serviceName='%s' AND timestamp>='%s' AND timestamp<='%s' AND kind='3' AND externalHttpUrl IS NOT NULL AND StatusCode >= 500 GROUP BY time, externalHttpUrl ORDER BY time DESC",strconv.Itoa(int(queryParams.StepSeconds/60)),r.indexTable,queryParams.ServiceName,strconv.FormatInt(queryParams.Start.UnixNano(),10),strconv.FormatInt(queryParams.End.UnixNano(),10))
err:=r.db.Select(&serviceExternalItems,query)
zap.S().Info(query)
iferr!=nil{
zap.S().Debug("Error in processing sql query: ",err)
returnnil,fmt.Errorf("Error in processing sql query")
query:=fmt.Sprintf("SELECT toStartOfInterval(timestamp, INTERVAL %s minute) as time, avg(durationNano) as avgDuration, count(1) as numCalls, externalHttpUrl FROM %s WHERE serviceName='%s' AND timestamp>='%s' AND timestamp<='%s' AND kind='3' AND externalHttpUrl IS NOT NULL GROUP BY time, externalHttpUrl ORDER BY time DESC",strconv.Itoa(int(queryParams.StepSeconds/60)),r.indexTable,queryParams.ServiceName,strconv.FormatInt(queryParams.Start.UnixNano(),10),strconv.FormatInt(queryParams.End.UnixNano(),10))
err:=r.db.Select(&serviceExternalItems,query)
zap.S().Info(query)
iferr!=nil{
zap.S().Debug("Error in processing sql query: ",err)
returnnil,fmt.Errorf("Error in processing sql query")