use the same labels on all client metrics
This commit is contained in:
		
							parent
							
								
									ea66248c7b
								
							
						
					
					
						commit
						93d6aac27e
					
				|  | @ -39,27 +39,27 @@ type uclient struct { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func descClient(ns string) *uclient { | func descClient(ns string) *uclient { | ||||||
| 	labels := []string{"name", "mac", "site_name", "gw_mac", "gw_name", "sw_mac", "sw_name", "vlan", "ip", "oui", "network", "sw_port", "wired"} | 	labels := []string{"name", "mac", "site_name", "gw_mac", "gw_name", "sw_mac", "sw_name", "vlan", "ip", "oui", "network", "sw_port", | ||||||
| 	labelWireless := append([]string{"ap_mac", "ap_name", "radio_name", "radio", "radio_proto", "channel", "essid", "bssid", "radio_desc"}, labels...) | 		"ap_mac", "ap_name", "radio_name", "radio", "radio_proto", "channel", "essid", "bssid", "radio_desc", "wired"} | ||||||
| 	return &uclient{ | 	return &uclient{ | ||||||
| 		Anomalies:      prometheus.NewDesc(ns+"anomalies_total", "Client Anomalies", labelWireless, nil), | 		Anomalies:      prometheus.NewDesc(ns+"anomalies_total", "Client Anomalies", labels, nil), | ||||||
| 		BytesR:         prometheus.NewDesc(ns+"transfer_rate_bytes", "Client Data Rate", labelWireless, nil), | 		BytesR:         prometheus.NewDesc(ns+"transfer_rate_bytes", "Client Data Rate", labels, nil), | ||||||
| 		CCQ:            prometheus.NewDesc(ns+"ccq_percent", "Client Connection Quality", labelWireless, nil), | 		CCQ:            prometheus.NewDesc(ns+"ccq_percent", "Client Connection Quality", labels, nil), | ||||||
| 		Noise:          prometheus.NewDesc(ns+"noise_db", "Client AP Noise", labelWireless, nil), | 		Noise:          prometheus.NewDesc(ns+"noise_db", "Client AP Noise", labels, nil), | ||||||
| 		RoamCount:      prometheus.NewDesc(ns+"roam_count_total", "Client Roam Counter", labelWireless, nil), | 		RoamCount:      prometheus.NewDesc(ns+"roam_count_total", "Client Roam Counter", labels, nil), | ||||||
| 		RSSI:           prometheus.NewDesc(ns+"rssi_db", "Client RSSI", labelWireless, nil), | 		RSSI:           prometheus.NewDesc(ns+"rssi_db", "Client RSSI", labels, nil), | ||||||
| 		RxBytes:        prometheus.NewDesc(ns+"receive_bytes_total", "Client Receive Bytes", labels, nil), | 		RxBytes:        prometheus.NewDesc(ns+"receive_bytes_total", "Client Receive Bytes", labels, nil), | ||||||
| 		RxBytesR:       prometheus.NewDesc(ns+"receive_rate_bytes", "Client Receive Data Rate", labels, nil), | 		RxBytesR:       prometheus.NewDesc(ns+"receive_rate_bytes", "Client Receive Data Rate", labels, nil), | ||||||
| 		RxPackets:      prometheus.NewDesc(ns+"receive_packets_total", "Client Receive Packets", labels, nil), | 		RxPackets:      prometheus.NewDesc(ns+"receive_packets_total", "Client Receive Packets", labels, nil), | ||||||
| 		RxRate:         prometheus.NewDesc(ns+"radio_receive_rate_bps", "Client Receive Rate", labelWireless, nil), | 		RxRate:         prometheus.NewDesc(ns+"radio_receive_rate_bps", "Client Receive Rate", labels, nil), | ||||||
| 		Signal:         prometheus.NewDesc(ns+"radio_signal_db", "Client Signal Strength", labelWireless, nil), | 		Signal:         prometheus.NewDesc(ns+"radio_signal_db", "Client Signal Strength", labels, nil), | ||||||
| 		TxBytes:        prometheus.NewDesc(ns+"transmit_bytes_total", "Client Transmit Bytes", labels, nil), | 		TxBytes:        prometheus.NewDesc(ns+"transmit_bytes_total", "Client Transmit Bytes", labels, nil), | ||||||
| 		TxBytesR:       prometheus.NewDesc(ns+"transmit_rate_bytes", "Client Transmit Data Rate", labels, nil), | 		TxBytesR:       prometheus.NewDesc(ns+"transmit_rate_bytes", "Client Transmit Data Rate", labels, nil), | ||||||
| 		TxPackets:      prometheus.NewDesc(ns+"transmit_packets_total", "Client Transmit Packets", labels, nil), | 		TxPackets:      prometheus.NewDesc(ns+"transmit_packets_total", "Client Transmit Packets", labels, nil), | ||||||
| 		TxPower:        prometheus.NewDesc(ns+"radio_transmit_power_dbm", "Client Transmit Power", labelWireless, nil), | 		TxPower:        prometheus.NewDesc(ns+"radio_transmit_power_dbm", "Client Transmit Power", labels, nil), | ||||||
| 		TxRate:         prometheus.NewDesc(ns+"radio_transmit_rate_bps", "Client Transmit Rate", labelWireless, nil), | 		TxRate:         prometheus.NewDesc(ns+"radio_transmit_rate_bps", "Client Transmit Rate", labels, nil), | ||||||
| 		WifiTxAttempts: prometheus.NewDesc(ns+"wifi_attempts_transmit_total", "Client Wifi Transmit Attempts", labelWireless, nil), | 		WifiTxAttempts: prometheus.NewDesc(ns+"wifi_attempts_transmit_total", "Client Wifi Transmit Attempts", labels, nil), | ||||||
| 		Uptime:         prometheus.NewDesc(ns+"uptime_seconds", "Client Uptime", labelWireless, nil), | 		Uptime:         prometheus.NewDesc(ns+"uptime_seconds", "Client Uptime", labels, nil), | ||||||
| 		/* needs more "looking into" | 		/* needs more "looking into" | ||||||
| 		DpiStatsApp:       prometheus.NewDesc(ns+"dpi_stats_app", "Client DPI Stats App", labels, nil), | 		DpiStatsApp:       prometheus.NewDesc(ns+"dpi_stats_app", "Client DPI Stats App", labels, nil), | ||||||
| 		DpiStatsCat:       prometheus.NewDesc(ns+"dpi_stats_cat", "Client DPI Stats Cat", labels, nil), | 		DpiStatsCat:       prometheus.NewDesc(ns+"dpi_stats_cat", "Client DPI Stats Cat", labels, nil), | ||||||
|  | @ -85,45 +85,17 @@ func (u *unifiCollector) exportClients(r report) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (u *unifiCollector) exportClient(r report, c *unifi.Client) { | func (u *unifiCollector) exportClient(r report, c *unifi.Client) { | ||||||
| 	labels := []string{c.Name, c.Mac, c.SiteName, c.GwMac, c.GwName, c.SwMac, c.SwName, c.Vlan.Txt, c.IP, c.Oui, c.Network, c.SwPort.Txt, "false"} | 	labels := []string{c.Name, c.Mac, c.SiteName, c.GwMac, c.GwName, c.SwMac, c.SwName, c.Vlan.Txt, c.IP, c.Oui, c.Network, c.SwPort.Txt, | ||||||
| 	labelWireless := append([]string{c.ApMac, c.ApName, c.RadioName, c.Radio, c.RadioProto, c.Channel.Txt, c.Essid, c.Bssid, c.RadioDescription}, labels...) | 		c.ApMac, c.ApName, c.RadioName, c.Radio, c.RadioProto, c.Channel.Txt, c.Essid, c.Bssid, c.RadioDescription, "false"} | ||||||
| 
 | 
 | ||||||
| 	if c.IsWired.Val { |  | ||||||
| 		labels[len(labels)-1] = "true" |  | ||||||
| 		labelWireless[len(labelWireless)-1] = "true" |  | ||||||
| 		r.send([]*metricExports{ |  | ||||||
| 			{u.Client.RxBytes, prometheus.CounterValue, c.WiredRxBytes, labels}, |  | ||||||
| 			{u.Client.RxBytesR, prometheus.GaugeValue, c.WiredRxBytesR, labels}, |  | ||||||
| 			{u.Client.RxPackets, prometheus.CounterValue, c.WiredRxPackets, labels}, |  | ||||||
| 			{u.Client.TxBytes, prometheus.CounterValue, c.WiredTxBytes, labels}, |  | ||||||
| 			{u.Client.TxBytesR, prometheus.GaugeValue, c.WiredTxBytesR, labels}, |  | ||||||
| 			{u.Client.TxPackets, prometheus.CounterValue, c.WiredTxPackets, labels}, |  | ||||||
| 		}) |  | ||||||
| 	} else { |  | ||||||
| 		labels[len(labels)-1] = "false" |  | ||||||
| 		labelWireless[len(labelWireless)-1] = "false" |  | ||||||
| 		r.send([]*metricExports{ |  | ||||||
| 			{u.Client.Anomalies, prometheus.CounterValue, c.Anomalies, labelWireless}, |  | ||||||
| 			{u.Client.CCQ, prometheus.GaugeValue, c.Ccq, labelWireless}, |  | ||||||
| 			{u.Client.Noise, prometheus.GaugeValue, c.Noise, labelWireless}, |  | ||||||
| 			{u.Client.RoamCount, prometheus.CounterValue, c.RoamCount, labelWireless}, |  | ||||||
| 			{u.Client.RSSI, prometheus.GaugeValue, c.Rssi, labelWireless}, |  | ||||||
| 			{u.Client.Signal, prometheus.GaugeValue, c.Signal, labelWireless}, |  | ||||||
| 			{u.Client.TxPower, prometheus.GaugeValue, c.TxPower, labelWireless}, |  | ||||||
| 			{u.Client.TxRate, prometheus.GaugeValue, c.TxRate * 1000, labelWireless}, |  | ||||||
| 			{u.Client.WifiTxAttempts, prometheus.CounterValue, c.WifiTxAttempts, labelWireless}, |  | ||||||
| 			{u.Client.RxRate, prometheus.GaugeValue, c.RxRate * 1000, labelWireless}, |  | ||||||
| 			{u.Client.TxBytes, prometheus.CounterValue, c.TxBytes, labels}, |  | ||||||
| 			{u.Client.TxBytesR, prometheus.GaugeValue, c.TxBytesR, labels}, |  | ||||||
| 			{u.Client.TxPackets, prometheus.CounterValue, c.TxPackets, labels}, |  | ||||||
| 			{u.Client.RxBytes, prometheus.CounterValue, c.RxBytes, labels}, |  | ||||||
| 			{u.Client.RxBytesR, prometheus.GaugeValue, c.RxBytesR, labels}, |  | ||||||
| 			{u.Client.RxPackets, prometheus.CounterValue, c.RxPackets, labels}, |  | ||||||
| 			{u.Client.BytesR, prometheus.GaugeValue, c.BytesR, labelWireless}, |  | ||||||
| 		}) |  | ||||||
| 	} |  | ||||||
| 	r.send([]*metricExports{ | 	r.send([]*metricExports{ | ||||||
| 		{u.Client.Uptime, prometheus.GaugeValue, c.Uptime, labelWireless}, | 		{u.Client.Uptime, prometheus.GaugeValue, c.Uptime, labels}, | ||||||
|  | 		{u.Client.RxBytes, prometheus.CounterValue, c.WiredRxBytes, labels}, | ||||||
|  | 		{u.Client.RxBytesR, prometheus.GaugeValue, c.WiredRxBytesR, labels}, | ||||||
|  | 		{u.Client.RxPackets, prometheus.CounterValue, c.WiredRxPackets, labels}, | ||||||
|  | 		{u.Client.TxBytes, prometheus.CounterValue, c.WiredTxBytes, labels}, | ||||||
|  | 		{u.Client.TxBytesR, prometheus.GaugeValue, c.WiredTxBytesR, labels}, | ||||||
|  | 		{u.Client.TxPackets, prometheus.CounterValue, c.WiredTxPackets, labels}, | ||||||
| 		/* needs more "looking into" | 		/* needs more "looking into" | ||||||
| 		{u.Client.DpiStatsApp, prometheus.GaugeValue, c.DpiStats.App, labels}, | 		{u.Client.DpiStatsApp, prometheus.GaugeValue, c.DpiStats.App, labels}, | ||||||
| 		{u.Client.DpiStatsCat, prometheus.GaugeValue, c.DpiStats.Cat, labels}, | 		{u.Client.DpiStatsCat, prometheus.GaugeValue, c.DpiStats.Cat, labels}, | ||||||
|  | @ -133,4 +105,21 @@ func (u *unifiCollector) exportClient(r report, c *unifi.Client) { | ||||||
| 		{u.Client.DpiStatsTxPackets, prometheus.CounterValue, c.DpiStats.TxPackets, labels}, | 		{u.Client.DpiStatsTxPackets, prometheus.CounterValue, c.DpiStats.TxPackets, labels}, | ||||||
| 		*/ | 		*/ | ||||||
| 	}) | 	}) | ||||||
|  | 	if !c.IsWired.Val { | ||||||
|  | 		labels[len(labels)-1] = "false" | ||||||
|  | 		r.send([]*metricExports{ | ||||||
|  | 			{u.Client.Anomalies, prometheus.CounterValue, c.Anomalies, labels}, | ||||||
|  | 			{u.Client.CCQ, prometheus.GaugeValue, c.Ccq, labels}, | ||||||
|  | 			{u.Client.Noise, prometheus.GaugeValue, c.Noise, labels}, | ||||||
|  | 			{u.Client.RoamCount, prometheus.CounterValue, c.RoamCount, labels}, | ||||||
|  | 			{u.Client.RSSI, prometheus.GaugeValue, c.Rssi, labels}, | ||||||
|  | 			{u.Client.Signal, prometheus.GaugeValue, c.Signal, labels}, | ||||||
|  | 			{u.Client.TxPower, prometheus.GaugeValue, c.TxPower, labels}, | ||||||
|  | 			{u.Client.TxRate, prometheus.GaugeValue, c.TxRate * 1000, labels}, | ||||||
|  | 			{u.Client.WifiTxAttempts, prometheus.CounterValue, c.WifiTxAttempts, labels}, | ||||||
|  | 			{u.Client.RxRate, prometheus.GaugeValue, c.RxRate * 1000, labels}, | ||||||
|  | 			{u.Client.BytesR, prometheus.GaugeValue, c.BytesR, labels}, | ||||||
|  | 		}) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue