From 5029bef951d7ef717e302979d7ea95033f986f53 Mon Sep 17 00:00:00 2001 From: adarsh0728 Date: Mon, 25 Nov 2024 23:31:34 +0530 Subject: [PATCH 1/3] feat: counter metrics visualizer for pipeline Signed-off-by: adarsh0728 --- .../namespaced-numaflow-server.yaml | 28 ++++++++++++++++++- config/advanced-install/numaflow-server.yaml | 28 ++++++++++++++++++- .../numaflow-server-metrics-proxy-config.yaml | 26 +++++++++++++++++ config/install.yaml | 28 ++++++++++++++++++- config/namespace-install.yaml | 28 ++++++++++++++++++- .../partials/NodeInfo/partials/Pods/index.tsx | 1 + .../Pods/partials/PodDetails/index.tsx | 6 ++-- .../PodDetails/partials/Metrics/index.tsx | 3 +- .../Metrics/partials/LineChart/index.tsx | 7 +++-- .../partials/common/FiltersDropdown/index.tsx | 6 ++-- .../partials/Metrics/utils/constants.ts | 6 ++++ ui/src/types/declarations/pods.d.ts | 1 + 12 files changed, 157 insertions(+), 11 deletions(-) diff --git a/config/advanced-install/namespaced-numaflow-server.yaml b/config/advanced-install/namespaced-numaflow-server.yaml index d316bf1e0..7db036f58 100644 --- a/config/advanced-install/namespaced-numaflow-server.yaml +++ b/config/advanced-install/namespaced-numaflow-server.yaml @@ -137,7 +137,7 @@ metadata: --- apiVersion: v1 data: - config.yaml: | + config.yaml: |- # url is a required field, it should be the url of the service to which the metrics proxy will connect # url: service_name + "." + service_namespace + ".svc.cluster.local" + ":" + port # example for local prometheus service @@ -186,6 +186,32 @@ data: # required: false # - name: mono-vertex # #expr: optional + - name: pipeline_counter_metrics + object: vertex + title: Rate of Change of metrics + description: This pattern is to calculate rate of change of counter metrics + expr: sum(rate($metric_name{$filters}[$duration])) by ($dimension) + params: + - name: duration + required: true + - name: start_time + required: false + - name: end_time + required: false + metrics: + - metric_name: forwarder_data_read_total + required_filters: + - namespace + - pipeline + - vertex + dimensions: + - name: vertex + # expr: optional expression for prometheus query + # overrides the default expression + - name: pod + filters: + - name: pod + required: false kind: ConfigMap metadata: name: numaflow-server-metrics-proxy-config diff --git a/config/advanced-install/numaflow-server.yaml b/config/advanced-install/numaflow-server.yaml index b4ba7fd48..01a8281e6 100644 --- a/config/advanced-install/numaflow-server.yaml +++ b/config/advanced-install/numaflow-server.yaml @@ -144,7 +144,7 @@ metadata: --- apiVersion: v1 data: - config.yaml: | + config.yaml: |- # url is a required field, it should be the url of the service to which the metrics proxy will connect # url: service_name + "." + service_namespace + ".svc.cluster.local" + ":" + port # example for local prometheus service @@ -193,6 +193,32 @@ data: # required: false # - name: mono-vertex # #expr: optional + - name: pipeline_counter_metrics + object: vertex + title: Rate of Change of metrics + description: This pattern is to calculate rate of change of counter metrics + expr: sum(rate($metric_name{$filters}[$duration])) by ($dimension) + params: + - name: duration + required: true + - name: start_time + required: false + - name: end_time + required: false + metrics: + - metric_name: forwarder_data_read_total + required_filters: + - namespace + - pipeline + - vertex + dimensions: + - name: vertex + # expr: optional expression for prometheus query + # overrides the default expression + - name: pod + filters: + - name: pod + required: false kind: ConfigMap metadata: name: numaflow-server-metrics-proxy-config diff --git a/config/base/numaflow-server/numaflow-server-metrics-proxy-config.yaml b/config/base/numaflow-server/numaflow-server-metrics-proxy-config.yaml index f970cea63..f99d32432 100644 --- a/config/base/numaflow-server/numaflow-server-metrics-proxy-config.yaml +++ b/config/base/numaflow-server/numaflow-server-metrics-proxy-config.yaml @@ -52,3 +52,29 @@ data: # required: false # - name: mono-vertex # #expr: optional + - name: pipeline_counter_metrics + object: vertex + title: Rate of Change of metrics + description: This pattern is to calculate rate of change of counter metrics + expr: sum(rate($metric_name{$filters}[$duration])) by ($dimension) + params: + - name: duration + required: true + - name: start_time + required: false + - name: end_time + required: false + metrics: + - metric_name: forwarder_data_read_total + required_filters: + - namespace + - pipeline + - vertex + dimensions: + - name: vertex + # expr: optional expression for prometheus query + # overrides the default expression + - name: pod + filters: + - name: pod + required: false \ No newline at end of file diff --git a/config/install.yaml b/config/install.yaml index d6332dc53..ec069a483 100644 --- a/config/install.yaml +++ b/config/install.yaml @@ -28452,7 +28452,7 @@ metadata: --- apiVersion: v1 data: - config.yaml: | + config.yaml: |- # url is a required field, it should be the url of the service to which the metrics proxy will connect # url: service_name + "." + service_namespace + ".svc.cluster.local" + ":" + port # example for local prometheus service @@ -28501,6 +28501,32 @@ data: # required: false # - name: mono-vertex # #expr: optional + - name: pipeline_counter_metrics + object: vertex + title: Rate of Change of metrics + description: This pattern is to calculate rate of change of counter metrics + expr: sum(rate($metric_name{$filters}[$duration])) by ($dimension) + params: + - name: duration + required: true + - name: start_time + required: false + - name: end_time + required: false + metrics: + - metric_name: forwarder_data_read_total + required_filters: + - namespace + - pipeline + - vertex + dimensions: + - name: vertex + # expr: optional expression for prometheus query + # overrides the default expression + - name: pod + filters: + - name: pod + required: false kind: ConfigMap metadata: name: numaflow-server-metrics-proxy-config diff --git a/config/namespace-install.yaml b/config/namespace-install.yaml index e2769284d..54298bf84 100644 --- a/config/namespace-install.yaml +++ b/config/namespace-install.yaml @@ -28340,7 +28340,7 @@ metadata: --- apiVersion: v1 data: - config.yaml: | + config.yaml: |- # url is a required field, it should be the url of the service to which the metrics proxy will connect # url: service_name + "." + service_namespace + ".svc.cluster.local" + ":" + port # example for local prometheus service @@ -28389,6 +28389,32 @@ data: # required: false # - name: mono-vertex # #expr: optional + - name: pipeline_counter_metrics + object: vertex + title: Rate of Change of metrics + description: This pattern is to calculate rate of change of counter metrics + expr: sum(rate($metric_name{$filters}[$duration])) by ($dimension) + params: + - name: duration + required: true + - name: start_time + required: false + - name: end_time + required: false + metrics: + - metric_name: forwarder_data_read_total + required_filters: + - namespace + - pipeline + - vertex + dimensions: + - name: vertex + # expr: optional expression for prometheus query + # overrides the default expression + - name: pod + filters: + - name: pod + required: false kind: ConfigMap metadata: name: numaflow-server-metrics-proxy-config diff --git a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/index.tsx b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/index.tsx index 91baaeed8..6f12096ea 100644 --- a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/index.tsx +++ b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/index.tsx @@ -201,6 +201,7 @@ export function Pods(props: PodsProps) { containerName={selectedContainer} pod={selectedPod} podDetails={selectedPodDetails} + vertexId={vertexId} /> ); diff --git a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/index.tsx b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/index.tsx index 164767ee8..b29cd1836 100644 --- a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/index.tsx +++ b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/index.tsx @@ -26,6 +26,7 @@ export function PodDetail({ type, containerName, pod, + vertexId }: PodDetailProps) { if (!pod) return null; @@ -59,7 +60,7 @@ export function PodDetail({ label="Logs" data-testid="logs-tab" /> - {!disableMetricsCharts && type === "monoVertex" && ( + {!disableMetricsCharts && ( )} - {!disableMetricsCharts && type === "monoVertex" && ( + {!disableMetricsCharts && (
)} diff --git a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/index.tsx b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/index.tsx index 220cb0f0c..d07850992 100644 --- a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/index.tsx +++ b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/index.tsx @@ -17,7 +17,7 @@ export interface MetricsProps { vertexId?: string; } -export function Metrics({ namespaceId, pipelineId, type }: MetricsProps) { +export function Metrics({ namespaceId, pipelineId, type, vertexId }: MetricsProps) { const { metricsDiscoveryData: discoveredMetrics, error: discoveredMetricsError, @@ -88,6 +88,7 @@ export function Metrics({ namespaceId, pipelineId, type }: MetricsProps) { pipelineId={pipelineId} type={type} metric={metric} + vertexId={vertexId} /> )} diff --git a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/partials/LineChart/index.tsx b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/partials/LineChart/index.tsx index 6152c83c2..3f073977f 100644 --- a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/partials/LineChart/index.tsx +++ b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/partials/LineChart/index.tsx @@ -18,7 +18,7 @@ import EmptyChart from "../EmptyChart"; import { useMetricsFetch } from "../../../../../../../../../../../../../../../utils/fetchWrappers/metricsFetch"; // TODO have a check for metricReq against metric object to ensure required fields are passed -const LineChartComponent = ({ namespaceId, pipelineId, type, metric }: any) => { +const LineChartComponent = ({ namespaceId, pipelineId, type, metric, vertexId }: any) => { const [transformedData, setTransformedData] = useState([]); const [chartLabels, setChartLabels] = useState([]); const [metricsReq, setMetricsReq] = useState({ @@ -42,6 +42,8 @@ const LineChartComponent = ({ namespaceId, pipelineId, type, metric }: any) => { case "mvtx_name": case "pipeline": return pipelineId; + case "vertex": + return vertexId; default: return ""; } @@ -91,7 +93,7 @@ const LineChartComponent = ({ namespaceId, pipelineId, type, metric }: any) => { name: param?.Name, required: param?.Required, })) || []; - + setParamsList([...initParams, ...newParams]); }, [metric, setParamsList]); @@ -214,6 +216,7 @@ const LineChartComponent = ({ namespaceId, pipelineId, type, metric }: any) => { namespaceId={namespaceId} pipelineId={pipelineId} type={type} + vertexId={vertexId} setFilters={setFilters} /> diff --git a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/partials/common/FiltersDropdown/index.tsx b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/partials/common/FiltersDropdown/index.tsx index 6cbc89794..193f2ef85 100644 --- a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/partials/common/FiltersDropdown/index.tsx +++ b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/partials/common/FiltersDropdown/index.tsx @@ -25,6 +25,7 @@ export interface FiltersDropdownProps { namespaceId: string; pipelineId: string; type: string; + vertexId?: string; setFilters: any; } @@ -33,6 +34,7 @@ const FiltersDropdown = ({ namespaceId, pipelineId, type, + vertexId, setFilters, }: FiltersDropdownProps) => { const { host } = useContext(AppContext); @@ -62,8 +64,8 @@ const FiltersDropdown = ({ try { const response = await fetch( `${host}${getBaseHref()}/api/v1/namespaces/${namespaceId}/${ - type === "monoVertex" ? "mono-vertices" : "pipeline" - }/${pipelineId}/pods` + type === "monoVertex" ? `mono-vertices/${pipelineId}/pods` : `pipelines/${pipelineId}/vertices/${vertexId}/pods` + }` ); if (!response.ok) { callback(null); diff --git a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/utils/constants.ts b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/utils/constants.ts index 3f5bf52f0..925d8acea 100644 --- a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/utils/constants.ts +++ b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/utils/constants.ts @@ -19,10 +19,14 @@ export const dimensionMap: { [p: string]: string } = { "mono-vertex": "MonoVertex", pod: "Pod", pipeline: "Pipeline", + vertex: "Vertex" }; export const dimensionReverseMap: { [p: string]: string } = { monoVertex: "mono-vertex", + source: "vertex", + udf: "vertex", + sink: "vertex", pipeline: "pipeline", pod: "pod", }; @@ -34,4 +38,6 @@ export const metricNameMap: { [p: string]: string } = { "Mono Vertex Processing Time Latency (in micro seconds)", monovtx_sink_time_bucket: "Mono Vertex Sink Write Time Latency (in micro seconds)", + forwarder_data_read_total: + "Vertex Read Processing Rate" }; diff --git a/ui/src/types/declarations/pods.d.ts b/ui/src/types/declarations/pods.d.ts index b108a8fbc..e9f72c4c4 100644 --- a/ui/src/types/declarations/pods.d.ts +++ b/ui/src/types/declarations/pods.d.ts @@ -98,6 +98,7 @@ export interface PodDetailProps { containerName: string; pod: Pod; podDetails: PodDetail; + vertexId: string; } export interface ContainerInfoProps { state: string; From a3f2ad4b5835e291a32c8fba7e9f832d670dc385 Mon Sep 17 00:00:00 2001 From: adarsh0728 Date: Fri, 29 Nov 2024 17:43:11 +0530 Subject: [PATCH 2/3] fix: update filters/filterlist only when dimension changes Signed-off-by: adarsh0728 --- .../numaflow-server-metrics-proxy-config.yaml | 6 +++--- .../partials/Metrics/partials/LineChart/index.tsx | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config/base/numaflow-server/numaflow-server-metrics-proxy-config.yaml b/config/base/numaflow-server/numaflow-server-metrics-proxy-config.yaml index f99d32432..7824bae01 100644 --- a/config/base/numaflow-server/numaflow-server-metrics-proxy-config.yaml +++ b/config/base/numaflow-server/numaflow-server-metrics-proxy-config.yaml @@ -52,10 +52,10 @@ data: # required: false # - name: mono-vertex # #expr: optional - - name: pipeline_counter_metrics + - name: vertex_throughput object: vertex - title: Rate of Change of metrics - description: This pattern is to calculate rate of change of counter metrics + title: Vertex Throughput and Message Rates + description: This pattern measures the throughput of a vertex in messages per second across different dimensions expr: sum(rate($metric_name{$filters}[$duration])) by ($dimension) params: - name: duration diff --git a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/partials/LineChart/index.tsx b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/partials/LineChart/index.tsx index 3f073977f..b7171a0c4 100644 --- a/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/partials/LineChart/index.tsx +++ b/ui/src/components/pages/Pipeline/partials/Graph/partials/NodeInfo/partials/Pods/partials/PodDetails/partials/Metrics/partials/LineChart/index.tsx @@ -28,6 +28,7 @@ const LineChartComponent = ({ namespaceId, pipelineId, type, metric, vertexId }: // store all filters for each selected dimension const [filtersList, setFiltersList] = useState([]); const [filters, setFilters] = useState({}); + const [previousDimension, setPreviousDimension] = useState(metricsReq?.dimension); const getRandomColor = useCallback((index: number) => { const hue = (index * 137.508) % 360; @@ -75,9 +76,11 @@ const LineChartComponent = ({ namespaceId, pipelineId, type, metric, vertexId }: setFilters(newFilters); }, [filtersList, getFilterValue, setFilters]); + //update filters only when dimension changes in metricsReq useEffect(() => { - if (metricsReq?.dimension) { + if (metricsReq?.dimension !== previousDimension) { updateFilterList(metricsReq.dimension); + setPreviousDimension(metricsReq?.dimension); } }, [metricsReq, updateFilterList]); From bb807118e706ead32508789b7226ba67b3cb7097 Mon Sep 17 00:00:00 2001 From: adarsh0728 Date: Fri, 29 Nov 2024 18:02:20 +0530 Subject: [PATCH 3/3] fix codegen Signed-off-by: adarsh0728 --- config/advanced-install/namespaced-numaflow-server.yaml | 6 +++--- config/advanced-install/numaflow-server.yaml | 6 +++--- config/install.yaml | 6 +++--- config/namespace-install.yaml | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config/advanced-install/namespaced-numaflow-server.yaml b/config/advanced-install/namespaced-numaflow-server.yaml index 7db036f58..2804c4124 100644 --- a/config/advanced-install/namespaced-numaflow-server.yaml +++ b/config/advanced-install/namespaced-numaflow-server.yaml @@ -186,10 +186,10 @@ data: # required: false # - name: mono-vertex # #expr: optional - - name: pipeline_counter_metrics + - name: vertex_throughput object: vertex - title: Rate of Change of metrics - description: This pattern is to calculate rate of change of counter metrics + title: Vertex Throughput and Message Rates + description: This pattern measures the throughput of a vertex in messages per second across different dimensions expr: sum(rate($metric_name{$filters}[$duration])) by ($dimension) params: - name: duration diff --git a/config/advanced-install/numaflow-server.yaml b/config/advanced-install/numaflow-server.yaml index 01a8281e6..6a7444d39 100644 --- a/config/advanced-install/numaflow-server.yaml +++ b/config/advanced-install/numaflow-server.yaml @@ -193,10 +193,10 @@ data: # required: false # - name: mono-vertex # #expr: optional - - name: pipeline_counter_metrics + - name: vertex_throughput object: vertex - title: Rate of Change of metrics - description: This pattern is to calculate rate of change of counter metrics + title: Vertex Throughput and Message Rates + description: This pattern measures the throughput of a vertex in messages per second across different dimensions expr: sum(rate($metric_name{$filters}[$duration])) by ($dimension) params: - name: duration diff --git a/config/install.yaml b/config/install.yaml index ec069a483..1d8a3d7ca 100644 --- a/config/install.yaml +++ b/config/install.yaml @@ -28501,10 +28501,10 @@ data: # required: false # - name: mono-vertex # #expr: optional - - name: pipeline_counter_metrics + - name: vertex_throughput object: vertex - title: Rate of Change of metrics - description: This pattern is to calculate rate of change of counter metrics + title: Vertex Throughput and Message Rates + description: This pattern measures the throughput of a vertex in messages per second across different dimensions expr: sum(rate($metric_name{$filters}[$duration])) by ($dimension) params: - name: duration diff --git a/config/namespace-install.yaml b/config/namespace-install.yaml index 54298bf84..9d02d855e 100644 --- a/config/namespace-install.yaml +++ b/config/namespace-install.yaml @@ -28389,10 +28389,10 @@ data: # required: false # - name: mono-vertex # #expr: optional - - name: pipeline_counter_metrics + - name: vertex_throughput object: vertex - title: Rate of Change of metrics - description: This pattern is to calculate rate of change of counter metrics + title: Vertex Throughput and Message Rates + description: This pattern measures the throughput of a vertex in messages per second across different dimensions expr: sum(rate($metric_name{$filters}[$duration])) by ($dimension) params: - name: duration