30 Sep 2025 05:01 AM
We are trying to build a metric to monitor the success vs failure rate of an API over time.
Requirement:
Issue:
Using the below DQL, we are able to generate the data. However, the output splits into multiple Success and Failure counts. For example, within a 5-minute interval, each unique combination of endpoint, client, service, and status is treated as a separate record.
Our expectation is to see only two records per timeframe (Success and Failure totals), but instead we are getting multiple entries.
We attempted to use dedup status to consolidate the records, but this results in loss of data and incorrect counts.
Looking for an alternate approach that allows us to aggregate Success and Failure counts properly and visualize them as a bar/line graph.
"If we try to summarize success and failure, then Line Graph goes unsupported."
timeseries {
value = sum(service.muleapi.response.count)
},
by: {dt.entity.service, http.response.status_code},
filter: {
in(endpoint.name, array($Endpoint)) AND in(`request_attribute.Client-Id`, array($Client_ID))
}
| lookup [
data record(service_id = "SERVICE-EXXXFB", api_name = "ABC"),
record(service_id = "SERVICE-9XXXX448", api_name = "DEF"),
record(service_id = "SERVICE-FXXXX926", api_name ="XYZ")
], sourceField: dt.entity.service, lookupField: service_id
| fieldsAdd API = lookup.api_name
| fieldsRemove lookup.service_id, lookup.api_name
| filter in(API, array($API_Name))
| fieldsAdd status = if(condition: http.response.status_code >= 400 AND http.response.status_code < 600,
then: "Failure", else: "Success" )
| sort status desc
//| dedup status
Screenshots: Line Graph with geometry as bar graph
Without dedup (with Legend) – multiple Success/Failure bars per timeframe
Without dedup (no Legend) – Graph looks fine visually, but bars still represent multiple records instead of aggregated totals
With dedup – Inaccurate data as multiple records are dropped
Please suggest an alternate approach (without dedup) to aggregate Success vs Failure counts per timeframe, so that we only see two entries (Success, Failure) per interval?
30 Sep 2025 03:02 PM - edited 30 Sep 2025 03:08 PM
Try to add a |maketimeseries sum(value), by:{status}