From 98b29abfffb08a90406ba27d38cc695db93953fa Mon Sep 17 00:00:00 2001 From: Tommaso Bailetti Date: Tue, 26 May 2026 14:11:12 +0200 Subject: [PATCH] refactor: using telegraf for new metrics --- api/methods/unit.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/api/methods/unit.go b/api/methods/unit.go index 449c929d..89aa3042 100644 --- a/api/methods/unit.go +++ b/api/methods/unit.go @@ -956,14 +956,27 @@ func GetPrometheusTargets(c *gin.Context) { unitIp, ok2 := unit["ipaddress"].(string) if ok1 && ok2 { - target := gin.H{ + // Netdata target (port 19999) + netdataTarget := gin.H{ "targets": []string{unitIp + ":19999"}, "labels": gin.H{ "node": unitIp, "unit": unitId, + "metrics_type": "netdata", "__metrics_path__": "/api/v1/allmetrics?format=prometheus&help=no"}, } - targets = append(targets, target) + targets = append(targets, netdataTarget) + + // Telegraf target (port 9273) + telegrafTarget := gin.H{ + "targets": []string{unitIp + ":9273"}, + "labels": gin.H{ + "node": unitIp, + "unit": unitId, + "metrics_type": "telegraf", + "__metrics_path__": "/metrics"}, + } + targets = append(targets, telegrafTarget) } }