This is an automated email from the ASF dual-hosted git repository.

zqr10159 pushed a commit to branch 2.0.0
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git


The following commit(s) were added to refs/heads/2.0.0 by this push:
     new 073dc37b7b Preserve metric series entity type context
073dc37b7b is described below

commit 073dc37b7b29164e1ab0c0563b1244dd0620b6e6
Author: Logic <[email protected]>
AuthorDate: Wed Jun 10 08:51:53 2026 +0800

    Preserve metric series entity type context
---
 web-next/lib/otlp-metrics/view-model.test.ts | 6 ++++++
 web-next/lib/otlp-metrics/view-model.ts      | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/web-next/lib/otlp-metrics/view-model.test.ts 
b/web-next/lib/otlp-metrics/view-model.test.ts
index 86d9628eb4..91448091ef 100644
--- a/web-next/lib/otlp-metrics/view-model.test.ts
+++ b/web-next/lib/otlp-metrics/view-model.test.ts
@@ -1087,6 +1087,7 @@ describe('otlp metrics view model', () => {
           span_id: 'span-series-42',
           http_route: '/inventory/{id}',
           'hertzbeat.entity_id': '42',
+          'hertzbeat.entity_type': 'service',
           'hertzbeat.entity_name': 'Inventory API',
           'hertzbeat.collector': 'collector-b',
           'hertzbeat.template': 'fastapi'
@@ -1100,6 +1101,7 @@ describe('otlp metrics view model', () => {
     expect(logParams.get('view')).toBe('list');
     expect(logParams.get('search')).toBeNull();
     expect(logParams.get('entityId')).toBe('42');
+    expect(logParams.get('entityType')).toBe('service');
     expect(logParams.get('entityName')).toBe('Inventory API');
     expect(logParams.get('serviceName')).toBe('inventory');
     expect(logParams.get('serviceNamespace')).toBe('warehouse');
@@ -1118,6 +1120,7 @@ describe('otlp metrics view model', () => {
     expect(traceParams.get('spanId')).toBe('span-series-42');
     expect(traceParams.get('operationName')).toBe('/inventory/{id}');
     expect(traceParams.get('entityId')).toBe('42');
+    expect(traceParams.get('entityType')).toBe('service');
 
     const entityHref = new URL(result.entityHref, 'https://example.com');
     expect(entityHref.pathname).toBe('/entities/42');
@@ -1127,11 +1130,14 @@ describe('otlp metrics view model', () => {
     const alertHandlingHref = new URL(result.alertHandlingHref, 
'https://example.com');
     expect(alertHandlingHref.searchParams.get('search')).toBe('inventory');
     expect(alertHandlingHref.searchParams.get('entityId')).toBe('42');
+    expect(alertHandlingHref.searchParams.get('entityType')).toBe('service');
     
expect(alertHandlingHref.searchParams.get('serviceName')).toBe('inventory');
     
expect(alertHandlingHref.searchParams.get('operationName')).toBe('/inventory/{id}');
 
     const alertRulesHref = new URL(result.alertRulesHref, 
'https://example.com');
+    expect(alertRulesHref.searchParams.get('entityType')).toBe('service');
     
expect(alertRulesHref.searchParams.get('operationName')).toBe('/inventory/{id}');
+    
expect(alertRulesHref.searchParams.get('alertQuery')).toContain('entityType=service');
     
expect(alertRulesHref.searchParams.get('alertQuery')).toContain('operationName=/inventory/{id}');
   });
 
diff --git a/web-next/lib/otlp-metrics/view-model.ts 
b/web-next/lib/otlp-metrics/view-model.ts
index 53fa2ff451..f1d03d7d84 100644
--- a/web-next/lib/otlp-metrics/view-model.ts
+++ b/web-next/lib/otlp-metrics/view-model.ts
@@ -146,6 +146,7 @@ export function buildMetricsAlertRuleDraft(
     ['aggregation', query.aggregation],
     ['groupBy', query.groupBy],
     ['entityId', query.entityId || routeContext.entityId],
+    ['entityType', query.entityType || routeContext.entityType],
     ['entityName', query.entityName || routeContext.entityName],
     ['serviceName', query.serviceName || routeContext.serviceName],
     ['serviceNamespace', query.serviceNamespace || 
routeContext.serviceNamespace],
@@ -187,6 +188,7 @@ function buildMetricSeriesSignalContext(series: 
OtlpMetricSeriesView | null | un
   if (!series) return {};
   return {
     entityId: readEntityIdRouteParam(readSeriesLabel(series, 
'hertzbeat.entity_id', 'hertzbeat_entity_id', 'entity.id', 'entity_id')),
+    entityType: readSeriesLabel(series, 'hertzbeat.entity_type', 
'hertzbeat_entity_type', 'entity.type', 'entity_type'),
     entityName: readSeriesLabel(series, 'hertzbeat.entity_name', 
'hertzbeat_entity_name', 'entity.name', 'entity_name'),
     serviceName: readSeriesLabel(series, 'service.name', 'service_name', 
'serviceName'),
     serviceNamespace: readSeriesLabel(series, 'service.namespace', 
'service_namespace', 'serviceNamespace'),
@@ -972,6 +974,7 @@ export function buildMetricsHandoffLinks(
     ...routeContext,
     ...query,
     entityId: selectedContext.entityId || query.entityId || 
(data.context?.entityId != null ? String(data.context.entityId) : 
routeContext.entityId),
+    entityType: selectedContext.entityType || query.entityType || 
(data.context?.entityType != null ? String(data.context.entityType) : 
routeContext.entityType),
     entityName: selectedContext.entityName || query.entityName || 
firstText(data.context?.entityName ?? undefined, routeContext.entityName),
     serviceName,
     serviceNamespace,


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to