Prometheus实战篇:什么是Exporter

简介: 所有可以向Prometheus提供监控样本数据的程序都可以被称为一个Exporter.而Exporter的一个实例称为target,如图下所示,Prometheus通过轮询的方式定期从这些target中获取样本数据

概述

所有可以向Prometheus提供监控样本数据的程序都可以被称为一个Exporter.而Exporter的一个实例称为target,如图下所示,

Prometheus通过轮询的方式定期从这些target中获取样本数据:


这里Prometheus是通过pull(拉取的方式)从Target中获取样本数据

安装好Exporter后会暴露一个/metrics的HTTP服务,通过Prometheus添加配置Prometheus就可以采集到这个/metrics里面的所有监控样本数据

- targets: ['node_exporter:9100'] 会自动带上/metrics

Exporter的来源

从exporter的来源上来讲,一共分俩类:

社区提供的

社区提供 (https://prometheus.io/docs/instrumenting/exporters/)

Prometheus社区提供了丰富的Exporter实现,涵盖了从基础设施,中间件一级网络等各个方面的监控功能.这些Exporter可以实现大部分通用的监控需求.下表列举一些社区中常用的Exporter:

使用范围

常用的Exporter

数据库

MySQL Exporter,RedisExporter,MongDB Exporter,MSSQL Exporter等

硬件

Apcupsd Exporter,IoT Edison Exporter,IPMI Exporter等

消息队列

Kafka Exporter,RabbitMQ Exporter,NSQ Exporter等

存储

Ceph Exporter,Gluster Exporter,HDFS Exporter,等

HTTP服务

Apache Exporter,HAProxy Exporter,Nginx Exporter等

API服务

AWS Exporter,Docker Cloud Exporter,Docker Hub  Exporter,GitHub Exporter等

日志

Flue Exporter,Grok Exporter等

监控系统

Collectd Exporter,Graphite Exporter,InfluxDB Exporter,Nagios Exporter等

其他

Blockbox Exporter,JIRA Exporter,Jenkins Exporter,Confluence Exporter等

用户自定义

除了直接使用社区提供的Exporter程序意外,用户还可以基于Prometheus提供的Client Library创建自己的Exporter程序,目前Prometheus社区官方提供了对以下编程语言的支持:Go,java,Python,Ruby.同事还有第三方实现的如:Bash,C++,Common Lisp,Erlang,Haskeel,Lua,Node.js,PHP,Rust等.

Exporter类型

通常来说可以将Exporter分为俩类

  • 直接采集型
    这类Exporter直接内置了相应的应用程序,用于向Prometheus直接提供Target数据支持.这样设计的好处是,可以更好的监控各自系统的内部运行状态,同时也适合更多自定义监控指标的项目实施.例如k8s 等.他们均内置了用于Prometheus提供监控数据的端点.
  • 间接采集型
    原始监控目标并不直接支持Prometheus,需要我们使用Prometheus提供的Client Library编写该监控目标的监控采集程序,用户可以将该程序独立运行,去获取指定的各类监控数据值.例如,由于Linux操作系统自身并不能直接支持Prometheus.用户无法从操作系统层面上直接提供对Prometheus的支持,因此单独安装Node Exporter,还有数据库或网站HTTP应用类等Exporter.

Exporter规范

所有的Exporter程序都需要按照Prometheus的规范,返回监控的样本数据.以Node Exporter为例,当访问/metrics结尾地址时会返回一下内容:

# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 4.029e-05
go_gc_duration_seconds{quantile="0.25"} 5.2092e-05
go_gc_duration_seconds{quantile="0.5"} 6.3091e-05
go_gc_duration_seconds{quantile="0.75"} 8.9905e-05
go_gc_duration_seconds{quantile="1"} 0.000300032
go_gc_duration_seconds_sum 2.6172319120000003
go_gc_duration_seconds_count 36170
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 9
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.19.3"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 2.19788e+06

以#开头的行通常都是注释内容,这些样本数据集合说明如下:

  • 以#HELP开始的行,表示metric的帮助与说明注释,可以包含当前监控指标名称和对应的说明信息.
  • 以#TYPE开始的行,表示定义metric类型,可以包含当前监控指标名称和类型,类型有Counter,Gauge....
  • 非#开头的行,就是监控样本数据

样本数据如何存储Prometheus的库中

//这种方式进行展示
go_memstats_alloc_bytes 2.19788e+06
//这种方式进行存储
go_memstats_alloc_bytes{instance="localhost:9090", job="prometheus"} timestamp(时间戳) value(样本值)
相关文章
|
3月前
|
Prometheus Kubernetes 监控
|
4月前
|
Prometheus 监控 Cloud Native
Prometheus实战篇:Prometheus监控docker
Prometheus实战篇:Prometheus监控docker
|
4月前
|
Prometheus 监控 Cloud Native
Prometheus实战篇:Prometheus监控mongodb
Prometheus实战篇:Prometheus监控mongodb
|
4月前
|
消息中间件 Prometheus 监控
Prometheus实战篇:Prometheus监控rabbitmq
Prometheus实战篇:Prometheus监控rabbitmq
|
4月前
|
Prometheus 监控 Cloud Native
|
4月前
|
Prometheus 监控 Cloud Native
Prometheus实战篇:Prometheus监控nginx
在此专栏的前几篇文章中已经准备了一台服务器作为我们进行环境的准备.大家也可以通过虚拟机创建俩台服务器,一台作为Prometheus的安装另外一台进行其他软件安装并且进行监控的服务器.
|
5月前
|
存储 Prometheus 监控
prometheus实战篇:prometheus相关概念
在安装好Prometheus后,会暴露一个/metrics的http服务(相当于安装了prometheus_exporter),通过配置,Prometheus就可以采集到这个/metrics下的所有监控样本数据.
|
5月前
|
Prometheus Cloud Native 数据安全/隐私保护
Prometheus实战篇:docker安装Prometheus
Docker搭建Prometheus监控系统
|
5月前
|
存储 Prometheus 监控
Prometheus实战篇:Prometheus简介
Prometheus 是一个开源的服务监控系统和时序数据库,其提供了通用的数据模型和快捷数据采集、存储和查询接口。
|
4月前
|
编解码 Prometheus 运维
Prometheus 的监控方法论
【1月更文挑战第24天】