From c5e0f5f5a6d62580c62d6c28d8a6cbbfc590f296 Mon Sep 17 00:00:00 2001 From: Starry Date: Fri, 8 Mar 2024 09:34:03 +0800 Subject: [PATCH] Add hierarchy for Pulsar (#11971) --- docs/en/changes/changes.md | 3 +++ .../concepts-and-designs/service-hierarchy.md | 22 +++++++++++++-- .../main/resources/hierarchy-definition.yml | 5 ++++ .../pulsar/pulsar-cluster.json | 27 ++++++++++++++++++- 4 files changed, 54 insertions(+), 3 deletions(-) diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md index 6b2faf9217e3..b15ae208a088 100644 --- a/docs/en/changes/changes.md +++ b/docs/en/changes/changes.md @@ -72,6 +72,9 @@ * Add Service Hierarchy auto matching layer relationships (upper -> lower) as following: - CLICKHOUSE -> K8S_SERVICE - VIRTUAL_DATABASE -> CLICKHOUSE +* Add Service Hierarchy auto matching layer relationships (upper -> lower) as following: + - PULSAR -> K8S_SERVICE + - VIRTUAL_MQ -> PULSAR #### UI diff --git a/docs/en/concepts-and-designs/service-hierarchy.md b/docs/en/concepts-and-designs/service-hierarchy.md index fc7548520431..e43693ef6f04 100644 --- a/docs/en/concepts-and-designs/service-hierarchy.md +++ b/docs/en/concepts-and-designs/service-hierarchy.md @@ -30,10 +30,12 @@ If you want to customize it according to your own needs, please refer to [Servic | KAFKA | K8S_SERVICE | [KAFKA On K8S_SERVICE](#kafka-on-k8s_service) | | VIRTUAL_MQ | RABBITMQ | [VIRTUAL_MQ On RABBITMQ](#virtual_mq-on-rabbitmq) | | VIRTUAL_MQ | ROCKETMQ | [VIRTUAL_MQ On K8S_SERVICE](#virtual_mq-on-rocketmq) | -| VIRTUAL_MQ | KAFKA | [VIRTUAL_MQ On KAFKA](#virtual_mq-on-kafka) | -| VIRTUAL_MQ | RABBITMQ | [VIRTUAL_MQ On RABBITMQ](#virtual_mq-on-rabbitmq) | +| VIRTUAL_MQ | KAFKA | [VIRTUAL_MQ On KAFKA](#virtual_mq-on-kafka) | +| VIRTUAL_MQ | RABBITMQ | [VIRTUAL_MQ On RABBITMQ](#virtual_mq-on-rabbitmq) | | CLICKHOUSE | K8S_SERVICE | [CLICKHOUSE On K8S_SERVICE](#clickhouse-on-k8s_service) | | VIRTUAL_DATABASE | CLICKHOUSE | [VIRTUAL_DATABASE On CLICKHOUSE](#virtual_database-on-clickhouse) | +| PULSAR | K8S_SERVICE | [PULSAR On K8S_SERVICE](#pulsar-on-k8s_service) | +| VIRTUAL_MQ | PULSAR | [VIRTUAL_MQ On PULSAR](#virtual_mq-on-pulsar) | - The following sections will describe the **default matching rules** in detail and use the `upper-layer On lower-layer` format. - The example service name are based on SkyWalking [Showcase](https://github.com/apache/skywalking-showcase) default deployment. @@ -199,6 +201,22 @@ If you want to customize it according to your own needs, please refer to [Servic - VIRTUAL_DATABASE.service.name: `clickhouse.skywalking-showcase.svc.cluster.local:8123` - CLICKHOUSE.service.name: `clickhouse::clickhouse.skywalking-showcase` +#### PULSAR On K8S_SERVICE +- Rule name: `short-name` +- Groovy script: `{ (u, l) -> u.shortName == l.shortName }` +- Description: PULSAR.service.shortName == K8S_SERVICE.service.shortName +- Matched Example: + - PULSAR.service.name: `pulsar::pulsar.skywalking-showcase` + - K8S_SERVICE.service.name: `skywalking-showcase::pulsar.skywalking-showcase` + +#### VIRTUAL_MQ On PULSAR +- Rule name: `lower-short-name-with-fqdn` +- Groovy script: `{ (u, l) -> u.shortName.substring(0, u.shortName.lastIndexOf(':')) == l.shortName.concat('.svc.cluster.local') }` +- Description: VIRTUAL_MQ.service.shortName remove port == PULSAR.service.shortName with fqdn suffix +- Matched Example: + - VIRTUAL_MQ.service.name: `pulsar.skywalking-showcase.svc.cluster.local:6650` + - PULSAR.service.name: `pulsar::pulsar.skywalking-showcase` + ### Build Through Specific Agents Use agent tech involved(such as eBPF) and deployment tools(such as operator and agent injector) detect the service hierarchy relations. diff --git a/oap-server/server-starter/src/main/resources/hierarchy-definition.yml b/oap-server/server-starter/src/main/resources/hierarchy-definition.yml index 6cd9b9d94741..3ddb09058e7a 100644 --- a/oap-server/server-starter/src/main/resources/hierarchy-definition.yml +++ b/oap-server/server-starter/src/main/resources/hierarchy-definition.yml @@ -56,6 +56,9 @@ hierarchy: CLICKHOUSE: K8S_SERVICE: short-name + + PULSAR: + K8S_SERVICE: short-name VIRTUAL_DATABASE: MYSQL: lower-short-name-with-fqdn @@ -66,6 +69,7 @@ hierarchy: ROCKETMQ: lower-short-name-with-fqdn RABBITMQ: lower-short-name-with-fqdn KAFKA: lower-short-name-with-fqdn + PULSAR: lower-short-name-with-fqdn # Use Groovy script to define the matching rules, the input parameters are the upper service(u) and the lower service(l) and the return value is a boolean, # which are used to match the relation between the upper service(u) and the lower service(l) on the different layers. @@ -98,6 +102,7 @@ layer-levels: CLICKHOUSE: 2 RABBITMQ: 2 KAFKA: 2 + PULSAR: 2 MESH_DP: 1 diff --git a/oap-server/server-starter/src/main/resources/ui-initialized-templates/pulsar/pulsar-cluster.json b/oap-server/server-starter/src/main/resources/ui-initialized-templates/pulsar/pulsar-cluster.json index 71003854b7ad..8b8da74c73fa 100644 --- a/oap-server/server-starter/src/main/resources/ui-initialized-templates/pulsar/pulsar-cluster.json +++ b/oap-server/server-starter/src/main/resources/ui-initialized-templates/pulsar/pulsar-cluster.json @@ -429,7 +429,32 @@ "entity": "Service", "name": "Pulsar-Cluster", "id": "Pulsar-Cluster", - "isRoot": false + "isRoot": false, + "isDefault": true, + "expressions": [ + "avg(meter_pulsar_total_topics)", + "avg(meter_pulsar_total_subscriptions)", + "avg(meter_pulsar_message_rate_in)", + "avg(meter_pulsar_message_rate_out)", + "avg(meter_pulsar_storage_size)" + ], + "expressionsConfig": [ + { + "label": "total topics" + }, + { + "label": "total subscriptions" + }, + { + "label": "message rate in" + }, + { + "label": "message rate out" + }, + { + "label": "storage size" + } + ] } } ] \ No newline at end of file