diff --git a/scripts/lua/modules/alert_utils.lua b/scripts/lua/modules/alert_utils.lua
index 4fc9674af7..33a68b768d 100644
--- a/scripts/lua/modules/alert_utils.lua
+++ b/scripts/lua/modules/alert_utils.lua
@@ -1822,7 +1822,7 @@ function alert_utils.formatAlertMessage(ifid, alert, alert_json)
local active_monitoring_utils = plugins_utils.loadModule("active_monitoring", "am_utils")
local host = active_monitoring_utils.key2host(alert.alert_entity_val)
- if host and host.measurement then
+ if host and host.measurement and not host.is_infrastructure then
msg = msg .. ' '
end
diff --git a/scripts/plugins/monitors/network/active_monitoring/httpdocs/active_monitoring_utils.js b/scripts/plugins/monitors/network/active_monitoring/httpdocs/active_monitoring_utils.js
index 6fe4958ecf..d96d411b06 100644
--- a/scripts/plugins/monitors/network/active_monitoring/httpdocs/active_monitoring_utils.js
+++ b/scripts/plugins/monitors/network/active_monitoring/httpdocs/active_monitoring_utils.js
@@ -379,7 +379,7 @@ $(document).ready(function() {
},
columns: [
{
- data: 'formatted_label',
+ data: 'label',
render: function(label, type, row) {
if (type === 'display') {
if (label == "" || label == undefined) return "";
diff --git a/scripts/plugins/monitors/network/active_monitoring/modules/am_utils.lua b/scripts/plugins/monitors/network/active_monitoring/modules/am_utils.lua
index 9add0a0fb9..0064b75e88 100644
--- a/scripts/plugins/monitors/network/active_monitoring/modules/am_utils.lua
+++ b/scripts/plugins/monitors/network/active_monitoring/modules/am_utils.lua
@@ -218,19 +218,6 @@ end
-- ##############################################
---- Format the label of an host, if the host belong to the infrastructure page
---- then append a badge
-function am_utils.format_label(host)
-
- if (host.token) then
- return string.gsub(host.label, "/lua/.+", " ".. i18n("infrastructure_dashboard.infrastructure") .."")
- end
-
- return host.label
-end
-
--- ##############################################
-
function am_utils.dropHourStats(host_key)
ntop.delCache(am_hour_stats_key(host_key))
end
@@ -284,6 +271,25 @@ end
-- ##############################################
+-- @brief Check if this is an infrastructure active monitoring url
+local function is_infrastructure(host)
+ if not ntop.isEnterpriseM() or isEmptyString(host) then
+ return false
+ end
+
+ package.path = dirs.installdir .. "/pro/scripts/lua/enterprise/modules/?.lua;" .. package.path
+ local infrastructure_utils = require("infrastructure_utils")
+
+ -- The host is considered an infrastructure host if it contains the endpoint in the name
+ if host:find(infrastructure_utils.ENDPOINT_TO_EXTRACT_DATA) then
+ return true
+ end
+
+ return false
+end
+
+-- ##############################################
+
-- Only used for the formatting, don't use as a key as the "/"
-- character is escaped in HTTP parameters
function am_utils.formatAmHost(host, measurement)
@@ -294,7 +300,14 @@ function am_utils.formatAmHost(host, measurement)
--return(host)
--end
- return(string.format("%s://%s", measurement, host))
+ -- Make a smarter way to determine infrastructure labels
+ local res = string.format("%s://%s", measurement, host)
+ if is_infrastructure(host) then
+ -- Make a nicer label for infrastructure hosts
+ res = res:gsub("/lua/.+", " ".. i18n("infrastructure_dashboard.infrastructure") .."")
+ end
+
+ return res
end
-- ##############################################
@@ -304,6 +317,7 @@ function am_utils.key2host(host_key)
return {
label = am_utils.formatAmHost(host, measurement),
+ is_infrastructure = is_infrastructure(host),
measurement = measurement,
host = host,
}
diff --git a/scripts/plugins/monitors/network/active_monitoring/web_gui/get_active_monitoring_hosts.lua b/scripts/plugins/monitors/network/active_monitoring/web_gui/get_active_monitoring_hosts.lua
index a7f3695368..f113db541f 100644
--- a/scripts/plugins/monitors/network/active_monitoring/web_gui/get_active_monitoring_hosts.lua
+++ b/scripts/plugins/monitors/network/active_monitoring/web_gui/get_active_monitoring_hosts.lua
@@ -91,7 +91,6 @@ for key, am_host in pairs(am_hosts) do
end
res[#res + 1] = {
key = key,
- formatted_label = am_utils.format_label(am_host),
label = am_host.label,
host = am_host.host,
alerted = alerted,