Skip to content

Commit

Permalink
keep metric same
Browse files Browse the repository at this point in the history
  • Loading branch information
innerpeacez committed Dec 20, 2021
1 parent 723dac8 commit ff27b56
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions modules/msp/apm/service/apm.service.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (s *apmServiceService) GetServices(ctx context.Context, req *pb.GetServices
}

// default get time: 1 day.
start, end := TimeRange("-24")
start, end := TimeRange("-24h")

// get services list
statement := fmt.Sprintf("SELECT service_id::tag,service_name::tag,service_agent_platform::tag,max(timestamp) FROM application_service_node "+
Expand Down Expand Up @@ -101,6 +101,8 @@ func (s *apmServiceService) GetServices(ctx context.Context, req *pb.GetServices
if err != nil {
return nil, errors.NewInternalServerError(err)
}

// service total count
total := int64(countResponse.Results[0].Series[0].Rows[0].GetValues()[0].GetNumberValue())

if rows == nil || len(rows) == 0 {
Expand Down Expand Up @@ -160,7 +162,7 @@ func (s *apmServiceService) aggregateMetric(serviceStatus, tenantId string, serv
includeIds = includeIds[:len(includeIds)-1]

statement := fmt.Sprintf("SELECT target_service_id::tag,sum(count_sum::field)/(60*60),sum(elapsed_sum::field)/sum(count_sum::field),sum(errors_sum::field)/sum(count_sum::field)"+
"FROM application_http_service,application_rpc_service "+
"FROM application_http_service,application_rpc_service,application_db_service,application_cache_service,application_mq_service "+
"WHERE (target_terminus_key::tag=$terminus_key OR source_terminus_key::tag=$terminus_key) "+
"AND include(target_service_id::tag, %s) GROUP BY target_service_id::tag", includeIds)
condition := " terminus_key::tag=$terminus_key "
Expand Down
6 changes: 3 additions & 3 deletions modules/msp/apm/service/components/service-list/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (p *provider) errorRateTop5(interval int64, tenantId interface{}, start int

func (p *provider) avgDurationTop5(interval int64, tenantId interface{}, start int64, end int64, ctx context.Context) ([]topn.Item, error) {
statement := fmt.Sprintf("SELECT target_service_id::tag,target_service_name::tag,avg(elapsed_sum::field) " +
"FROM application_http " +
"FROM application_http,application_rpc,application_db,application_cache,application_mq " +
"WHERE (target_terminus_key::tag=$terminus_key OR source_terminus_key::tag=$terminus_key) " +
"GROUP BY target_service_id::tag " +
"ORDER BY avg(elapsed_sum::field) DESC " +
Expand Down Expand Up @@ -205,7 +205,7 @@ func (p *provider) avgDurationTop5(interval int64, tenantId interface{}, start i

func (p *provider) rpsMinTop5(interval int64, tenantId interface{}, start int64, end int64, ctx context.Context) ([]topn.Item, error) {
statement := fmt.Sprintf("SELECT target_service_id::tag,target_service_name::tag,sum(elapsed_count::field)/%v "+
"FROM application_http "+
"FROM application_http,application_rpc,application_db,application_cache,application_mq "+
"WHERE (target_terminus_key::tag=$terminus_key OR source_terminus_key::tag=$terminus_key) "+
"GROUP BY target_service_id::tag "+
"ORDER BY sum(elapsed_count::field) ASC "+
Expand Down Expand Up @@ -247,7 +247,7 @@ func (p *provider) rpsMinTop5(interval int64, tenantId interface{}, start int64,

func (p *provider) rpsMaxTop5(interval int64, tenantId interface{}, start int64, end int64, ctx context.Context) ([]topn.Item, error) {
statement := fmt.Sprintf("SELECT target_service_id::tag,target_service_name::tag,sum(elapsed_count::field)/%v "+
"FROM application_http "+
"FROM application_http,application_rpc,application_db,application_cache,application_mq "+
"WHERE (target_terminus_key::tag=$terminus_key OR source_terminus_key::tag=$terminus_key) "+
"GROUP BY target_service_id::tag "+
"ORDER BY sum(elapsed_count::field) DESC "+
Expand Down
2 changes: 1 addition & 1 deletion modules/msp/apm/service/view/chart/avg_duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type AvgDurationChart struct {

func (avgDuration *AvgDurationChart) GetChart(ctx context.Context) (*pb.ServiceChart, error) {
statement := fmt.Sprintf("SELECT sum(elapsed_sum::field)/sum(elapsed_count::field) "+
"FROM application_http "+
"FROM application_http,application_rpc,application_db,application_cache,application_mq "+
"WHERE (target_terminus_key::tag=$terminus_key OR source_terminus_key::tag=$terminus_key) "+
"AND target_service_id::tag=$service_id "+
"GROUP BY time(%s)", avgDuration.Interval)
Expand Down
2 changes: 1 addition & 1 deletion modules/msp/apm/service/view/chart/rps.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type RpsChart struct {
func (rps *RpsChart) GetChart(ctx context.Context) (*pb.ServiceChart, error) {

statement := fmt.Sprintf("SELECT rateps(elapsed_count::field) "+
"FROM application_http "+
"FROM application_http,application_rpc,application_db,application_cache,application_mq "+
"WHERE (target_terminus_key::tag=$terminus_key OR source_terminus_key::tag=$terminus_key) "+
"AND target_service_id::tag=$service_id "+
"GROUP BY time(%s)", rps.Interval)
Expand Down

0 comments on commit ff27b56

Please sign in to comment.