Prometheus实战篇:什么是Exporter

本文涉及的产品
可观测监控 Prometheus 版,每月50GB免费额度
简介: 所有可以向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(样本值)
相关实践学习
容器服务Serverless版ACK Serverless 快速入门:在线魔方应用部署和监控
通过本实验,您将了解到容器服务Serverless版ACK Serverless 的基本产品能力,即可以实现快速部署一个在线魔方应用,并借助阿里云容器服务成熟的产品生态,实现在线应用的企业级监控,提升应用稳定性。
目录
打赏
0
2
3
1
66
分享
相关文章
智能运维实战:Prometheus与Grafana的监控与告警体系
【10月更文挑战第26天】Prometheus与Grafana是智能运维中的强大组合,前者是开源的系统监控和警报工具,后者是数据可视化平台。Prometheus具备时间序列数据库、多维数据模型、PromQL查询语言等特性,而Grafana支持多数据源、丰富的可视化选项和告警功能。两者结合可实现实时监控、灵活告警和高度定制化的仪表板,广泛应用于服务器、应用和数据库的监控。
503 3
Prometheus中的Exporter详解
【10月更文挑战第25天】Prometheus Exporter分为直接采集(如cAdvisor, Kubernetes)和间接采集(如Node Exporter)两类。
智能运维实战:Prometheus与Grafana的监控与告警体系
【10月更文挑战第27天】在智能运维中,Prometheus和Grafana的组合已成为监控和告警体系的事实标准。Prometheus负责数据收集和存储,支持灵活的查询语言PromQL;Grafana提供数据的可视化展示和告警功能。本文介绍如何配置Prometheus监控目标、Grafana数据源及告警规则,帮助运维团队实时监控系统状态,确保稳定性和可靠性。
463 0
SpringCloud微服务实战——搭建企业级开发框架(四十五):【微服务监控告警实现方式二】使用Actuator(Micrometer)+Prometheus+Grafana实现完整的微服务监控
无论是使用SpringBootAdmin还是使用Prometheus+Grafana都离不开SpringBoot提供的核心组件Actuator。提到Actuator,又不得不提Micrometer,从SpringBoot2.x开始,Actuator的功能实现都是基于Micrometer的。
559 57
Prometheus实战篇:Prometheus监控nginx
在此专栏的前几篇文章中已经准备了一台服务器作为我们进行环境的准备.大家也可以通过虚拟机创建俩台服务器,一台作为Prometheus的安装另外一台进行其他软件安装并且进行监控的服务器.
prometheus实战篇:prometheus相关概念
在安装好Prometheus后,会暴露一个/metrics的http服务(相当于安装了prometheus_exporter),通过配置,Prometheus就可以采集到这个/metrics下的所有监控样本数据.
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等