metric file rename

This commit is contained in:
aexel90 2020-12-29 14:24:09 +01:00
parent 050d40cf27
commit 06b264fdd5
3 changed files with 10 additions and 2 deletions

View file

@ -23,6 +23,7 @@ type collectEntry struct {
const (
typeLight = "light"
typeSensor = "sensor"
typeBridge = "bridge"
labelName = "name"
labelType = "type"
@ -127,12 +128,19 @@ func (exporter *Exporter) Collect(metrics []*metric.Metric) (err error) {
return err
}
bridgeData, err := collectBridgeInfo(bridge)
if err != nil {
return err
}
for _, metric := range metrics {
switch metric.HueType {
case typeLight:
metric.MetricResult = lightData
case typeSensor:
metric.MetricResult = sensorData
case typeBridge:
metric.MetricResult = bridgeData
default:
return fmt.Errorf("Type '%v' currently not supported", metric.HueType)
}

View file

@ -32,7 +32,7 @@
]
},
{
"type": "sesnsor",
"type": "sensor",
"fqname": "hue_sensor_info",
"help": "Non-numeric data, value is always 1",
"labels": [

View file

@ -20,7 +20,7 @@ var (
flagBridgeURL = flag.String("hue-url", "", "The URL of the bridge")
flagUsername = flag.String("username", "", "The username token having bridge access")
flagAddress = flag.String("listen-address", "127.0.0.1:9773", "The address to listen on for HTTP requests.")
flagMetricsFile = flag.String("metrics-file", "metrics.json", "The JSON file with the metric definitions.")
flagMetricsFile = flag.String("metrics-file", "hue_metrics.json", "The JSON file with the metric definitions.")
flagTest = flag.Bool("test", false, "test configured metrics")
flagCollect = flag.Bool("collect", false, "test configured metrics")