diff --git a/collector/dhcp_lease_collector.go b/collector/dhcp_lease_collector.go index 85b2bcc..3b3ee5c 100644 --- a/collector/dhcp_lease_collector.go +++ b/collector/dhcp_lease_collector.go @@ -78,5 +78,13 @@ func (c *dhcpLeaseCollector) collectMetric(ctx *collectorContext, re *proto.Sent activeaddress := re.Map["active-address"] hostname := re.Map["host-name"] - ctx.ch <- prometheus.MustNewConstMetric(c.descriptions, prometheus.GaugeValue, v, ctx.device.Name, ctx.device.Address, activemacaddress, server, status, strconv.FormatFloat(f, 'f', 0, 64), activeaddress, hostname) + metric, err := prometheus.NewConstMetric(c.descriptions, prometheus.GaugeValue, v, ctx.device.Name, ctx.device.Address, activemacaddress, server, status, strconv.FormatFloat(f, 'f', 0, 64), activeaddress, hostname) + if err != nil { + log.WithFields(log.Fields{ + "device": ctx.device.Name, + "error": err, + }).Error("error parsing dhcp lease") + return + } + ctx.ch <- metric }