Skip to content

Commit 1eb5d47

Browse files
committed
remove unused code, update single edge metrics to use vectors
Signed-off-by: ps48 <pshenoy36@gmail.com>
1 parent 9b11883 commit 1eb5d47

File tree

8 files changed

+87
-727
lines changed

8 files changed

+87
-727
lines changed

public/components/apm/query_services/query_requests/promql_queries.ts

Lines changed: 26 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -737,113 +737,86 @@ label_replace(
737737
`;
738738

739739
// ============================================================================
740-
// EDGE METRICS QUERIES (for Application Map connections)
741-
// ============================================================================
742-
743-
/**
744-
* Get all edge request counts (service->remoteService connections)
745-
* For application map edge labels
746-
* @page Application Map — Edge request labels (via useEdgeMetrics hook)
747-
*/
748-
export const getQueryAllEdgeRequests = (): string => `
749-
sum by (service, environment, remoteService) (
750-
request{namespace="span_derived",remoteService!=""}
751-
)
752-
`;
753-
754-
/**
755-
* Get all edge P95 latency (service->remoteService connections)
756-
* Returns latency in milliseconds
757-
* @page Application Map — Edge latency labels (via useEdgeMetrics hook)
758-
*/
759-
export const getQueryAllEdgeLatency = (): string => `
760-
histogram_quantile(0.95,
761-
sum by (service, environment, remoteService, le) (
762-
latency_seconds_bucket{namespace="span_derived",remoteService!=""}
763-
)
764-
) * 1000
765-
`;
766-
767-
/**
768-
* Get all edge fault rates (service->remoteService connections)
769-
* Returns percentage (0-100)
770-
* @page Application Map — Edge fault rate labels (via useEdgeMetrics hook)
771-
*/
772-
export const getQueryAllEdgeFaultRate = (): string => `
773-
(
774-
sum by (service, environment, remoteService) (fault{namespace="span_derived",remoteService!=""})
775-
/
776-
clamp_min(sum by (service, environment, remoteService) (request{namespace="span_derived",remoteService!=""}), 1)
777-
) * 100
778-
`;
779-
780-
// ============================================================================
781-
// SINGLE EDGE METRICS QUERIES (for Edge Popup)
740+
// EDGE METRICS QUERIES (for Edge Flyout)
782741
// ============================================================================
783742

784743
/**
785744
* Get request count for a specific edge (service-to-service connection)
745+
* Uses sum_over_time to aggregate over the selected time range
786746
* @param service - Source service name
787747
* @param environment - Source environment
788748
* @param remoteService - Target service name
749+
* @param timeRange - Time range string (e.g., "3600s")
789750
* @page App Map Edge Flyout — Edge requests metric (via useSelectedEdgeMetrics hook)
790751
*/
791752
export const getQueryEdgeRequests = (
792753
service: string,
793754
environment: string,
794-
remoteService: string
755+
remoteService: string,
756+
timeRange: string
795757
): string => `
796-
sum(request{namespace="span_derived",service="${service}",environment="${environment}",remoteService="${remoteService}"})
758+
sum(sum_over_time(request{namespace="span_derived",service="${service}",environment="${environment}",remoteService="${remoteService}"}[${timeRange}]))
797759
`;
798760

799761
/**
800762
* Get P99 latency for a specific edge
763+
* Uses avg_over_time to aggregate the histogram quantile over the selected time range
801764
* Returns latency in milliseconds
802765
* @param service - Source service name
803766
* @param environment - Source environment
804767
* @param remoteService - Target service name
768+
* @param timeRange - Time range string (e.g., "3600s")
805769
* @page App Map Edge Flyout — Edge P99 latency metric (via useSelectedEdgeMetrics hook)
806770
*/
807771
export const getQueryEdgeLatencyP99 = (
808772
service: string,
809773
environment: string,
810-
remoteService: string
774+
remoteService: string,
775+
timeRange: string
811776
): string => `
812-
histogram_quantile(0.99,
813-
sum by (le) (
814-
latency_seconds_bucket{namespace="span_derived",service="${service}",environment="${environment}",remoteService="${remoteService}"}
815-
)
777+
avg_over_time(
778+
histogram_quantile(0.99,
779+
sum by (le) (
780+
latency_seconds_bucket{namespace="span_derived",service="${service}",environment="${environment}",remoteService="${remoteService}"}
781+
)
782+
)[${timeRange}:]
816783
) * 1000
817784
`;
818785

819786
/**
820787
* Get fault count (5xx errors) for a specific edge
788+
* Uses sum_over_time to aggregate over the selected time range
821789
* @param service - Source service name
822790
* @param environment - Source environment
823791
* @param remoteService - Target service name
792+
* @param timeRange - Time range string (e.g., "3600s")
824793
* @page App Map Edge Flyout — Edge faults metric (via useSelectedEdgeMetrics hook)
825794
*/
826795
export const getQueryEdgeFaults = (
827796
service: string,
828797
environment: string,
829-
remoteService: string
798+
remoteService: string,
799+
timeRange: string
830800
): string => `
831-
sum(fault{namespace="span_derived",service="${service}",environment="${environment}",remoteService="${remoteService}"})
801+
sum(sum_over_time(fault{namespace="span_derived",service="${service}",environment="${environment}",remoteService="${remoteService}"}[${timeRange}]))
832802
`;
833803

834804
/**
835805
* Get error count (4xx errors) for a specific edge
806+
* Uses sum_over_time to aggregate over the selected time range
836807
* @param service - Source service name
837808
* @param environment - Source environment
838809
* @param remoteService - Target service name
810+
* @param timeRange - Time range string (e.g., "3600s")
839811
* @page App Map Edge Flyout — Edge errors metric (via useSelectedEdgeMetrics hook)
840812
*/
841813
export const getQueryEdgeErrors = (
842814
service: string,
843815
environment: string,
844-
remoteService: string
816+
remoteService: string,
817+
timeRange: string
845818
): string => `
846-
sum(error{namespace="span_derived",service="${service}",environment="${environment}",remoteService="${remoteService}"})
819+
sum(sum_over_time(error{namespace="span_derived",service="${service}",environment="${environment}",remoteService="${remoteService}"}[${timeRange}]))
847820
`;
848821

849822
// ============================================================================

0 commit comments

Comments
 (0)