Skip to content

Commit

Permalink
feat: report pod silence to server (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
xzchaoo authored Sep 11, 2023
1 parent 48857f6 commit 1a791cd
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions pkg/k8s/silence/pod_update_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
package silence

import (
"github.com/traas-stack/holoinsight-agent/pkg/ioc"
"github.com/traas-stack/holoinsight-agent/pkg/logger"
"github.com/traas-stack/holoinsight-agent/pkg/meta"
"github.com/traas-stack/holoinsight-agent/pkg/server/registry/pb"
"go.uber.org/zap"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/fields"
Expand Down Expand Up @@ -162,11 +165,28 @@ func (l *PodUpdateListener) OnPodDel(obj interface{}) {
}

func (l *PodUpdateListener) EnterSilence(pod *v1.Pod) {
// TODO report to server side
logger.Metaz("[k8s-op] [pod] enter silence", zap.String("ns", pod.Namespace), zap.String("name", pod.Name))

tags := meta.ExtractPodCommonTags(pod)
tags["event"] = "enter"
ioc.RegistryService.ReportEventAsync(&pb.ReportEventRequest_Event{
EventTimestamp: time.Now().UnixMilli(),
EventType: "DIGEST",
PayloadType: "pod_silence",
Tags: tags,
})

}

func (l *PodUpdateListener) LeaveSilence(pod *v1.Pod) {
// TODO report to server side
logger.Metaz("[k8s-op] [pod] leave silence", zap.String("ns", pod.Namespace), zap.String("name", pod.Name))

tags := meta.ExtractPodCommonTags(pod)
tags["event"] = "leave"
ioc.RegistryService.ReportEventAsync(&pb.ReportEventRequest_Event{
EventTimestamp: time.Now().UnixMilli(),
EventType: "DIGEST",
PayloadType: "pod_silence",
Tags: tags,
})
}

0 comments on commit 1a791cd

Please sign in to comment.