influxdb/telegraf/plugins/inputs/tail.go

39 lines
931 B
Go
Raw Normal View History

2018-10-05 21:43:01 +00:00
package inputs
import (
"fmt"
"strconv"
"strings"
)
// Tail is based on telegraf Tail plugin.
type Tail struct {
2018-10-16 00:38:36 +00:00
baseInput
2018-10-05 21:43:01 +00:00
Files []string `json:"files"`
}
2018-10-16 00:38:36 +00:00
// PluginName is based on telegraf plugin name.
func (t *Tail) PluginName() string {
return "tail"
}
2018-10-05 21:43:01 +00:00
// TOML encodes to toml string
func (t *Tail) TOML() string {
s := make([]string, len(t.Files))
2018-10-05 21:43:01 +00:00
for k, v := range t.Files {
2018-10-05 21:43:01 +00:00
s[k] = strconv.Quote(v)
}
2018-10-16 00:38:36 +00:00
return fmt.Sprintf(`[[inputs.%s]]
2018-10-05 21:43:01 +00:00
## files to tail.
## These accept standard unix glob matching rules, but with the addition of
## ** as a "super asterisk". ie:
## "/var/log/**.log" -> recursively find all .log files in /var/log
## "/var/log/*/*.log" -> find all .log files with a parent dir in /var/log
## "/var/log/apache.log" -> just tail the apache log file
##
## See https://github.com/gobwas/glob for more examples
##
files = [%s]
2018-10-16 00:38:36 +00:00
`, t.PluginName(), strings.Join(s, ", "))
2018-10-05 21:43:01 +00:00
}