Giter VIP home page Giter VIP logo

prometheus_practice's Issues

wechat告警消息格式化

alertmanager发送到wechat的消息原始格式不易读,使用templates文件也无法实现wechat消息的格式化。
请问如何实现wechat text消息的内容和格式定制?谢谢!

wechat告警模板中隐藏instance中ip前几位如何实现!

import (
	"strings"
)
{{- define "_alert_list" -}}
{{- range .Alerts.Firing -}}
--------
告警类型:{{ .Labels.alertname }}
告警主题: {{ .Annotations.summary }}
告警机器:{{  strings.Join("***",strings.Split(.Labels.instance, ".")[3])}} {{ .Labels.device }}
告警详情: {{ .Annotations.description }}
触发时间: {{ (.StartsAt.Add 28800e9).Format "2006-01-02 15:04:05" }}
{{ end -}}
{{- end -}}

{{- define "_resolve_list" -}}
{{- range .Alerts.Resolved -}}
************
告警类型:{{ .Labels.alertname }}
告警主题: {{ .Annotations.summary }}
告警机器:{{ strings.Join("***",strings.Split(.Labels.instance, ".")[3])}} {{ .Labels.device }}
告警详情: {{ .Annotations.description }}
触发时间: {{ (.StartsAt.Add 28800e9).Format "2006-01-02 15:04:05" }}
恢复时间: {{ (.EndsAt.Add 28800e9).Format "2006-01-02 15:04:05" }}
{{ end -}}
{{- end -}}

{{- define "wechat.html" -}}
{{- if and (gt (len .Alerts.Firing) 0) (gt (len .Alerts.Resolved) 0) -}}
Alerts Firing:{{.Alerts.Firing | len}}
Alerts Resolved:{{len .Alerts.Resolved}}
{{ template "_alert_list" . }}
{{ template "_resolve_list" . }}
{{- else -}}
  {{- if gt (len .Alerts.Firing) 0 -}}
Alerts Firing:{{.Alerts.Firing | len}}
{{ template "_alert_list" . }}
  {{- end -}}
  {{- if gt (len .Alerts.Resolved) 0 -}}
Alerts Resolved:{{len .Alerts.Resolved}}
{{ template "_resolve_list" . }}
  {{- end -}}
{{- end -}}
{{- end -}}

报错信息如下:failed to reload config: template: wechat.tmpl:4: function "strings" not defined,请问如何在go template中引入strings

关于Prometheus一些聚合函数的问题

http://127.0.0.1:9090/api/v1/query_range?query=sum_over_time(Jvm_Thread_MemUsage[10s])&start=2018-10-18T02:00:00Z&end=2018-10-18T02:00:15Z&step=15s
对于上面的语句有一些不明白,希望大佬可以解答一下。
1:sum_over_time这个函数在查询时是否已经对时间进行分组。
2:这个语句对应的SQL语句是什么样的。
3:为什么通过这个语句查出的数据结果与我自己算的结果有些差异。
4:我想取规定时间、固定时间间隔的数据总和应该怎么取,就像下图这样
2018-10-22 10-50-16
刚开始接触prometheus数据库,问题比较多,麻烦大佬了,非常感谢。

图片重新整理

书稿中的图片存在以下问题:

建议:

  • 图片全部统一命名格式,例如 1-1-pic1.jpg, 1-1-pic2.jps
  • 图片全部统一存储在一个服务器或者统一存储在本地,方便日后维护

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.