fix: added tag key for devices, so it doesn't only register the last one in the list

Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
Louis Vallat 2022-07-02 13:31:36 +02:00
parent 4280261c1e
commit da1fa96505
No known key found for this signature in database
GPG Key ID: 0C87282F76E61283

View File

@ -125,23 +125,21 @@ async fn devices_to_datapoints(devices: &Vec<Device>, hostname: &String)
for d in devices {
datapoints.append(&mut vec![
DataPoint::builder("devices").tag("hostname", hostname)
.field("key", d.key.clone()).build().unwrap(),
.field("name", d.name.clone()).tag("key", d.key.clone()).build().unwrap(),
DataPoint::builder("devices").tag("hostname", hostname)
.field("name", d.name.clone()).build().unwrap(),
.field("discovery_source", d.discovery_source.clone()).tag("key", d.key.clone()).build().unwrap(),
DataPoint::builder("devices").tag("hostname", hostname)
.field("discovery_source", d.discovery_source.clone()).build().unwrap(),
.field("active", d.active).tag("key", d.key.clone()).build().unwrap(),
DataPoint::builder("devices").tag("hostname", hostname)
.field("active", d.active).build().unwrap(),
.field("device_type", d.device_type.clone()).tag("key", d.key.clone()).build().unwrap(),
DataPoint::builder("devices").tag("hostname", hostname)
.field("device_type", d.device_type.clone()).build().unwrap(),
.field("tags", d.tags.clone()).tag("key", d.key.clone()).build().unwrap(),
DataPoint::builder("devices").tag("hostname", hostname)
.field("tags", d.tags.clone()).build().unwrap(),
.field("ip_address", d.ip_address.clone().unwrap_or("N/A".to_string())).tag("key", d.key.clone()).build().unwrap(),
DataPoint::builder("devices").tag("hostname", hostname)
.field("ip_address", d.ip_address.clone().unwrap_or("N/A".to_string())).build().unwrap(),
.field("ssid", d.ssid.clone().unwrap_or("N/A".to_string())).tag("key", d.key.clone()).build().unwrap(),
DataPoint::builder("devices").tag("hostname", hostname)
.field("ssid", d.ssid.clone().unwrap_or("N/A".to_string())).build().unwrap(),
DataPoint::builder("devices").tag("hostname", hostname)
.field("channel", d.channel.unwrap_or(0) as i64).build().unwrap(),
.field("channel", d.channel.unwrap_or(0) as i64).tag("key", d.key.clone()).build().unwrap(),
]);
}
return datapoints;