This commit is contained in:
MichaelDvP
2025-12-11 16:26:16 +01:00
6 changed files with 288 additions and 19 deletions

View File

@@ -1766,8 +1766,11 @@ std::string EMSdevice::get_metrics_prometheus(const int8_t tag) {
metric_name = metric_name.substr(last_dot + 1);
}
// sanitize metric name: convert to lowercase and replace non-alphanumeric with underscores
for (char & c : metric_name) {
if (!isalnum(c) && c != '_') {
if (isupper(c)) {
c = tolower(c);
} else if (!isalnum(c) && c != '_') {
c = '_';
}
}