8000 feat: add instance labels into host monitor metrics by Abingcbc · Pull Request #2226 · alibaba/loongcollector · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: add instance labels into host monitor metrics #2226

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

Merged
merged 3 commits into from
Jun 6, 2025

Conversation

Abingcbc
Copy link
Collaborator

商业版主机监控指标默认添加 instance_id 和 user_id 两个标签。
开源版主机监控指标默认添加 host_ip 标签。

TODO

对于Label的处理,后续Loongcollector SPL支持处理Metric后,可以通过SPL进行删除和重命名

@yyuuttaaoo yyuuttaaoo requested a review from Copilot June 1, 2025 17:57
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds functionality to tag host monitor metrics with instance and user labels for the enterprise version and with a host IP label for the open-source version.

  • Added a new method AddHostLabels in HostMonitorInputRunner to assign labels.
  • Introduced new constants for default tag names in both enterprise and open-source modes.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
core/host_monitor/HostMonitorInputRunner.h Added declaration of AddHostLabels method
core/host_monitor/HostMonitorInputRunner.cpp Calls AddHostLabels to tag metrics and implements label assignment
core/host_monitor/Constants.h Added declaration of new label constants under conditional macros
core/host_monitor/Constants.cpp Defined the new label constants for enterprise and open-source builds

@@ -197,4 +209,30 @@ void HostMonitorInputRunner::PushNextTimerEvent(const std::chrono::steady_clock:
Timer::GetInstance()->PushEvent(std::move(event));
}

void HostMonitorInputRunner::AddHostLabels(PipelineEventGroup& group) {
#ifdef __ENTERPRISE__
auto userID = group.GetSourceBuffer()->CopyString(EnterpriseConfigProvider::GetInstance()->GetAliuidSet());
Copy link
Collaborator

Choose a reason for hiding this comment

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

允许多个uid?

Copy link
Collaborator Author
@Abingcbc Abingcbc Jun 5, 2025

Choose a reason for hiding this comment

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

应该取ECS Meta中的user id

@yyuuttaaoo yyuuttaaoo merged commit 459c83d into alibaba:main Jun 6, 2025
22 checks passed
WRPStephanie pushed a commit to WRPStephanie/loongcollector that referenced this pull request Jun 20, 2025
* feat: add instance labels into host monitor metrics
xiongyunn pushed a commit to xiongyunn/loongcollector that referenced this pull request Jun 27, 2025
* feat: add instance labels into host monitor metrics
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.

3 participants
0