Skip to content

Commit

Permalink
Add cardinality count to HTTPOutNode
Browse files Browse the repository at this point in the history
  • Loading branch information
desa committed Mar 2, 2017
1 parent f3fb481 commit bc447fc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions http_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path"
"sync"

"github.com/influxdata/kapacitor/expvar"
"github.com/influxdata/kapacitor/models"
"github.com/influxdata/kapacitor/pipeline"
"github.com/influxdata/kapacitor/services/httpd"
Expand All @@ -20,6 +21,8 @@ type HTTPOutNode struct {
endpoint string
routes []httpd.Route
mu sync.RWMutex

nodeCardinality *expvar.IntFuncGauge
}

// Create a new HTTPOutNode which caches the most recent item and exposes it over the HTTP API.
Expand All @@ -30,6 +33,12 @@ func newHTTPOutNode(et *ExecutingTask, n *pipeline.HTTPOutNode, l *log.Logger) (
groupSeriesIdx: make(map[models.GroupID]int),
result: new(models.Result),
}
hn.nodeCardinality = expvar.NewIntFuncGauge(func() int {
hn.mu.RLock()
l := len(hn.groupSeriesIdx)
hn.mu.RUnlock()
return l
})
et.registerOutput(hn.c.Endpoint, hn)
hn.node.runF = hn.runOut
hn.node.stopF = hn.stopOut
Expand All @@ -41,6 +50,8 @@ func (h *HTTPOutNode) Endpoint() string {
}

func (h *HTTPOutNode) runOut([]byte) error {
// h.nodeCardinality is assigned in newHTTPOutNode
h.statMap.Set(statsCardinalityGauge, h.nodeCardinality)

hndl := func(w http.ResponseWriter, req *http.Request) {
h.mu.RLock()
Expand Down

0 comments on commit bc447fc

Please sign in to comment.