add plugins
parent
e643c434f6
commit
ff27648dcd
|
@ -0,0 +1,10 @@
|
|||
package inputs
|
||||
|
||||
// CPUStats is based on telegraf CPUStats.
|
||||
type CPUStats struct{}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (c *CPUStats) TOML() string {
|
||||
return `[[inputs.cpu]]
|
||||
`
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package inputs
|
||||
|
||||
// DiskStats is based on telegraf DiskStats.
|
||||
type DiskStats struct{}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (d *DiskStats) TOML() string {
|
||||
return `[[inputs.disk]]
|
||||
`
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package inputs
|
||||
|
||||
// DiskIO is based on telegraf DiskIO.
|
||||
type DiskIO struct{}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (d *DiskIO) TOML() string {
|
||||
return `[[inputs.diskio]]
|
||||
`
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package inputs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Docker is based on telegraf Docker plugin.
|
||||
type Docker struct {
|
||||
Endpoint string `json:"endpoint"`
|
||||
}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (d *Docker) TOML() string {
|
||||
return fmt.Sprintf(`[[inputs.docker]]
|
||||
## Docker Endpoint
|
||||
## To use TCP, set endpoint = "tcp://[ip]:[port]"
|
||||
## To use environment variables (ie, docker-machine), set endpoint = "ENV"
|
||||
## exp: unix:///var/run/docker.sock
|
||||
endpoint = "%s"
|
||||
`, d.Endpoint)
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package inputs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// File is based on telegraf input File plugin.
|
||||
type File struct {
|
||||
Files []string `json:"files"`
|
||||
}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (f *File) TOML() string {
|
||||
s := make([]string, len(f.Files))
|
||||
for k, v := range s {
|
||||
s[k] = strconv.Quote(v)
|
||||
}
|
||||
return fmt.Sprintf(`[[inputs.file]]
|
||||
## Files to parse each interval.
|
||||
## 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 -> only read the apache log file
|
||||
files = [%s]
|
||||
`, strings.Join(f.Files, ", "))
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package inputs
|
||||
|
||||
// Kernel is based on telegraf Kernel.
|
||||
type Kernel struct{}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (k *Kernel) TOML() string {
|
||||
return `[[inputs.kernel]]
|
||||
`
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package inputs
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Kubernetes is based on telegraf Kubernetes plugin
|
||||
type Kubernetes struct {
|
||||
URL string `json:"url"`
|
||||
}
|
||||
|
||||
// TOML encodes to toml string.
|
||||
func (k *Kubernetes) TOML() string {
|
||||
return fmt.Sprintf(`[[inputs.kubernetes]]
|
||||
## URL for the kubelet
|
||||
## exp: http://1.1.1.1:10255
|
||||
url = "%s"
|
||||
`, k.URL)
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package inputs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// LogParserPlugin is based on telegraf LogParserPlugin.
|
||||
type LogParserPlugin struct {
|
||||
Files []string `json:"files"`
|
||||
}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (l *LogParserPlugin) TOML() string {
|
||||
s := make([]string, len(l.Files))
|
||||
for k, v := range s {
|
||||
s[k] = strconv.Quote(v)
|
||||
}
|
||||
return fmt.Sprintf(`[[inputs.logparser]]
|
||||
## Log files to parse.
|
||||
## 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 -> only tail the apache log file
|
||||
files = [%s]
|
||||
`, strings.Join(s, ", "))
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package inputs
|
||||
|
||||
// MemStats is based on telegraf MemStats.
|
||||
type MemStats struct{}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (m *MemStats) TOML() string {
|
||||
return `[[inputs.mem]]
|
||||
`
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package inputs
|
||||
|
||||
// NetIOStats is based on telegraf NetIOStats.
|
||||
type NetIOStats struct{}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (n *NetIOStats) TOML() string {
|
||||
return `[[inputs.net]]
|
||||
`
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package inputs
|
||||
|
||||
// NetResponse is based on telegraf NetResponse.
|
||||
type NetResponse struct{}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (n *NetResponse) TOML() string {
|
||||
return `[[inputs.net_response]]
|
||||
`
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package inputs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Nginx is based on telegraf nginx plugin.
|
||||
type Nginx struct {
|
||||
URLs []string `json:"urls,omitempty"`
|
||||
}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (n *Nginx) TOML() string {
|
||||
s := make([]string, len(n.URLs))
|
||||
for k, v := range s {
|
||||
s[k] = strconv.Quote(v)
|
||||
}
|
||||
return fmt.Sprintf(`[[inputs.nginx]]
|
||||
# An array of Nginx stub_status URI to gather stats.
|
||||
urls = [%s]
|
||||
`, strings.Join(s, ", "))
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package inputs
|
||||
|
||||
// Processes is based on telegraf Processes.
|
||||
type Processes struct{}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (p *Processes) TOML() string {
|
||||
return `[[inputs.processes]]
|
||||
`
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package inputs
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Procstat is based on telegraf procstat input plugin.
|
||||
type Procstat struct {
|
||||
Exe string `json:"exe,omitempty"`
|
||||
}
|
||||
|
||||
// TOML encodes to toml string.
|
||||
func (p *Procstat) TOML() string {
|
||||
return fmt.Sprintf(`[[inputs.procstat]]
|
||||
## executable name (ie, pgrep <exe>)
|
||||
# exe = "%s"
|
||||
`, p.Exe)
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package inputs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Prometheus is based on telegraf Prometheus plugin.
|
||||
type Prometheus struct {
|
||||
URLs []string `json:"urls,omitempty"`
|
||||
}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (p *Prometheus) TOML() string {
|
||||
s := make([]string, len(p.URLs))
|
||||
for k, v := range s {
|
||||
s[k] = strconv.Quote(v)
|
||||
}
|
||||
return fmt.Sprintf(`[[inputs.prometheus]]
|
||||
## An array of urls to scrape metrics from.
|
||||
urls = [%s]
|
||||
`, strings.Join(s, ", "))
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package inputs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Redis is based on telegraf Redis plugin.
|
||||
type Redis struct {
|
||||
Servers []string `json:"servers"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (r *Redis) TOML() string {
|
||||
s := make([]string, len(r.Servers))
|
||||
for k, v := range s {
|
||||
s[k] = strconv.Quote(v)
|
||||
}
|
||||
return fmt.Sprintf(`[[inputs.redis]]
|
||||
## specify servers via a url matching:
|
||||
## [protocol://][:password]@address[:port]
|
||||
## e.g.
|
||||
## tcp://localhost:6379
|
||||
## tcp://:password@192.168.99.100
|
||||
## unix:///var/run/redis.sock
|
||||
##
|
||||
## If no servers are specified, then localhost is used as the host.
|
||||
## If no port is specified, 6379 is used
|
||||
servers = [%s]
|
||||
|
||||
## specify server password
|
||||
# password = "%s"
|
||||
`, strings.Join(s, ", "), r.Password)
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package inputs
|
||||
|
||||
// SwapStats is based on telegraf SwapStats.
|
||||
type SwapStats struct{}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (c *SwapStats) TOML() string {
|
||||
return `[[inputs.swap]]
|
||||
`
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package inputs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Syslog is based on telegraf Syslog plugin.
|
||||
type Syslog struct {
|
||||
Address string `json:"server"`
|
||||
}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (s *Syslog) TOML() string {
|
||||
return fmt.Sprintf(`[[inputs.syslog]]
|
||||
## Specify an ip or hostname with port - eg., tcp://localhost:6514, tcp://10.0.0.1:6514
|
||||
## Protocol, address and port to host the syslog receiver.
|
||||
## If no host is specified, then localhost is used.
|
||||
## If no port is specified, 6514 is used (RFC5425#section-4.1).
|
||||
server = "%s"
|
||||
`, s.Address)
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package inputs
|
||||
|
||||
// SystemStats is based on telegraf SystemStats.
|
||||
type SystemStats struct{}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (s *SystemStats) TOML() string {
|
||||
return `[[inputs.system]]
|
||||
`
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package inputs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Tail is based on telegraf Tail plugin.
|
||||
type Tail struct {
|
||||
Files []string `json:"files"`
|
||||
}
|
||||
|
||||
// TOML encodes to toml string
|
||||
func (t *Tail) TOML() string {
|
||||
s := make([]string, len(t.Files))
|
||||
for k, v := range s {
|
||||
s[k] = strconv.Quote(v)
|
||||
}
|
||||
return fmt.Sprintf(`[[inputs.tail]]
|
||||
## 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]
|
||||
`, strings.Join(s, ", "))
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package outputs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// File is based on telegraf file output plugin.
|
||||
type File struct {
|
||||
Files []FileConfig `json:"files"`
|
||||
}
|
||||
|
||||
// FileConfig is the config settings of outpu file plugin.
|
||||
type FileConfig struct {
|
||||
Typ string `json:"type"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
// TOML encodes to toml string.
|
||||
func (f *File) TOML() string {
|
||||
s := make([]string, len(f.Files))
|
||||
for k, v := range f.Files {
|
||||
if v.Typ == "stdout" {
|
||||
s[k] = strconv.Quote(v.Typ)
|
||||
continue
|
||||
}
|
||||
s[k] = strconv.Quote(v.Path)
|
||||
}
|
||||
return fmt.Sprintf(`[[outputs.file]]
|
||||
## Files to write to, "stdout" is a specially handled file.
|
||||
files = [%s]
|
||||
`, strings.Join(s, ", "))
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package outputs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// InfluxDBV2 is based on telegraf influxdb_v2 output plugin.
|
||||
type InfluxDBV2 struct {
|
||||
URLs []string `toml:"urls"`
|
||||
Token string `toml:"token"`
|
||||
Organization string `toml:"organization"`
|
||||
Bucket string `toml:"bucket"`
|
||||
}
|
||||
|
||||
// TOML encodes to toml string.
|
||||
func (i *InfluxDBV2) TOML() string {
|
||||
s := make([]string, len(i.URLs))
|
||||
for k, v := range i.URLs {
|
||||
s[k] = strconv.Quote(v)
|
||||
}
|
||||
return fmt.Sprintf(`[[outputs.influxdb_v2]]
|
||||
## The URLs of the InfluxDB cluster nodes.
|
||||
##
|
||||
## Multiple URLs can be specified for a single cluster, only ONE of the
|
||||
## urls will be written to each interval.
|
||||
## urls exp: http://127.0.0.1:9999
|
||||
urls = [%s]
|
||||
|
||||
## Token for authentication.
|
||||
token = "%s"
|
||||
|
||||
## Organization is the name of the organization you wish to write to; must exist.
|
||||
organization = "%s"
|
||||
|
||||
## Destination bucket to write into.
|
||||
bucket = "%s"
|
||||
`, strings.Join(s, ", "), i.Token, i.Organization, i.Bucket)
|
||||
}
|
Loading…
Reference in New Issue