-
Notifications
You must be signed in to change notification settings - Fork 17
Inconsistent metric status when collector is down #10328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The dashboard (when showing one date) determines the status of metrics by looking up the latest measurement that has today's date: export function measurementOnDate(date, measurements, metricUuid) {
const isoDateString = date.toISOString().split("T")[0]
return measurements?.find((m) => {
return (
m.metric_uuid === metricUuid &&
m.start.split("T")[0] <= isoDateString &&
isoDateString <= m.end.split("T")[0]
)
})
}
function metricStatusOnDate(metricUuid, metric, measurements, date, dataModel) {
const measurement = measurementOnDate(date, measurements, metricUuid)
const scale = getMetricScale(metric, dataModel)
return measurement?.[scale]?.status ?? "unknown"
} The subject table (when showing one date) determines the status of the metrics by looking at the metrics's status attribute which is set by the API-server based on the latest measurement when returning the report: class Metric(dict):
"""Class representing a metric."""
def status(self, last_measurement: Measurement | None) -> Status | None:
"""Determine the metric status."""
if last_measurement and (status := last_measurement.status()):
return status
return "debt_target_met" if self.accept_debt() and not self.debt_end_date_passed() else None
def summarize(self, measurements: list[Measurement], **kwargs) -> dict:
"""Add a summary of the metric to the report."""
latest_measurement = measurements[-1] if measurements else None
summary = dict(self)
summary["scale"] = self.scale()
summary["status"] = self.status(latest_measurement)
summary["status_start"] = latest_measurement.status_start() if latest_measurement else None
summary["latest_measurement"] = latest_measurement.summarize_latest() if latest_measurement else None
summary["recent_measurements"] = [measurement.summarize() for measurement in measurements]
if latest_measurement:
summary["issue_status"] = self.issue_statuses(latest_measurement)
summary.update(kwargs)
return summary This means that the metric status as reported by the dashboard and by the subject table will differ if the latest measurement's date is not today. To prevent this discrepancy, the dashboard and subject table should determine the status in the same way. |
Describe the bug
When the collector is down, dashboard cards and subject tables may seem to be inconsistent.
When the collector is down, no new measurements are made. After a while the frontend will start to notice this and mark the status of metrics as unknown in the dashboard. However, in the subject table, the last know status of metrics will still be shown (e.g. a metric meeting its target is still green). The measurement value will get a red background and the popup will explain to the user why the measurement value has the red background.
Expected behaviour
When the above scenario happens, mark the metrics as unknown (white) in the subject table. Check that the popup explains that the collector hasn't measured the metric for more than 1 (2?) hours.
CC: @Sebastiaan127001
The text was updated successfully, but these errors were encountered: