From 678a128ae41ddf93e54135c5e1bac5afc0dab133 Mon Sep 17 00:00:00 2001
From: lijianguo <lijianguo1991@outlook.com>
Date: Wed, 3 Sep 2025 15:29:46 +0800
Subject: [PATCH] chore(controller): unify victoriametricsUrl configuration
 format

---
 charts/controller/values.yaml |  1 +
 rootfs/api/monitor.py         | 17 ++++++++---------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/charts/controller/values.yaml b/charts/controller/values.yaml
index 1ce7de44..df5ab587 100644
--- a/charts/controller/values.yaml
+++ b/charts/controller/values.yaml
@@ -58,6 +58,7 @@ passportUrl: ""
 passportKey: ""
 passportSecret: ""
 # victoriametricsUrl is will no longer use the built-in victoriametrics component
+# format: http://victoriametrics-server/select/0/prometheus
 victoriametricsUrl: ""
 # Workflow-manager Configuration Options
 workflowManagerUrl: ""
diff --git a/rootfs/api/monitor.py b/rootfs/api/monitor.py
index baa47ae7..9752aed1 100644
--- a/rootfs/api/monitor.py
+++ b/rootfs/api/monitor.py
@@ -1,7 +1,6 @@
 import time
 import aiohttp
 from typing import Iterator, AsyncGenerator
-from urllib.parse import urljoin
 from django.conf import settings
 
 
@@ -66,7 +65,7 @@ async def query_prom(url, params) -> list[tuple[dict[str, str], int]]:
 async def last_metrics(namespace) -> AsyncGenerator[Iterator, str]:
     if not settings.DRYCC_METRICS_CONFIG:
         return
-    url = urljoin(settings.DRYCC_VICTORIAMETRICS_URL, "/select/0/prometheus/api/v1/query")
+    url = f"{settings.DRYCC_VICTORIAMETRICS_URL}/api/v1/query"
     promql = query_last_metrics_promql_tpl % (
       '|'.join(settings.DRYCC_METRICS_CONFIG.keys()),
       namespace,
@@ -84,7 +83,7 @@ async def last_metrics(namespace) -> AsyncGenerator[Iterator, str]:
 
 async def query_volume_size(namespaces: Iterator[str], start: int, stop: int
                             ) -> list[tuple[dict[str, str], int]]:
-    url = urljoin(settings.DRYCC_VICTORIAMETRICS_URL, "/select/0/prometheus/api/v1/query")
+    url = f"{settings.DRYCC_VICTORIAMETRICS_URL}/api/v1/query"
     promql = query_volume_size_promql_tpl % (
         "|".join(namespaces), "|".join(namespaces), "|".join(namespaces))
     return await query_prom(url, {"query": promql, "start": start, "end": stop})
@@ -92,14 +91,14 @@ async def query_volume_size(namespaces: Iterator[str], start: int, stop: int
 
 async def query_network_receive_flow(namespaces: Iterator[str], start: int, stop: int
                                      ) -> list[tuple[dict[str, str], int]]:
-    url = urljoin(settings.DRYCC_VICTORIAMETRICS_URL, "/select/0/prometheus/api/v1/query")
+    url = f"{settings.DRYCC_VICTORIAMETRICS_URL}/api/v1/query"
     promql = query_network_receive_flow_promql_tpl % ("|".join(namespaces), f"{stop-start}s")
     return await query_prom(url, {"query": promql, "start": start, "end": stop})
 
 
 async def query_network_transmit_flow(namespaces: Iterator[str], start: int, stop: int
                                       ) -> list[tuple[dict[str, str], int]]:
-    url = urljoin(settings.DRYCC_VICTORIAMETRICS_URL, "/select/0/prometheus/api/v1/query")
+    url = f"{settings.DRYCC_VICTORIAMETRICS_URL}/api/v1/query"
     promql = query_network_transmit_flow_promql_tpl % ("|".join(namespaces), f"{stop-start}s")
     return await query_prom(url, {"query": promql, "start": start, "end": stop})
 
@@ -107,7 +106,7 @@ async def query_network_transmit_flow(namespaces: Iterator[str], start: int, sto
 async def query_cpu_usage(namespace: str, ptype: str, every: str,
                           start: int, stop: int, step: int,
                           ) -> list[tuple[dict[str, str], int]]:
-    url = urljoin(settings.DRYCC_VICTORIAMETRICS_URL, "/select/0/prometheus/api/v1/query_range")
+    url = f"{settings.DRYCC_VICTORIAMETRICS_URL}/api/v1/query_range"
     pod_prefix = "%s-%s" % (namespace, ptype)
     promql = query_cpu_usage_promql_tpl % (pod_prefix, namespace, every)
     return await query_prom(url, {"query": promql, "start": start, "end": stop, "step": step})
@@ -116,7 +115,7 @@ async def query_cpu_usage(namespace: str, ptype: str, every: str,
 async def query_memory_usage(namespace: str, ptype: str, every: str,
                              start: int, stop: int, step: int,
                              ) -> list[tuple[dict[str, str], int]]:
-    url = urljoin(settings.DRYCC_VICTORIAMETRICS_URL, "/select/0/prometheus/api/v1/query_range")
+    url = f"{settings.DRYCC_VICTORIAMETRICS_URL}/api/v1/query_range"
     pod_prefix = "%s-%s" % (namespace, ptype)
     promql = query_memory_usage_promql_tpl % (pod_prefix, namespace, every)
     return await query_prom(url, {"query": promql, "start": start, "end": stop, "step": step})
@@ -125,7 +124,7 @@ async def query_memory_usage(namespace: str, ptype: str, every: str,
 async def query_network_receive_usage(namespace: str, ptype: str, every: str,
                                       start: int, stop: int, step: int,
                                       ) -> list[tuple[dict[str, str], int]]:
-    url = urljoin(settings.DRYCC_VICTORIAMETRICS_URL, "/select/0/prometheus/api/v1/query_range")
+    url = f"{settings.DRYCC_VICTORIAMETRICS_URL}/api/v1/query_range"
     pod_prefix = "%s-%s" % (namespace, ptype)
     promql = query_network_receive_usage_promql_tpl % (pod_prefix, namespace, every)
     return await query_prom(url, {"query": promql, "start": start, "end": stop, "step": step})
@@ -134,7 +133,7 @@ async def query_network_receive_usage(namespace: str, ptype: str, every: str,
 async def query_network_transmit_usage(namespace: str, ptype: str, every: str,
                                        start: int, stop: int, step: int,
                                        ) -> list[tuple[dict[str, str], int]]:
-    url = urljoin(settings.DRYCC_VICTORIAMETRICS_URL, "/select/0/prometheus/api/v1/query_range")
+    url = f"{settings.DRYCC_VICTORIAMETRICS_URL}/api/v1/query_range"
     pod_prefix = "%s-%s" % (namespace, ptype)
     promql = query_network_transmit_usage_promql_tpl % (pod_prefix, namespace, every)
     return await query_prom(url, {"query": promql, "start": start, "end": stop, "step": step})
