You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2026/06/23 13:06:33 UTC

(skywalking-cli) branch master updated: Add --value-column / --value-type to `admin inspect entities` for foreign-metric inspect (#230)

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

wu-sheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-cli.git


The following commit(s) were added to refs/heads/master by this push:
     new c0b5f58  Add --value-column / --value-type to `admin inspect entities` for foreign-metric inspect (#230)
c0b5f58 is described below

commit c0b5f58f69666761e526314ef15911450eb958f2
Author: 吴晟 Wu Sheng <wu...@foxmail.com>
AuthorDate: Tue Jun 23 21:06:27 2026 +0800

    Add --value-column / --value-type to `admin inspect entities` for foreign-metric inspect (#230)
    
    * Add --value-column / --value-type to admin inspect entities for foreign-metric inspect
    
    SkyWalking OAP's /inspect/entities now accepts a metric persisted by another OAP
    (one this node does not define locally) when the caller supplies the metric's
    value column + type. Expose those as --value-column / --value-type on
    `swctl admin inspect entities`; both are passed through as query params and are
    required only when the metric is unknown to the target OAP's local registry.
---
 internal/commands/admin/inspect/inspect.go | 28 +++++++++++++++++++++-------
 pkg/admin/inspect/inspect.go               | 13 ++++++++++++-
 2 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/internal/commands/admin/inspect/inspect.go b/internal/commands/admin/inspect/inspect.go
index 528d6c6..385807a 100644
--- a/internal/commands/admin/inspect/inspect.go
+++ b/internal/commands/admin/inspect/inspect.go
@@ -92,7 +92,11 @@ Each row carries an MQE-ready entity to paste into a follow-up "swctl metrics ex
 
 Examples:
 1. Entities reporting service_cpm in the last 30 minutes:
-$ swctl admin inspect entities --metric service_cpm`,
+$ swctl admin inspect entities --metric service_cpm
+
+2. Inspect a metric persisted by ANOTHER OAP (not defined on this OAP) — supply its value
+   column + type so the OAP resolves it from storage without its local registry:
+$ swctl admin inspect entities --metric meter_foo --value-column value --value-type LONG`,
 	Flags: flags.Flags(
 		flags.DurationFlags,
 		[]cli.Flag{
@@ -105,6 +109,14 @@ $ swctl admin inspect entities --metric service_cpm`,
 				Name:  "limit",
 				Usage: fmt.Sprintf("max rows scanned at the storage layer (1-%d, server default 300)", inspect.MaxLimit),
 			},
+			&cli.StringFlag{
+				Name:  "value-column",
+				Usage: "the metric's value `column` (e.g. value, value_, double_value); REQUIRED when the metric is not defined on the target OAP",
+			},
+			&cli.StringFlag{
+				Name:  "value-type",
+				Usage: "value data `type` (LONG / INT / DOUBLE / LABELED); REQUIRED when the metric is not defined on the target OAP",
+			},
 		},
 	),
 	Before: interceptor.BeforeChain(
@@ -117,12 +129,14 @@ $ swctl admin inspect entities --metric service_cpm`,
 		}
 		step := ctx.Generic("step").(*model.StepEnumValue).Selected
 
-		entities, err := inspect.ListEntities(ctx.Context, inspect.EntitiesOptions{
-			Metric: ctx.String("metric"),
-			Start:  ctx.String("start"),
-			End:    ctx.String("end"),
-			Step:   string(step),
-			Limit:  limit,
+		entities, err := inspect.ListEntities(ctx.Context, &inspect.EntitiesOptions{
+			Metric:      ctx.String("metric"),
+			Start:       ctx.String("start"),
+			End:         ctx.String("end"),
+			Step:        string(step),
+			Limit:       limit,
+			ValueColumn: ctx.String("value-column"),
+			ValueType:   ctx.String("value-type"),
 		})
 		if err != nil {
 			return preflight.Explain(ctx.Context, err, preflight.ModuleInspect, "SW_INSPECT")
diff --git a/pkg/admin/inspect/inspect.go b/pkg/admin/inspect/inspect.go
index 6ff9807..ef3ee20 100644
--- a/pkg/admin/inspect/inspect.go
+++ b/pkg/admin/inspect/inspect.go
@@ -82,6 +82,11 @@ type EntitiesOptions struct {
 	End    string
 	Step   string
 	Limit  int
+	// ValueColumn / ValueType are required only when the metric is NOT defined on the target OAP
+	// (a metric persisted by another OAP). When set, the OAP resolves the metric from storage
+	// using this caller-supplied metadata instead of its local registry.
+	ValueColumn string
+	ValueType   string
 }
 
 // ListMetrics lists the registered metric catalog (GET /inspect/metrics).
@@ -107,7 +112,7 @@ func ListMetrics(ctx context.Context, opts MetricsOptions) (*Metrics, error) {
 
 // ListEntities enumerates the entities holding values for a metric over a time range
 // (GET /inspect/entities). Only REGULAR_VALUE / LABELED_VALUE metrics are accepted.
-func ListEntities(ctx context.Context, opts EntitiesOptions) (*Entities, error) {
+func ListEntities(ctx context.Context, opts *EntitiesOptions) (*Entities, error) {
 	query := url.Values{}
 	query.Set("metric", opts.Metric)
 	query.Set("start", opts.Start)
@@ -116,6 +121,12 @@ func ListEntities(ctx context.Context, opts EntitiesOptions) (*Entities, error)
 	if opts.Limit > 0 {
 		query.Set("limit", strconv.Itoa(opts.Limit))
 	}
+	if opts.ValueColumn != "" {
+		query.Set("valueColumn", opts.ValueColumn)
+	}
+	if opts.ValueType != "" {
+		query.Set("valueType", opts.ValueType)
+	}
 
 	var out Entities
 	err := client.GetJSON(ctx, "/inspect/entities", query, &out)