参考
监控
- promethus+grafana:grafana中通过配置仪表盘(写PromQL)监控指标
- springboot应用所有指标:http://localhost:8880/actuator/prometheus获取
- 已有指标可以重载方法进行修改扩展
- 支持自定义Metrics指标:有四种类型
public class PrometheusMetricsInterceptor extends HandlerInterceptorAdapter {
static final Counter requestCounter = Counter.build()
.name("io_namespace_http_requests_total").labelNames("path", "method", "code")
.help("Total requests.").register();
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
String requestURI = request.getRequestURI();
String method = request.getMethod();
int status = response.getStatus();
requestCounter.labels(requestURI, method, String.valueOf(status)).inc();
super.afterCompletion(request, response, handler, ex);
}
}
Histogram和Sumamry区别:不同在于Histogram可以通过histogram_quantile函数在服务器端计算分位数。 而Sumamry的分位数则是直接在客户端进行定义。因此对于分位数的计算。 Summary在通过PromQL进行查询时有更好的性能表现,而Histogram则会消耗更多的资源。相对的对于客户端而言Histogram消耗的资源更少。
告警
promethus+alertmanager:Prometheus 是一个非常强大的监控系统,它不仅能够收集和存储时间序列数据,还能通过 Alertmanager 提供灵活的报警机制。Alertmanager 负责接收 Prometheus 发送的警报,并根据配置的规则执行相应的通知动作。本文将详细介绍如何配置 Alertmanager 以及如何使用它来实现基于 Prometheus 指标的报警通知。
garafna
- 支持多种数据源。
- 图表基本以时间为主(sql或者模版字段配置,x/y/图标序列自定义)。
- 常用模版可以import模板市场中的模板。
- 大部分需要和promethus配合使用