Browse Source

moved fixedLabels to promDesc

pull/4/head
sberk42 4 years ago
parent
commit
320ad2d613
  1. 13
      fritzbox_lua/lua_client.go
  2. 33
      main.go
  3. 24
      metrics-lua.json

13
fritzbox_lua/lua_client.go

@ -57,11 +57,10 @@ type LuaPage struct {
// LuaMetricValueDefinition definition for a single metric
type LuaMetricValueDefinition struct {
Path string
Key string
OkValue string
Labels []string
FixedLabels map[string]string
Path string
Key string
OkValue string
Labels []string
}
// LuaMetricValue single value retrieved from lua page
@ -110,10 +109,6 @@ func (lmvDef *LuaMetricValueDefinition) createValue(name string, value float64)
Labels: make(map[string]string),
}
for l := range lmvDef.FixedLabels {
lmv.Labels[l] = lmvDef.FixedLabels[l]
}
return lmv
}

33
main.go

@ -71,9 +71,10 @@ var (
)
type JSON_PromDesc struct {
FqName string `json:"fqName"`
Help string `json:"help"`
VarLabels []string `json:"varLabels"`
FqName string `json:"fqName"`
Help string `json:"help"`
VarLabels []string `json:"varLabels"`
FixedLabels map[string]string `json:"fixedLabels"`
}
type ActionArg struct {
@ -110,14 +111,13 @@ type LuaLabelRename struct {
type LuaMetric struct {
// initialized loading JSON
Path string `json:"path"`
Params string `json:"params"`
ResultPath string `json:"resultPath"`
ResultKey string `json:"resultKey"`
OkValue string `json:"okValue"`
FixedLabels map[string]string `json:"fixedLabels"`
PromDesc JSON_PromDesc `json:"promDesc"`
PromType string `json:"promType"`
Path string `json:"path"`
Params string `json:"params"`
ResultPath string `json:"resultPath"`
ResultKey string `json:"resultKey"`
OkValue string `json:"okValue"`
PromDesc JSON_PromDesc `json:"promDesc"`
PromType string `json:"promType"`
// initialized at startup
Desc *prometheus.Desc
@ -643,7 +643,7 @@ func main() {
labels[i] = strings.ToLower(l)
}
lm.Desc = prometheus.NewDesc(pd.FqName, pd.Help, labels, nil)
lm.Desc = prometheus.NewDesc(pd.FqName, pd.Help, labels, pd.FixedLabels)
lm.MetricType = getValueType(lm.PromType)
lm.LuaPage = lua.LuaPage{
@ -652,11 +652,10 @@ func main() {
}
lm.LuaMetricDef = lua.LuaMetricValueDefinition{
Path: lm.ResultPath,
Key: lm.ResultKey,
OkValue: lm.OkValue,
Labels: pd.VarLabels,
FixedLabels: lm.FixedLabels,
Path: lm.ResultPath,
Key: lm.ResultKey,
OkValue: lm.OkValue,
Labels: pd.VarLabels,
}
}

24
metrics-lua.json

@ -92,13 +92,15 @@
"params": "page=ecoStat",
"resultPath": "data.ramusage.series.0",
"resultKey": "-1",
"fixedLabels": { "ram_type" : "Fixed" },
"promDesc": {
"fqName": "gateway_data_ecostat_ramusage",
"help": "percentage of RAM utilization from data.lua?page=energy",
"varLabels": [
"gateway", "ram_type"
]
"gateway"
],
"fixedLabels": {
"ram_type" : "Fixed"
}
},
"promType": "GaugeValue"
},
@ -107,13 +109,15 @@
"params": "page=ecoStat",
"resultPath": "data.ramusage.series.1",
"resultKey": "-1",
"fixedLabels": { "ram_type" : "Dynamic" },
"promDesc": {
"fqName": "gateway_data_ecostat_ramusage",
"help": "percentage of RAM utilization from data.lua?page=energy",
"varLabels": [
"gateway", "ram_type"
]
"gateway"
],
"fixedLabels": {
"ram_type" : "Dynamic"
}
},
"promType": "GaugeValue"
},
@ -122,13 +126,15 @@
"params": "page=ecoStat",
"resultPath": "data.ramusage.series.2",
"resultKey": "-1",
"fixedLabels": { "ram_type" : "Free" },
"promDesc": {
"fqName": "gateway_data_ecostat_ramusage",
"help": "percentage of RAM utilization from data.lua?page=energy",
"varLabels": [
"gateway", "ram_type"
]
"gateway"
],
"fixedLabels": {
"ram_type" : "Free"
}
},
"promType": "GaugeValue"
},

Loading…
Cancel
Save