Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
filter: Clean up generation of per rule metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
mjs committed Apr 10, 2018
1 parent 7782183 commit e037211
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"time"

"github.com/jumptrading/influx-spout/config"
"github.com/jumptrading/influx-spout/prometheus"
"github.com/jumptrading/influx-spout/stats"
"github.com/nats-io/go-nats"
)
Expand Down Expand Up @@ -172,20 +171,16 @@ func (f *Filter) startStatistician(st *stats.Stats, rules *RuleSet) {
f.nc.Publish(f.c.NATSSubjectMonitor, lines)

// publish the per rule stats
// XXX merge with SnapshotToPrometheus
millis := now.UnixNano() / int64(time.Millisecond)
for i, subject := range rules.Subjects() {
metric := &prometheus.Metric{
Name: []byte("triggered"),
Labels: prometheus.LabelPairs{
{[]byte("filter"), []byte(f.c.Name)},
{[]byte("rule"), []byte(subject)},
f.nc.Publish(f.c.NATSSubjectMonitor, stats.CounterToPrometheus(
"triggered",
ruleCounts[i],
now,
map[string]string{
"filter": f.c.Name,
"rule": subject,
},
Value: int64(ruleCounts[i]),
Milliseconds: millis,
}

f.nc.Publish(f.c.NATSSubjectMonitor, metric.ToBytes())
))
}

select {
Expand Down

0 comments on commit e037211

Please sign in to comment.