Skip to content

Commit 345c294

Browse files
authored
feat(server): Cluster MOVED response Prometheus metric (#4786)
* feat(server): Cluster MOVED response Prometheus metric Get number of MOVED reported errors and send as Prometheus metric. Closes #4749 Signed-off-by: mkaruza <[email protected]> * Update help string --------- Signed-off-by: mkaruza <[email protected]>
1 parent 8ba7bd2 commit 345c294

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/server/server_family.cc

+15-4
Original file line numberDiff line numberDiff line change
@@ -1520,12 +1520,23 @@ void PrintPrometheusMetrics(uint64_t uptime, const Metrics& m, DflyCmd* dfly_cmd
15201520
}
15211521

15221522
if (IsClusterEnabled()) {
1523-
string str;
1523+
string migration_errors_str;
15241524
AppendMetricHeader("migration_errors_total", "Total error numbers of current migrations",
1525-
MetricType::GAUGE, &str);
1525+
MetricType::GAUGE, &migration_errors_str);
15261526
AppendMetricValue("migration_errors_total", m.migration_errors_total, {"num"},
1527-
{"migration errors"}, &str);
1528-
absl::StrAppend(&resp->body(), str);
1527+
{"migration errors"}, &migration_errors_str);
1528+
absl::StrAppend(&resp->body(), migration_errors_str);
1529+
1530+
string moved_errors_str;
1531+
uint64_t moved_total_errors = 0;
1532+
if (m.facade_stats.reply_stats.err_count.contains("MOVED")) {
1533+
moved_total_errors = m.facade_stats.reply_stats.err_count.at("MOVED");
1534+
}
1535+
AppendMetricHeader("moved_errors_total", "Total number of moved slot errors",
1536+
MetricType::COUNTER, &moved_errors_str);
1537+
AppendMetricValue("moved_errors_total", moved_total_errors, {"num"}, {"moved errors"},
1538+
&moved_errors_str);
1539+
absl::StrAppend(&resp->body(), moved_errors_str);
15291540
}
15301541

15311542
string db_key_metrics;

0 commit comments

Comments
 (0)