瀏覽代碼

Fixed #TASK_QT-9810 修改target_appid不对应的场景。

rock.wu 1 年之前
父節點
當前提交
2a9dc3aa67
共有 2 個文件被更改,包括 4 次插入3 次删除
  1. 3 2
      containers/container.go
  2. 1 1
      containers/metrics.go

+ 3 - 2
containers/container.go

@@ -378,7 +378,7 @@ func (c *Container) Collect(ch chan<- prometheus.Metric) {
 	strAppName := c.AppInfo.AppName
 	apps := c.registry.GetAllAppInfoFromServer()
 	for d, stats := range c.connectsSuccessful {
-		targetAppId := apps[stats.Src.String()]
+		targetAppId := apps[d.dst.String()]
 		ch <- counter(metrics.NetConnectionsSuccessful, float64(stats.Count), strInstanceID, strAppId, targetAppId, strAppName, stats.Src.String(), d.src.String(), d.dst.String())
 		ch <- counter(metrics.NetConnectionsTotalTime, stats.TotalTime.Seconds(), strInstanceID, strAppId, targetAppId, strAppName, stats.Src.String(), d.src.String(), d.dst.String())
 		if stats.Retransmissions > 0 {
@@ -406,7 +406,8 @@ func (c *Container) Collect(ch chan<- prometheus.Metric) {
 	// 	klog.Infof("c.acceptsSuccessful d.src=%s d.dst=%s stats.BytesSent=%d,stats.BytesReceived=%d", d.src.String(), d.dst.String(), stats.BytesSent, stats.BytesReceived)
 	// }
 	for dst, count := range c.connectsFailed {
-		ch <- counter(metrics.NetConnectionsFailed, float64(count), strInstanceID, strAppId, strAppName, dst.String())
+		targetAppId := apps[dst.String()]
+		ch <- counter(metrics.NetConnectionsFailed, float64(count), strInstanceID, strAppId,targetAppId, strAppName, dst.String())
 	}
 
 	connections := map[AddrPair]int{}

+ 1 - 1
containers/metrics.go

@@ -89,7 +89,7 @@ var metrics = struct {
 	NetListenInfo:            metric("process_net_tcp_listen_info", "Listen address of the process", "listen_addr", "proxy"),
 	NetConnectionsSuccessful: metric("process_net_tcp_successful_connects_total", "Total number of successful TCP connects", "instance_id", "app_id", "target_app_id", "app_name", "src", "destination", "actual_destination"),
 	NetConnectionsTotalTime:  metric("process_net_tcp_connection_time_seconds_total", "Time spent on TCP connections", "instance_id", "app_id", "target_app_id", "app_name", "src", "destination", "actual_destination"),
-	NetConnectionsFailed:     metric("process_net_tcp_failed_connects_total", "Total number of failed TCP connects", "instance_id", "app_id", "app_name", "destination"),
+	NetConnectionsFailed:     metric("process_net_tcp_failed_connects_total", "Total number of failed TCP connects", "instance_id", "app_id","target_app_id", "app_name", "destination"),
 	NetConnectionsActive:     metric("process_net_tcp_active_connections", "Number of active outbound connections used by the process", "destination", "actual_destination"),
 	NetRetransmits:           metric("process_net_tcp_retransmits_total", "Total number of retransmitted TCP segments", "instance_id", "app_id", "target_app_id", "app_name", "src", "destination", "actual_destination"),
 	NetLatency:               metric("process_net_latency_seconds", "Round-trip time between the process and a remote IP", "destination_ip"),