Skip to content

Commit

Permalink
Add input counters and names to Filebeat state API
Browse files Browse the repository at this point in the history
The reported document looks as following:

```
{
  "input": {
    "count": 4,
    "names": [
      "log",
      "redis"
    ]
  },
  "output": {
    "name": "elasticsearch"
  }
}
```
  • Loading branch information
ruflin committed Jul 9, 2018
1 parent 606f961 commit 0887bbb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions filebeat/input/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ import (
"github.com/elastic/beats/filebeat/input/file"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/libbeat/monitoring"
)

var (
inputList = monitoring.NewUniqueList()
)

func init() {
monitoring.NewFunc(monitoring.GetNamespace("state").GetRegistry(), "input", inputList.Report, monitoring.Report)
}

// Input is the interface common to all input
type Input interface {
Run()
Expand Down Expand Up @@ -111,6 +120,7 @@ func (p *Runner) Start() {
}

onceWg.Add(1)
inputList.Add(p.config.Type)
// Add waitgroup to make sure input is finished
go func() {
defer func() {
Expand Down Expand Up @@ -150,6 +160,7 @@ func (p *Runner) Stop() {
// Stop scanning and wait for completion
close(p.done)
p.wg.Wait()
inputList.Remove(p.config.Type)
}

func (p *Runner) stop() {
Expand Down

0 comments on commit 0887bbb

Please sign in to comment.