本文整理匯總了Golang中github.com/elastic/beats/metricbeat/mb.BaseMetricSet.Module方法的典型用法代碼示例。如果您正苦於以下問題:Golang BaseMetricSet.Module方法的具體用法?Golang BaseMetricSet.Module怎麽用?Golang BaseMetricSet.Module使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/elastic/beats/metricbeat/mb.BaseMetricSet
的用法示例。
在下文中一共展示了BaseMetricSet.Module方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: New
// New creates and returns a new MetricSet instance.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// Unpack additional configuration options.
config := struct {
Hosts []string `config:"hosts" validate:"nonzero,required"`
Username string `config:"username"`
Password string `config:"password"`
}{
Username: "",
Password: "",
}
err := base.Module().UnpackConfig(&config)
if err != nil {
return nil, err
}
// Create and validate the data source name.
dsn, err := mysql.CreateDSN(base.Host(), config.Username, config.Password, base.Module().Config().Timeout)
if err != nil {
return nil, err
}
return &MetricSet{
BaseMetricSet: base,
dsn: dsn,
}, nil
}
示例2: New
// New create a new instance of the MetricSet
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
config := struct {
Hosts []string `config:"hosts" validate:"nonzero,required"`
Username string `config:"username"`
Password string `config:"password"`
}{
Username: "",
Password: "",
}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
url, err := postgresql.ParseURL(base.Host(), config.Username, config.Password,
base.Module().Config().Timeout)
if err != nil {
return nil, err
}
return &MetricSet{
BaseMetricSet: base,
connectionString: url,
}, nil
}
示例3: New
// New creates new instance of MetricSet
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// Additional configuration options
config := struct {
ServerStatusPath string `config:"server_status_path"`
}{
ServerStatusPath: defaultPath,
}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
u, err := getURL(config.ServerStatusPath, base.Host())
if err != nil {
return nil, err
}
debugf("nginx-stubstatus URL=%s", u)
return &MetricSet{
BaseMetricSet: base,
url: u.String(),
client: &http.Client{Timeout: base.Module().Config().Timeout},
requests: 0,
}, nil
}
示例4: New
// New creates new instance of MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// Additional configuration options
config := struct {
ServerStatusPath string `config:"server_status_path"`
Username string `config:"username"`
Password string `config:"password"`
}{
ServerStatusPath: defaultPath,
Username: "",
Password: "",
}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
u, err := getURL(config.Username, config.Password, config.ServerStatusPath, base.Host())
if err != nil {
return nil, err
}
debugf("apache-status URL=%s", redactPassword(*u))
return &MetricSet{
BaseMetricSet: base,
url: u.String(),
client: &http.Client{Timeout: base.Module().Config().Timeout},
}, nil
}
示例5: New
// New create a new instance of the MetricSet
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
config := struct{}{}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
return &MetricSet{
BaseMetricSet: base,
}, nil
}
示例6: New
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
dialInfo, err := mgo.ParseURL(base.HostData().URI)
if err != nil {
return nil, err
}
dialInfo.Timeout = base.Module().Config().Timeout
return &MetricSet{
BaseMetricSet: base,
dialInfo: dialInfo,
}, nil
}
示例7: New
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
config := struct {
Hosts []string `config:"hosts" validate:"nonzero,required"`
}{}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
return &MetricSet{
BaseMetricSet: base,
}, nil
}
示例8: New
// New create a new instance of the MetricSet
// Part of new is also setting up the configuration by processing additional
// configuration entries if needed.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("EXPERIMENTAL: The couchbase cluster metricset is experimental")
config := struct{}{}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
return &MetricSet{
BaseMetricSet: base,
client: &http.Client{Timeout: base.Module().Config().Timeout},
}, nil
}
示例9: New
// New creates new instance of MetricSet
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// Unpack additional configuration options.
config := struct {
Network string `config:"network"`
MaxConn int `config:"maxconn" validate:"min=1"`
Password string `config:"password"`
}{
Network: "tcp",
MaxConn: 10,
Password: "",
}
err := base.Module().UnpackConfig(&config)
if err != nil {
return nil, err
}
redisPools := make(map[string]*rd.Pool, len(base.Module().Config().Hosts))
for _, host := range base.Module().Config().Hosts {
redisPool := createPool(host, config.Password, config.Network,
config.MaxConn, base.Module().Config().Timeout)
redisPools[host] = redisPool
}
return &MetricSet{
BaseMetricSet: base,
redisPools: redisPools,
}, nil
}
示例10: New
// New create a new instance of the docker info MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("EXPERIMENTAL: The docker info metricset is experimental")
config := docker.Config{}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
client, err := docker.NewDockerClient(base.HostData().URI, config)
if err != nil {
return nil, err
}
return &MetricSet{
BaseMetricSet: base,
dockerClient: client,
}, nil
}
示例11: NewMetricSet
func NewMetricSet(base mb.BaseMetricSet) (mb.MetricSet, error) {
// Unpack additional configuration options.
config := struct {
Username string `config:"username"`
Password string `config:"password"`
}{
Username: "",
Password: "",
}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
return &MetricSet{
BaseMetricSet: base,
username: config.Username,
password: config.Password,
}, nil
}
示例12: New
// New create a new instance of the container MetricSet
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("EXPERIMENTAL: The container metricset is experimental")
config := docker.GetDefaultConf()
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
client, err := docker.NewDockerClient(&config)
if err != nil {
return nil, err
}
return &MetricSet{
BaseMetricSet: base,
dockerClient: client,
}, nil
}
示例13: New
// New is a mb.MetricSetFactory that returns a cpu.MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
config := struct {
CpuTicks bool `config:"cpu_ticks"` // export CPU usage in ticks
}{
CpuTicks: false,
}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
return &MetricSet{
BaseMetricSet: base,
cpu: &CPU{
CpuTicks: config.CpuTicks,
},
}, nil
}
示例14: New
// New creates and returns a new MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
config := struct {
Procs []string `config:"processes"` // collect all processes by default
Cgroups bool `config:"cgroups"`
}{
Procs: []string{".*"},
Cgroups: false,
}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
m := &MetricSet{
BaseMetricSet: base,
stats: &ProcStats{
ProcStats: true,
Procs: config.Procs,
},
}
err := m.stats.InitProcStats()
if err != nil {
return nil, err
}
if runtime.GOOS == "linux" {
systemModule, ok := base.Module().(*system.Module)
if !ok {
return nil, fmt.Errorf("unexpected module type")
}
if config.Cgroups {
logp.Warn("EXPERIMENTAL: Cgroup is enabled for the system.process MetricSet.")
m.cgroup, err = cgroup.NewReader(systemModule.HostFS, true)
if err != nil {
return nil, errors.Wrap(err, "error initializing cgroup reader")
}
}
}
return m, nil
}
示例15: New
// New creates a new instance of the docker network MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("EXPERIMENTAL: The docker network metricset is experimental")
config := docker.Config{}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
client, err := docker.NewDockerClient(base.HostData().URI, config)
if err != nil {
return nil, err
}
return &MetricSet{
BaseMetricSet: base,
dockerClient: client,
netService: &NetService{
NetworkStatPerContainer: make(map[string]map[string]NetRaw),
},
}, nil
}