系统架构
架构图
架构说明
类 | 说明 |
---|---|
CollectorRegister | 所有Collector的容器,exporter从CollectorRegister获取所有的Metrics度量信息 |
Collector | 一个Collector为一个metrics的收集器,收集该metrics的labels对应的所有label_values的指标信息,常见子类Counter,Gauge,直方图Histogram,分位图summary |
Child | 每一个Metric有多个label_name数据,(abel_name对应多组label_values)一组label_values对应一个child,对目标对象监控时,child为监控对象指标的容器 |
MetricFamilySamples | CollectorRegister进行统一收集时,将每个Collector的child中的数据转化为MetricFamilySamples |
Sample | 一组sample构成一个MetricFamilySamples,一个sample对应一个Collector.child,对应一组label_values |
Exemplar | Sample被prometheus采集后用来构建线条, Exemplar为一些打点数据, |
Builder | 负责构建Collector,建造者模式 |
MetricFamilySamplesEnumeration | CollectorRegister负责Collector的注册, MetricFamilySamplesEnumeration负责汇总对prometheus的指标采集 |
源码架构
- 核心关注simpleclient
- 核心关注simplecommon
- simpleclient_tracer与openTrace属于Trace体系,本文不做分析
client_java
|--benchmarks <explain [基准测试] />
|--integration_tests <explain [集成测试] />
|--simpleclient<explain [核心模块] />
|--simpleclient_bom <explain [bom 依赖] />
|--simpleclient_caffeine <explain [collector of caffeine cache] />
|--simpleclient_common <explain [协议输出模块] />
|--simpleclient_dropwizard <explain [collector of Dropwizard ] />
|--simpleclient_graphite_bridge <explain [exporter to graphite link at github.com_graphite-project_graphite-web] />
|--simpleclient_guava <explain [collector of guava cache]] />
|--simpleclient_hibernate <explain [collector of ORM ] />
|--simpleclient_hotspot <explain [collector hotspot] />
|--simpleclient_httpserver <explain[exporter httpserver] />
|--simpleclient_jetty <explain [collector of jetty] />
|--simpleclient_jetty_jdk8 <explain [collector of jetty 线程池] />
|--simpleclient_log4j <explain [collector 结合日志扩展点的Collector] />
|--simpleclient_log4j2 <explain [collector 结合日志扩展点的Collector] />
|--simpleclient_logback <explain [collector 结合日志扩展点的Collector] />
|--simpleclient_pushgateway <explain [exporter 主动推送至pushgateway] />
|--simpleclient_servlet <explain [exporter adapter of servlet] />
|--simpleclient_servlet_common <explain [exporter of servlet] />
|--simpleclient_servlet_jakarta <explain [exporter adapter of jakarta] />
|--simpleclient_spring_boot <explain [ collector adapter of springboot ] />
|--simpleclient_spring_web <explain [ exporter of Summary collector by spring AOP] />
|--simpleclient_tracer <explain[tracer模块,openTraceing] />]
| |--simpleclient_tracer_common
| |--simpleclient_tracer_otel
| |--simpleclient_tracer_otel_agent
|--simpleclient_vertx <explain [ exporter for vertx ] />
|--simpleclient_vertx4 <explain [ exporter for vertx ] />
总结
- Prometheus采用微内核多模块设计[simple_client作为内核,如需要观测不同的领域,则构建不同模块的Collector]
文本协议详细介绍
- TextFormat负责[文本格式]序列化
- 0.0.4版本不携带Exemplar信息【# {lable_name =“lable_value”} 222.0 1663394993.752 】
- 1.0.0版本携带Exemplar信息【# {lable_name =“lable_value”} # {lable_name =“lable_value”} 222.0 1663394993.752 】
- 下图展示了[有|无]Exemplar区别;有Exemplar则曲线之外包含一些样本点
序列化版本CONTENT_TYPE_OPENMETRICS_100
# TYPE counter counter
# HELP counter meh
counter_total{lable_name="lable_value"} 222.0 # {lable_name ="lable_value"} 222.0 1663394993.752
counter_created{lable_name ="lable_value"} 1.663394991658E9
序列化版本CONTENT_TYPE_004
# HELP tomcat_global_sent_bytes_total
# TYPE tomcat_global_sent_bytes_total counter
tomcat_global_sent_bytes_total{application="appcenter",name="http-nio-8080",} 22490.0
- 白色的点表示含有exemplar
- 黑色的点表示含有exemplar