Skip to content

Commit

Permalink
add application name for serive monitor list
Browse files Browse the repository at this point in the history
  • Loading branch information
chengjoey committed Mar 13, 2024
1 parent 8c3aef9 commit 4e559d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/proto/msp/apm/service/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ message Service {
erda.common.Language language = 3;
string lastHeartbeat = 4;
AggregateMetric aggregateMetric = 5;
string appName = 6;
}

message AggregateMetric {
Expand Down
3 changes: 2 additions & 1 deletion internal/apps/msp/apm/service/apm.service.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (s *apmServiceService) GetServices(ctx context.Context, req *pb.GetServices
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 "+
statement := fmt.Sprintf("SELECT service_id::tag,service_name::tag,service_agent_platform::tag,max(timestamp),application_name::tag FROM application_service_node "+
"WHERE $condition GROUP BY service_id::tag ORDER BY max(timestamp) DESC LIMIT %v OFFSET %v", req.PageSize, (req.PageNo-1)*req.PageSize)
condition := " terminus_key::tag=$terminus_key "
queryParams := map[string]*structpb.Value{
Expand Down Expand Up @@ -143,6 +143,7 @@ func (s *apmServiceService) GetServices(ctx context.Context, req *pb.GetServices
service.Name = row.Values[1].GetStringValue()
service.Language = parseLanguage(row.Values[2].GetStringValue())
service.LastHeartbeat = time.Unix(0, int64(row.Values[3].GetNumberValue())).Format("2006-01-02 15:04:05")
service.AppName = row.Values[4].GetStringValue()
service.AggregateMetric = &pb.AggregateMetric{}
services = append(services, service)
}
Expand Down
4 changes: 4 additions & 0 deletions internal/apps/msp/apm/service/apm.service.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ func Test_apmServiceService_GetServices(t *testing.T) {
{Kind: &structpb.Value_StringValue{StringValue: "test-service-name"}},
{Kind: &structpb.Value_StringValue{StringValue: "jdk 1.2.3"}},
{Kind: &structpb.Value_NumberValue{NumberValue: 1638770074000}},
{Kind: &structpb.Value_StringValue{StringValue: "erda"}},
},
},
{
Expand All @@ -118,6 +119,7 @@ func Test_apmServiceService_GetServices(t *testing.T) {
{Kind: &structpb.Value_StringValue{StringValue: "test-service-name2"}},
{Kind: &structpb.Value_StringValue{StringValue: "py 1.2.3"}},
{Kind: &structpb.Value_NumberValue{NumberValue: 1638770074000}},
{Kind: &structpb.Value_StringValue{StringValue: "erda"}},
},
},
{
Expand All @@ -126,6 +128,7 @@ func Test_apmServiceService_GetServices(t *testing.T) {
{Kind: &structpb.Value_StringValue{StringValue: "test-service-name3"}},
{Kind: &structpb.Value_StringValue{StringValue: "golang 1.2.3"}},
{Kind: &structpb.Value_NumberValue{NumberValue: 1638770074000}},
{Kind: &structpb.Value_StringValue{StringValue: "erda"}},
},
},
{
Expand All @@ -134,6 +137,7 @@ func Test_apmServiceService_GetServices(t *testing.T) {
{Kind: &structpb.Value_StringValue{StringValue: "test-service-name4"}},
{Kind: &structpb.Value_StringValue{StringValue: "nodejs 1.2.3"}},
{Kind: &structpb.Value_NumberValue{NumberValue: 1638770074000}},
{Kind: &structpb.Value_StringValue{StringValue: "erda"}},
},
},
}},
Expand Down

0 comments on commit 4e559d1

Please sign in to comment.