Skip to content

feat: support dynamic label values and global metrics record.#2268

Closed
shunjiazhu wants to merge 4 commits intoalibaba:mainfrom
shunjiazhu:feat/dynamic-labels
Closed

feat: support dynamic label values and global metrics record.#2268
shunjiazhu wants to merge 4 commits intoalibaba:mainfrom
shunjiazhu:feat/dynamic-labels

Conversation

@shunjiazhu
Copy link
Copy Markdown
Contributor

@shunjiazhu shunjiazhu commented Jun 24, 2025

  1. 增加一个GlobalMetricsRecord,用来记录一些和插件流水线及插件无关的指标
  2. 支持将Go单个MetricVector级别的静态Label和动态可变Label Value序列化后转出给c++,原先这部分信息丢失。

Change-Id: I0ed79c684700adfd35d0ec67385e1b5abc22aaa6
Change-Id: I7dbb706bb72494d5aff7d0be6c1732a56fe421fd
// A metric may have three levels of labels
// 1. MetricsRecord Level Const Labels, like PluginType=flusher_http, PluginId=1
// 2. Metric Level Const Labels, for example, flusher_http may have a const label: RemoteURL=http://aliyun.com/write
// 3. Metric Level Dynamic Labels, like status_code=200, status_code=204
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是可以这样理解:

  1. MetricsRecord级别有一些label,也有一些没有自己label的metrics,他们会输出一个metric记录,也就是Line45这一条
  2. 每个Metric会有自己的一些const和Dynamic label,当有这些label时,一个metric会变成一条单独的metric记录被暴露出来,例如上面的http_flusher_status_code_count * 2,http_flusher_error_count * 3?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

指标是有类型的,go这边key是metric_category,value是agent、runner、这些。https://observability.cn/project/loongcollector/internal-metrics-description/#_top

具有单独label的Metric,是不是需要定义为plugin_source级?这块有考虑过吗

Comment thread pluginmanager/metric_export.go
// 1. MetricsRecord Level Const Labels, like PluginType=flusher_http, PluginId=1
// 2. Metric Level Const Labels, for example, flusher_http may have a const label: RemoteURL=http://aliyun.com/write
// 3. Metric Level Dynamic Labels, like status_code=200, status_code=204
func (m *MetricsRecord) ExportMetricRecords() []map[string]string {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

方便给一个前后对比吗?先前有问题的指标和修改之后的样子

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我晚点补一下

@Takuka0311
Copy link
Copy Markdown
Collaborator

Takuka0311 commented Apr 27, 2026

经百炼自动化审查后,按「重复或已被替代」关闭本项。

本 PR 核心功能已被同作者更新的 PR #2496 涵盖并替代,且当前存在合并冲突与待处理的审查反馈,建议关闭以集中维护。.

最佳落地路径:

关闭本 PR,将动态标签序列化与全局指标记录的审查、测试与合并工作转移至 PR #2496。若需保留本 PR 的特定实现细节,请在 #2496 中同步或基于最新 main 分支重建。.

已核对内容:

后续讨论请以已链接的规范工单为准。

百炼审查备注:模型 qwen3.6-max-preview;对照提交 7099f790b8a3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants