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

重写GetTimeDuration方法,将持续时间为开始时间与当前时间的间隔改为开始时间和结束时间的间隔(默认) #448

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

Leif160519
Copy link
Contributor

@Leif160519 Leif160519 commented Oct 15, 2024

说明:
重写GetTimeDuration方法,将原先的传一个开始时间参数改为传开始时间和结束时间两个参数

告警模板写法:

🧭 持续时间: {{GetTimeDuration  $v.startsAt $v.endsAt}}

当然也可以计算当前时间和开始时间的间隔

🧭 持续时间: {{GetTimeDuration  $v.startsAt (GetCSTtime "")}}

效果:

  • 修复前
    image
  • 修复后
    与结束时间间隔
    image
    与当前时间间隔
    image

#390 #332

@12ymg
Copy link

12ymg commented Oct 15, 2024

20241015-183027
20241015-183101
我改完后,结束时间看起来抓取的不对

@Leif160519
Copy link
Contributor Author

Leif160519 commented Oct 15, 2024

20241015-183027 20241015-183101 我改完后,结束时间看起来抓取的不对

告警没有恢复就不因该有持续时间,你可以在告警类型上加判断

{{- if eq $v.status "resolved" }}
🧭 结束时间:{{ GetCSTtime $v.endsAt }}
🧭 持续时间:  {{GetTimeDuration  $v.startsAt $v.endsAt}}{{ end }}

@feiyu563 feiyu563 merged commit 810d3ee into feiyu563:master Oct 16, 2024
@feiyu563
Copy link
Owner

感谢提交

@ilanni2460
Copy link

ilanni2460 commented Nov 21, 2024

本地测试 ok的

2024-11-21_230456

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

Successfully merging this pull request may close these issues.

4 participants