Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

通知给飞书的告警时间Alert.StartsAt值有问题 #276

Open
ColeSu-n opened this issue Dec 10, 2024 · 4 comments
Open

通知给飞书的告警时间Alert.StartsAt值有问题 #276

ColeSu-n opened this issue Dec 10, 2024 · 4 comments

Comments

@ColeSu-n
Copy link

ColeSu-n commented Dec 10, 2024

configMap notification-manager-template

....

{{ define "nm.feishu.text" }} {{ range.Alerts }}
    {{ template "nm.default.message". }}
    时间: {{ .StartsAt }}
    {{ range.Labels.SortedPairs }}
        {{.Name | translate }}: {{.Value }}
    {{ end }}
{{ end }} {{- end }}

...

实际飞书中接收到告警内容

[触发中] 过去3分钟内,kube - proxy存在没有本地端点的代理规则,这可能导致某些服务无法正确路由。检查服务的端点配置和kube - proxy
    时间: 0001-01-01 00:00:00 +0000 UTC
    
        告警名称: KubeProxySyncProxyRulesNoLocalEndpoints
    
        告警类型: metric
    
        集群: prod
    
        endpoint: http-metrics
    
        实例: xxxx
    
        任务: kube-proxy-metrics
    
        项目: kube-system
    
        容器组: kube-proxy-jnfdg
    
        receiver: global-feishu-receiver
    
        rule_group: kube-proxy-alert
    
        rule_level: cluster
    
        rule_type: custom
    
        服务: kube-proxy-metrics
    
        告警级别: warning
    
        traffic_policy: external

时间: 0001-01-01 00:00:00 +0000 UTC
这个值还是零值,是没有赋值吗

@ColeSu-n
Copy link
Author

{{ define "nm.feishu.text" }} {{ range.Alerts }}
    时间: {{ .StartsAt }}
    {{ template "nm.default.message". }}
    {{ range.Labels.SortedPairs }}
        {{.Name | translate }}: {{.Value }}
    {{ end }}
{{ end }} {{- end }}

这种写法也是同样的问题

@ColeSu-n
Copy link
Author

ColeSu-n commented Dec 10, 2024

我想我解决了这个问题,我改了源码中的StartsAt字段的类型,不应该用time.Time类型,我改为string,fork到自己的repo中改的,并且改完后nm镜像已上传到docker.io/colesun/test:v1,这是个public,从dockerhub拉镜像,需要你们本地docker login docker.io

@benjaminhuo
Copy link
Member

我想我解决了这个问题,我改了源码中的StartsAt字段的类型,不应该用time.Time类型,我改为了string,回来不影响源码,我fork到自己的repo中改的,并且改完后nm镜像已上传到docker.io/colesun/test:v1,这是个public,从dockerhub拉镜像,需要你们本地docker login docker.io

可以提个 PR,@wanjunlei 看看是否需要 merge

@ColeSu-n
Copy link
Author

@wanjunlei #277 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants