Skip to content

Commit

Permalink
Treat HC/HP values as gauges. Compute difference in DD graph
Browse files Browse the repository at this point in the history
  • Loading branch information
j-vizcaino committed Jul 21, 2018
1 parent 0433828 commit 86083dc
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ func buildFrameTags(f teleinfo.Frame) []string {
}

func exportFrames(dsd *statsd.Client, framesChan chan teleinfo.Frame) {
counters := map[string]string{
gauges := map[string]string{
"HCHC": "counter_low_price_kwh",
"HCHP": "counter_full_price_kwh",
}
gauges := map[string]string{
"PAPP": "power_va",
"IINST": "current_amps",
}
Expand All @@ -78,17 +76,6 @@ func exportFrames(dsd *statsd.Client, framesChan chan teleinfo.Frame) {
continue
}

for key, metric := range counters {
value, ok := f.GetUIntField(key)
if !ok {
s, _ := f.GetStringField(key)
log.WithFields(log.Fields{"field_name": key, "field_value": s, "metric": metric}).Warn("Cannot extract metric value from frame")
continue
}
log.WithFields(log.Fields{"value": value, "metric": metric, "namespace": dsd.Namespace, "tags": tags}).Debug("Sending dogstatsd counter")
dsd.Count(metric, int64(value), tags, 1)
}

for key, metric := range gauges {
value, ok := f.GetUIntField(key)
if !ok {
Expand Down

0 comments on commit 86083dc

Please sign in to comment.