Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
# Unreleased

## Breaking Changes & Upgrade Notes

### Instance Metric dashboard URL contract ([#1591](https://github.com/apache/dubbo-admin/pull/1591))

The Instance Metric dashboard's user-visible `var-instance` URL parameter changes
from `IP:QoSPort` to the instance's bare IP address. For example,
`var-instance=10.42.1.10:22222` becomes `var-instance=10.42.1.10`. This does not
change Prometheus's `instance` scrape-target label, which remains an internal
association key for metrics without a native `ip` label.

Upgrade the Admin backend and Grafana Instance Metric dashboard as a coordinated
change:

1. Deploy the updated Admin backend.
2. Update Grafana's provisioned dashboard definitions from the same version and
reload or redeploy them; updating Admin alone does not update Grafana.
3. Reopen Instance Metric from Admin and verify that the URL contains a bare IP
and that the dashboard selects the intended application's instance data.

Avoid using Instance Metric during the mixed-version upgrade window. An old
backend with the new dashboard, or a new backend with a dashboard expecting
`IP:port`, can produce empty or incorrect results. There is no runtime version
guard or automatic fallback for this mismatch.

Update saved links, bookmarks, and custom dashboards that interpret
`var-instance` as an `IP:port` scrape address. Existing links are not automatically
migrated. For rollback, restore the matching backend and dashboard together.

Selection is scoped to an application and IP, not an individual process: multiple
instances of the same application sharing an IP may be returned together. See
[Java and Go metric compatibility](docs/observability-metric-compatibility.md)
for query paths, scraping requirements, and verification scope.

# 0.7.0 [Milestone]
## Summary
This release is a milestone version. The entire backend system is completely rewritten using Go, meanwhile,
Expand Down
78 changes: 78 additions & 0 deletions docs/observability-metric-compatibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Dubbo Java and Go metric compatibility

Dubbo Admin uses the same Application, Service, and Instance metric dashboards for dubbo-java and dubbo-go. The shared query identities are `application_name` for an application and `interface` for a service. `method` is an optional service refinement: an interface-only query remains valid. Provider and consumer data come from their respective `dubbo_provider_*` and `dubbo_consumer_*` metric families; there is no shared `side` label.

## Instance resolution

The Instance Metric dashboard selects data by application name and native, bare IP address. Prometheus's `instance` label, commonly an `IP:port` scrape target, is an internal association key, not the dashboard's instance selection parameter.

The shared Instance dashboard supports two paths:

1. If an RPC metric has `ip`, filter it directly by the selected bare IP. This is the path observed with dubbo-go 3.3.2.
2. If an RPC metric lacks `ip`, correlate `application_name` and the selected IP through `dubbo_application_info_total`, then match the resulting scrape target to the RPC metric on `(application_name, instance)`. The `instance` label is only an internal join key. This is the path observed with dubbo-java 3.2.16.

The dashboard combines the paths with PromQL `or`, which returns an identical series once if both paths find it. The bridge requires the application-info series to identify the correct scrape target. Do not guess a QoS, RPC, or exporter port from the bare IP.

This selection is IP-scoped, not process- or port-scoped. If multiple instances of the same application share an IP but use different ports, selecting that IP can include all of them. The direct-IP path cannot distinguish those processes, and the metadata path can match multiple scrape targets for the same application/IP. Use distinguishable IPs when validating instance isolation; this dashboard does not promise per-process isolation for a shared IP.

## Upgrade and deployment notes

The Instance Metric URL parameter `var-instance` changes from `IP:QoSPort` to bare IP. Deploy the updated Admin backend and Instance Metric dashboard together, and reload or redeploy Grafana's provisioned dashboard definitions. Mixing an old backend with the new dashboard, or a new backend with a dashboard expecting `IP:port`, can produce empty or incorrect results.

Update custom dashboards and saved links that treat `var-instance` as a scrape address. This parameter change does not rename or rewrite Prometheus's `instance` label, change application/service identity parameters, or configure scrape discovery.

## Scraping a dubbo-go application

Dashboard query compatibility does not configure a Go application or make Prometheus scrape it. In dubbo-go, the metrics master switch is disabled by default. Enable `metrics.enable`, use the Prometheus exporter, and expose its configured HTTP port and path (defaults: `9090` and `/metrics`). The exporter being enabled by default does not override the disabled metrics master switch.

For example, the dubbo-go application configuration can include:

```yaml
dubbo:
metrics:
enable: true
protocol: prometheus
port: 9090
path: /metrics
prometheus:
exporter:
enabled: true
```

The release's [`dubbo-serviceMonitor.yaml`](../release/kubernetes/monitoring/dubbo-serviceMonitor.yaml) selects Services labeled `org.apache.dubbo/service: dubbo-qos` and scrapes a Service port named `dubbo-qos`. It does not automatically discover a Go application's default `9090/metrics` endpoint. Expose the Go exporter through a Kubernetes Service and configure a Prometheus scrape target or ServiceMonitor that selects that Service and its actual named metrics port. An existing ServiceMonitor can be reused only if its selector and port name really match the Go Service; do not infer a scrape port from the Admin instance IP or QoS port. Point the Grafana dashboards at the Prometheus datasource that receives those samples.

Before testing Admin, check Prometheus targets and confirm `dubbo_application_info_total{application_name="<go-app>"}` and the relevant `dubbo_provider_requests_total` or `dubbo_consumer_requests_total` series. After an RPC call, verify that the series carries the expected application, `interface`, and native `ip` labels. A consumer-only application need not have provider request series.

## Metric capabilities

Request counters are the common basis for the dashboards. Other families, including processing and histograms, depend on what the running application actually exports; they are not inferred from a Java/Go runtime name. A missing optional family must not make the whole application appear to lack metric support.

This compatibility work does not align cross-language error or duration semantics, add metrics to dubbo-go, or change Trace-to-Metric links. Those are outside the scope of this dashboard compatibility work.

## Verification scope

The compatibility targets are dubbo-java 3.2.0 and later and dubbo-go 3.1.1 and later. Source inspection at those starting tags supports the identity and metric-family assumptions. Runtime checks used dubbo-java 3.2.16 and dubbo-go 3.3.2; they do not constitute E2E verification of every release in either range.

For the tested Java runtime, RPC request series lacked native `ip`, while application-info series included `application_name`, `ip`, and the scrape `instance`. Two `shop-detail` IPs resolved to distinct RPC series through the bridge. For the tested Go runtime, RPC series contained `application_name` and `ip`, and direct-IP queries returned the fixture's real provider and consumer request data. Shared dashboards were checked against Grafana 12.1.0 and Prometheus data. Browser acceptance and a complete Go discovery-to-Admin-to-Grafana journey should be recorded separately from these API checks.

### Recorded runtime query results

The following summarizes the historical API/query observations above, not a new runtime run of the network/codec summary fix:

| Runtime | Observed labels and query path | Recorded result |
| --- | --- | --- |
| dubbo-java 3.2.16 | RPC request series lacked `ip`; `dubbo_application_info_total` supplied `application_name`, `ip`, and scrape `instance`; RPC series were matched on `(application_name, instance)` | The two tested `shop-detail` IPs resolved to distinct RPC series through the metadata bridge. |
| dubbo-go 3.3.2 | RPC series supplied `application_name` and native `ip`; queries selected them directly | The fixture's real provider and consumer request data were returned. |

These observations do not establish network/codec counter behavior, shared-IP process isolation, or all-version compatibility. For runtime acceptance of the error summaries, record the concrete Java/Go label sets, selected application/IP, rendered PromQL, time range, and returned values for two distinguishable instances. A zero fallback alone is not evidence of successful isolation: use nonzero samples in the selected and excluded instances, or explicitly record that an optional metric is not exported. Retain the corresponding Grafana screenshots or query results with the PR's acceptance evidence.

### Automated dashboard contract check

```sh
go test ./release/kubernetes/monitoring -run '^TestInstanceMetricQueriesScopeSelectedIP$' -count=1 -v
go test ./pkg/console/service ./pkg/console/handler -count=1
```

The dashboard check parses the provisioning YAML and embedded dashboard JSON, inspects every Instance Metric query expression (not only those already containing `$instance`), and checks that the provider network/codec summaries retain both selection paths and the zero fallback. It is a structural regression test, not a PromQL evaluator or browser acceptance test.

A complete product acceptance should use a registered dubbo-go application with two distinguishable instances: confirm Prometheus ingestion, open its Application, Instance, and Service Metric views from Admin, trigger real RPCs, verify provider and/or consumer data, and verify that selecting one instance excludes the other's series. Repeat representative views with dubbo-java to check for regression. These browser and discovery checks have not been claimed by the runtime query checks above.
9 changes: 1 addition & 8 deletions pkg/console/service/observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,9 @@ func GetInstanceDashboardVariables(ctx consolectx.Context, req *model.InstanceDa
if err != nil {
return nil, err
}
var instanceValue string
if res.Spec.QosPort != 0 {
instanceValue = fmt.Sprintf("%s:%d", res.Spec.Ip, res.Spec.QosPort)
} else {
instanceValue = fmt.Sprintf("%s:%d", res.Spec.Ip, 22222)
}

return map[string]string{
"var-application": res.Spec.AppName,
"var-instance": instanceValue,
"var-instance": res.Spec.Ip,
}, nil
}

Expand Down
110 changes: 110 additions & 0 deletions pkg/console/service/observability_instance_metric_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package service

import (
"fmt"
"net/url"
"testing"

"github.com/stretchr/testify/require"

"github.com/apache/dubbo-admin/pkg/console/model"
"github.com/apache/dubbo-admin/pkg/core/manager"
meshresource "github.com/apache/dubbo-admin/pkg/core/resource/apis/mesh/v1alpha1"
coremodel "github.com/apache/dubbo-admin/pkg/core/resource/model"
"github.com/apache/dubbo-admin/pkg/core/store"
memoryst "github.com/apache/dubbo-admin/pkg/store/memory"
)

func instanceMetricTestContext(t *testing.T) (*testContext, store.ResourceStore) {
t.Helper()
s := memoryst.NewMemoryResourceStore(meshresource.InstanceKind)
require.NoError(t, s.Init(nil))
return &testContext{rm: manager.NewResourceManager(&testRouter{stores: map[coremodel.ResourceKind]store.ResourceStore{meshresource.InstanceKind: s}}, nil)}, s
}

func TestInstanceMetricDashboardVariables(t *testing.T) {
for _, qosPort := range []int64{0, 22222} {
t.Run(fmt.Sprintf("qos-%d", qosPort), func(t *testing.T) {
ctx, s := instanceMetricTestContext(t)
instance := meshresource.NewInstanceResourceWithAttributes("instance", "mesh")
instance.Spec.AppName = "shop-user"
instance.Spec.Ip = "10.42.1.10"
instance.Spec.QosPort = qosPort
require.NoError(t, s.Add(instance))

variables, err := GetInstanceDashboardVariables(ctx, &model.InstanceDashboardReq{Mesh: "mesh", InstanceName: "instance"})
require.NoError(t, err)
require.Equal(t, map[string]string{
"var-application": "shop-user",
"var-instance": "10.42.1.10",
}, variables)
})
}
}

func TestInstanceMetricDashboardURLUsesBareIP(t *testing.T) {
for _, qosPort := range []int64{0, 22222} {
t.Run(fmt.Sprintf("qos-%d", qosPort), func(t *testing.T) {
ctx, s := instanceMetricTestContext(t)
instance := meshresource.NewInstanceResourceWithAttributes("instance", "mesh")
instance.Spec.AppName = "shop-user"
instance.Spec.Ip = "10.42.1.10"
instance.Spec.QosPort = qosPort
require.NoError(t, s.Add(instance))

base, err := url.Parse("http://grafana/d/instance?kiosk=1")
require.NoError(t, err)
result, err := GetInstanceDashboard(ctx, base, &model.InstanceDashboardReq{Mesh: "mesh", InstanceName: "instance"})
require.NoError(t, err)
parsed, err := url.Parse(result)
require.NoError(t, err)
require.Equal(t, "shop-user", parsed.Query().Get("var-application"))
require.Equal(t, "10.42.1.10", parsed.Query().Get("var-instance"))
require.Equal(t, "1", parsed.Query().Get("kiosk"))
require.NotContains(t, parsed.Query().Get("var-instance"), ":")
})
}
}

func TestInstanceMetricDashboardErrors(t *testing.T) {
ctx, _ := instanceMetricTestContext(t)
req := &model.InstanceDashboardReq{Mesh: "mesh", InstanceName: "missing"}
result, err := GetInstanceDashboard(ctx, nil, req)
require.ErrorContains(t, err, "grafana url is not configured")
require.Empty(t, result)

variables, err := GetInstanceDashboardVariables(ctx, req)
require.ErrorContains(t, err, "instance missing not found")
require.Nil(t, variables)

base, err := url.Parse("http://grafana/d/instance")
require.NoError(t, err)
result, err = GetInstanceDashboard(ctx, base, req)
require.ErrorContains(t, err, "instance missing not found")
require.Empty(t, result)

lookupFailureCtx := &testContext{rm: manager.NewResourceManager(&testRouter{stores: map[coremodel.ResourceKind]store.ResourceStore{}}, nil)}
variables, err = GetInstanceDashboardVariables(lookupFailureCtx, req)
require.Error(t, err)
require.Nil(t, variables)
result, err = GetInstanceDashboard(lookupFailureCtx, base, req)
require.Error(t, err)
require.Empty(t, result)
}
6 changes: 3 additions & 3 deletions pkg/console/service/observability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func TestInstanceMetricAndTraceDashboardVariables(t *testing.T) {
qosPort int64
metricInstance string
}{
{name: "explicit QoS port", qosPort: 22222, metricInstance: "10.42.1.10:22222"},
{name: "default QoS port", qosPort: 0, metricInstance: "10.42.1.10:22222"},
{name: "explicit QoS port", qosPort: 22222, metricInstance: "10.42.1.10"},
{name: "default QoS port", qosPort: 0, metricInstance: "10.42.1.10"},
} {
t.Run(tc.name, func(t *testing.T) {
ctx, s := instanceDashboardTestContext(t)
Expand All @@ -73,7 +73,7 @@ func TestInstanceMetricAndTraceDashboardVariables(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "shop-user", trace["var-application"])
require.Equal(t, "10.42.1.10", trace["var-instance"])
require.NotEqual(t, metric["var-instance"], trace["var-instance"])
require.Equal(t, metric["var-instance"], trace["var-instance"])
})
}
}
Expand Down
Loading
Loading