8000 feat: support send multivalue metrics to sls by Abingcbc · Pull Request #2233 · alibaba/loongcollector · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: support send multivalue metrics to sls #2233

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 6 commits into from
Jun 9, 2025
Merged

Conversation

Abingcbc
Copy link
Collaborator
@Abingcbc Abingcbc commented May 23, 2025

支持flusher_sls写入SLS MetricStore多值接口

接口介绍

SLS MetricStore多值接口与日志接口相同。除此之外,针对多值指标有一些额外的规则:

  1. label与value打平在content中,依赖服务端通过schema判断字段类型。
  2. 时间字段同样位于content中。字段名同样依赖schema,一般客户没有自定义需求。与存储同学交流后,同意约定保留字段。实现上,使用了单值指标的默认字段名,两者统一。

@@ -505,7 +508,8 @@ bool FlusherSLS::Init(const Json::Value& config, Json::Value& optionalGoPipeline
this,
strategy,
!mContext->IsExactlyOnceEnabled() && mShardHashKeys.empty()
&& mTelemetryType != sls_logs::SLS_TELEMETRY_TYPE_METRICS)) {
&& mTelemetryType != sls_logs::SLS_TELEMETRY_TYPE_METRICS
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
Collaborator

Choose a reason for hiding this comment

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

SLS_TELEMETRY_TYPE_APM_METRICS 为什么没有?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

这个APM的目前没什么问题。 @KayzzzZ 后续会测试再提PR

@yyuuttaaoo yyuuttaaoo requested a review from Copilot June 6, 2025 10:12
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

Add support for sending multi-value and host metrics to SLS MetricStore by extending the serializer, client manager, and flusher components, and by adding unit tests and protobuf enum entries.

  • Extended SLSSerializer and LogGroupSerializer to calculate and emit multi-value metric fields.
  • Introduced new telemetry types (metrics_multivalue, metrics_host) in sls_logs.proto, constants, client manager, and flusher logic.
  • Added unit tests for multi-value metrics and fixed a typo in MetricsValue API.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
core/unittest/serializer/SLSSerializerUnittest.cpp Added CreateBatchedMultiValueMetricEvents and tests for various tag/value combos.
core/unittest/flusher/FlusherSLSUnittest.cpp Added config test for metrics_multivalue telemetry type.
core/protobuf/sls/sls_logs.proto Added SLS_TELEMETRY_TYPE_METRICS_MULTIVALUE and METRICS_HOST.
core/plugin/flusher/sls/SLSConstant.h/.cpp Defined new HOSTMETRICS constant for host metrics path.
core/plugin/flusher/sls/SLSClientManager.h/.cpp Added PreparePostHostMetricsRequest to build host metrics requests.
core/plugin/flusher/sls/FlusherSLS.h/.cpp Added CreatePostHostMetricsRequest, ShouldGroupBatch, and telemetry branching.
core/plugin/flusher/sls/DiskBufferWriter.cpp Included METRICS_MULTIVALUE in the switch for dispatch.
core/models/MetricValue.h/.cpp Renamed ValusSize to ValuesSize.
core/collection_pipeline/serializer/SLSSerializer.h/.cpp Extended serializer to support multi-value metric size calculation and serialization.

req = CreatePostLogStoreLogsRequest(accessKeyId, accessKeySecret, type, data);
break;
case sls_logs::SLS_TELEMETRY_TYPE_METRICS_HOST:
req = CreatePostHostMetricsRequest(accessKeyId, accessKeySecret, type, data);
break;
case sls_logs::SLS_TELEMETRY_TYPE_METRICS:
Copy link
Collaborator

Choose a reason for hiding this comment

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

SLS_TELEMETRY_TYPE_APM_AGENTINFOS jq

@Abingcbc Abingcbc merged commit 1b7df94 into main Jun 9, 2025
29 checks passed
wardenjohn pushed a commit to wardenjohn/loo-zyd that referenced this pull request Jun 18, 2025
* feat: support send multivalue metrics to sls

* fix

* fix

* fix

* fix

* fix
@henryzhx8 henryzhx8 deleted the multivalue_metric_flush branch June 26, 2025 03:20
xiongyunn pushed a commit to xiongyunn/loongcollector that referenced this pull request Jun 27, 2025
* feat: support send multivalue metrics to sls

* fix

* fix

* fix

* fix

* fix
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