Skip to content

Commit 133bb0b

Browse files
committed
feat: prometheus data uses pod name to match pod ns and pod group.
1 parent 499d884 commit 133bb0b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

server/ingester/prometheus/decoder/decoder.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,16 @@ func (b *PrometheusSamplesBuilder) fillUniversalTagSlow(m *dbwriter.PrometheusSa
507507
t.L3EpcID = b.platformData.QueryVtapEpc0(m.OrgId, vtapID)
508508
var ip net.IP
509509
var hasMatched bool
510+
podGroupType := uint8(0)
510511
if podName != "" {
511512
podInfo := b.platformData.QueryPodInfo(m.OrgId, vtapID, podName)
512513
if podInfo != nil {
513514
t.PodClusterID = uint16(podInfo.PodClusterId)
514515
t.PodID = podInfo.PodId
515516
t.L3EpcID = podInfo.EpcId
517+
t.PodNSID = uint16(podInfo.PodNsId)
518+
t.PodGroupID = podInfo.PodGroupId
519+
podGroupType = podInfo.PodGroupType
516520
ip = net.ParseIP(podInfo.Ip)
517521
// maybe Pod is hostnetwork mode or can't get pod IP, then get pod node IP instead
518522
if ip == nil {
@@ -556,14 +560,10 @@ func (b *PrometheusSamplesBuilder) fillUniversalTagSlow(m *dbwriter.PrometheusSa
556560
} else {
557561
info = b.platformData.QueryIPV4Infos(m.OrgId, t.L3EpcID, t.IP)
558562
}
559-
podGroupType := uint8(0)
560563
if info != nil {
561564
t.RegionID = uint16(info.RegionID)
562565
t.AZID = uint16(info.AZID)
563566
t.HostID = uint16(info.HostID)
564-
t.PodGroupID = info.PodGroupID
565-
podGroupType = uint8(info.PodGroupType)
566-
t.PodNSID = uint16(info.PodNSID)
567567
t.PodNodeID = info.PodNodeID
568568
t.SubnetID = uint16(info.SubnetID)
569569
t.L3DeviceID = info.DeviceID
@@ -574,6 +574,15 @@ func (b *PrometheusSamplesBuilder) fillUniversalTagSlow(m *dbwriter.PrometheusSa
574574
if t.PodID == 0 {
575575
t.PodID = info.PodID
576576
}
577+
if t.PodNSID == 0 {
578+
t.PodNSID = uint16(info.PodNSID)
579+
}
580+
if t.PodGroupID == 0 {
581+
t.PodGroupID = info.PodGroupID
582+
}
583+
if podGroupType == 0 {
584+
podGroupType = uint8(info.PodGroupType)
585+
}
577586

578587
// if it is just Pod Node, there is no need to match the service
579588
if common.IsPodServiceIP(t.L3DeviceType, t.PodID, 0) {

0 commit comments

Comments
 (0)