「GRAFANA-AGENT」- 指标、日志、追踪

认识

文档:https://grafana.com/docs/agent/latest/
仓库:https://github.com/grafana/agent

Grafana Agent 是个终端代理,负责在终端收集信息(并对信息进行加工),然后数据发送给远端的系统(例如日志、监控等等)。

Grafana Agent 是个 OpenTelemetry Collector 发行版,其配置灵感来自 Terraform。它的设计灵活、高性能,并且与 Prometheus 和 OpenTelemetry 等多个生态系统兼容。

补充说明:Grafana Agent has reached End-of-Life (EOL) on November 1, 2025. Agent is no longer receiving vendor support and will no longer receive security or bug fixes. Current users of Agent Static mode, Agent Flow mode, and Agent Operator should proceed with migrating to Grafana Alloy.

组成

Grafana Agent 集成 Metrics、Logging、Tracing 功能,仅通过 Grafana Agent 变成完成各种指标的采集;

Component and Pipeline

Grafana Agent is based around components. Components are wired together to form programmable observability pipelines for telemetry collection, processing, and delivery.

性质

Grafana Agent 提供三种不同的变体:Static vs. Operator vs. Flow

收集数据

转换数据

发送数据

数据能够发送到
1)Grafana 生态(例如 Loki, Grafana, Tempo, Mimir, Pyroscope 等等)
2)Prometheus 生态;
3)OpenTelemetry 生态;

但是,针对我们来说,它最突出的地方是对各种 exporter 做了集成:其内嵌各种 Exporter 服务(诸如 node_exporter、mysql_exporter 等等),还集成 Log、Metric、Trace 的客户端,减轻我们对微服务的管理。

提供 Static Mode 方式

1)The default, original variant of Grafana Agent. 最早期的,最成熟的
2)通过配置文件,来定义需要采集的内容(Logs/Metrics/Traces);

应用
Maturity: You need to use the most mature version of Grafana Agent.
Grafana Cloud integrations: You need to use Grafana Agent with Grafana Cloud integrations.
Complete list of integrations: 该模式的 integration 是最完整的,部分 integration 未在 Flow Mode 中提供;

应用

通过 Grafana Agent 服务,来采集 Kubernetes Pod 日志(替代 Promtail 组件);
Kubernetes Events Collection | 通过 Grafana Agent 服务,来采集 Kubernetes Event 日志

现在(11/21/2023),鉴于项目支持三种模式,并且我们之前使用 Operator 模式,所以我们将按照三种模式来组织笔记。我们采用 Top to Down 方式,究其原因:我们仅使其来解决问题,而非研究内部机理;

参考

Grafana Agent | Grafana Agent documentation