8000 feat: support dynamic label values and global metrics record. by shunjiazhu · Pull Request #2268 · alibaba/loongcollector · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

shunjiazhu
Copy link
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
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
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级?这块有考虑过吗

@@ -27,6 +30,27 @@ const (
MetricExportTypeCpp = "cpp_provided"
)

var globalMetricRecord = globalMetricRecords{records: make(map[*selfmonitor.MetricsRecord]struct{})}
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里的global metric有例子吗?如果是全局级别的(agent级,现有的在pkg/selfmonitor/metrics_constants_agent.go)的指标,要添加到C++部分一起输出的。

还是说这些指标不是agent级,而是某些单例?单例的话可以参考k8s_meta这里的实现,是runner级的,指标等级一定要有

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是的,单例,我加一下runner

// 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
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我晚点补一下

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
0