feature: Implement Event stream for Application/Instance/Service #1472#1487
Open
ambiguous-pointer wants to merge 1 commit into
Open
feature: Implement Event stream for Application/Instance/Service #1472#1487ambiguous-pointer wants to merge 1 commit into
ambiguous-pointer wants to merge 1 commit into
Conversation
…ent ingestion ([apache#1472](apache#1472)) - Add K8sEvent resource type (proto + Go spec) and store indexes - Add K8sEventListerWatcher to watch K8s /api/v1/events via client-go - Register K8sEventListerWatcher in Kubernetes EngineFactory - Add /application/event, /instance/event, /service/event console API endpoints - Add EventTimeline shared Vue component with normal/warning node styles - Wire up event tabs for application, instance, and service detail pages - Un-hide event tab routes in frontend router - Add mock event handlers for development - Add PlatformEvent resource type (platformevent_types.go) with store indexes - Add shared platform_event_recorder utility for event recording - Record ZK config change events (tag-route, condition-route, dynamic-config) - Record ZK metadata events (provider/consumer metadata added/updated) - Record Nacos instance registration/deregistration events - Record Nacos consumer metadata change events - Merge K8s events and Platform events into unified timeline in event query service - Downgrade "no subscriber" log level from INFO to DEBUG to reduce log noise
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This change introduces a complete event timeline feature for applications, instances, and services
based on discussion #1474 and
issue #1472.
It ingests Kubernetes events via the cluster API and records platform events from ZooKeeper
and Nacos registration centers, merging them into a unified, time-sorted timeline with full
frontend visualization.
📌 What's New
Kubernetes Event Ingestion
K8sEvent resource type
K8sEventResourcewith protoK8sEventspec (api/mesh/v1alpha1/k8s_event.proto+Go generated code). Captures namespace, reason, message, type, involved object kind/name,
source component/host, first/last timestamps, count, and a static
EventSource: "KUBERNETES"marker.K8sEventListerWatcher
New
K8sEventListerWatcher(pkg/engine/kubernetes/listerwatcher/k8s_event.go) watchesapi/v1/eventsacross all namespaces usingclient-go'sListWatch+TransformFunc.Registered in the K8s
EngineFactoryalongside the existingPodListerWatcher.K8sEvent store indexes (
pkg/core/store/index/k8s_event.go)ByK8sEventInvolvedObjKind,ByK8sEventInvolvedObjName,ByK8sEventType,ByK8sEventSource— enables efficient queries by mesh, involved object, event type, and source.
Platform Event Recording (ZooKeeper & Nacos)
PlatformEvent resource type
PlatformEventResourcewithPlatformEventspec (pkg/core/resource/apis/mesh/v1alpha1/platformevent_types.go).Carries
AppName,InstanceName,InstanceIP,ServiceName,Type(normal/warning),Message,Source(Zookeeper/Nacos),SourceType(provider/consumer/config),Category,Action, andEventTime.Shared platform event recorder (
pkg/core/discovery/subscriber/platform_event_recorder.go)recordPlatformEvent()utility that createsPlatformEventResourceinstances and persiststhem directly to the store via
storeRouter.ResourceKindRoute(PlatformEventKind).ZooKeeper config change events
ZKConfigEventSubscriber(pkg/core/discovery/subscriber/zk_config.go) recordstag-route,condition-route, anddynamic-configadded/updated/deleted eventsvia
recordConfigPlatformEvent().ZooKeeper metadata change events
ZKMetadataEventSubscriber(pkg/core/discovery/subscriber/zk_metadata.go) recordsprovider and consumer metadata added/updated events via
recordMetadataPlatformEvent().Nacos instance registration/deregistration events
NacosServiceEventSubscriber(pkg/core/discovery/subscriber/nacos_service.go)records
Nacos instance registered,deregistered, andupdatedevents withapplication name, IP, and port via
recordNacosInstanceEvents().Nacos consumer metadata change events
Same subscriber records
Nacos consumer metadata added/updatedeventsvia
recordNacosConsumerEvents().PlatformEvent store indexes (
pkg/core/store/index/platform_event.go)ByPlatformEventAppName,ByPlatformEventInstanceName,ByPlatformEventInstanceIP,ByPlatformEventServiceName,ByPlatformEventSourceType— enables per-entity event queries.Unified Event Timeline Query Service
pkg/console/service/event.go)GET /application/eventGET /instance/eventGET /service/eventEach endpoint queries both
K8sEventandPlatformEventstores in parallel,merges results, sorts by time descending, and returns paginated unified timeline entries.
{ "code": "Success", "message": "success", "data": { "list": [ { "time": "2026-06-07 17:39:14", "type": "warning", "message": "Error updating Endpoint Slices...", "source": "endpoint-slice-controller" }, { "time": "2026-06-07 10:25:04", "type": "normal", "message": "Zookeeper provider metadata added: demo-app → com.example.TestService", "source": "Zookeeper" }, { "time": "2026-06-07 10:25:05", "type": "normal", "message": "Nacos instance registered: shop-order 10.244.1.29:20882", "source": "Nacos" } ], "total": 78 } }Frontend Event Timeline Visualization
EventTimeline shared component (
ui-vue3/src/components/EventTimeline.vue)Reusable Vue component with alternating left/right timeline layout using Ant Design.
Each event node displays: timestamp, icon (check-circle for normal, warning for warnings),
message text, and source tag. Supports infinite scroll with "load more" pagination.
Degraded/expired events show an empty state with "过期事件不会存储" (expired events
are not stored) watermark.
Application event tab (
ui-vue3/src/views/resources/applications/tabs/event.vue)Wires the EventTimeline component into the application detail page as an "事件" tab.
Queries events filtered by
appNameand currentmesh.Instance event tab (
ui-vue3/src/views/resources/instances/tabs/event.vue)Wires the EventTimeline component into the instance detail page as an "事件" tab.
Queries events filtered by
instanceNameandinstanceIP.Service event tab (
ui-vue3/src/views/resources/services/tabs/event.vue)Wires the EventTimeline component into the service detail page as an "事件" tab.
Queries events filtered by
serviceName.Event tab restored in routes (
ui-vue3/src/router/defaultRoutes.ts)Event tab routes previously commented out are now enabled for all three resource types.
Minor Improvements
pkg/core/events/component.go)"no subscriber for resource" message downgraded from
INFOtoDEBUGto reducelog noise (991 occurrences per 5 minutes for
K8sEventandService).📁 Affected Areas / Review Checklist
api/mesh/v1alpha1/k8s_event.go,k8s_event.protopkg/console/service/event.go,handler/event.go,model/event.go,router/router.gopkg/core/events/component.gopkg/core/resource/apis/mesh/v1alpha1/k8sevent_types.go,platformevent_types.gopkg/core/store/index/k8s_event.go,platform_event.gopkg/core/discovery/subscriber/nacos_service.go,zk_config.go,zk_metadata.gopkg/core/discovery/subscriber/platform_event_recorder.gopkg/engine/kubernetes/factory.go,listerwatcher/k8s_event.goui-vue3/src/components/EventTimeline.vueui-vue3/src/views/resources/{applications,instances,services}/tabs/event.vueui-vue3/src/api/service/{app,instance,service}.tsui-vue3/src/router/defaultRoutes.tsui-vue3/src/types/api.ts🔄 Data Flow Architecture
🧪 E2E Verification
Tested against a 6-node kind cluster (
cluster-ha-new, k8s v1.35.1) with:🔮 Known Limitations
K8s events use mesh "default" — K8s events are not associated with any discovery
mesh. The frontend registry selector must be set to "default" (or unset) to view
K8s events. There is a UX gap: the registry dropdown does not show "default" as an
explicit option.
No event TTL / cleanup — Events accumulate indefinitely in the store. There is
no retention policy, TTL, or automatic cleanup mechanism for any store backend.
No subscriber for K8sEvent and Service — K8sEvent and Service resources are
stored but no event subscriber processes them (by design — they only need storage).
The EventBus emits a "no subscriber" debug log for these kinds.
PlatformEvent bypasses EventBus — PlatformEvents are created as side-effects
within subscriber
ProcessEventmethods and stored directly viaeventStore.Add(), bypassing the EventBus entirely. This means PlatformEventsthemselves cannot be observed by downstream subscribers.