本文整理匯總了Golang中github.com/elastic/beats/metricbeat/mb.BaseMetricSet.Host方法的典型用法代碼示例。如果您正苦於以下問題:Golang BaseMetricSet.Host方法的具體用法?Golang BaseMetricSet.Host怎麽用?Golang BaseMetricSet.Host使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/elastic/beats/metricbeat/mb.BaseMetricSet
的用法示例。
在下文中一共展示了BaseMetricSet.Host方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 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
}
示例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 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
}
示例5: 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 haproxy info metricset is experimental")
return &MetricSet{
BaseMetricSet: base,
statsAddr: base.Host(),
counter: 1,
}, nil
}
示例6: 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
}
return &MetricSet{
BaseMetricSet: base,
pool: createPool(base.Host(), config.Password, config.Network,
config.MaxConn, base.Module().Config().Timeout),
}, nil
}
示例7: New
// New creates and returns a new MetricSet instance.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// Unpack additional configuration options.
config := struct {
Username string `config:"username"`
Password string `config:"password"`
}{
Username: "",
Password: "",
}
err := base.Module().UnpackConfig(&config)
if err != nil {
return nil, err
}
// TODO (akroh): Apply validation to the mysql DSN format.
dsn := mysql.CreateDSN(base.Host(), config.Username, config.Password)
return &MetricSet{
BaseMetricSet: base,
dsn: dsn,
}, nil
}
示例8: New
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("EXPERIMENTAL: The filebeat metricset is experimental")
// Additional configuration options
config := struct {
VarsPath string `config:"vars_path"`
}{
VarsPath: "/debug/vars",
}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
url := "http://" + base.Host() + config.VarsPath
return &MetricSet{
BaseMetricSet: base,
url: url,
client: &http.Client{Timeout: base.Module().Config().Timeout},
}, nil
}
示例9: New
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
config := struct {
Hosts []string `config:"hosts" validate:"nonzero,required"`
Username string `config:"username"`
Password string `config:"username"`
}{}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
info, err := mongodb.ParseURL(base.Host(), config.Username, config.Password)
if err != nil {
return nil, err
}
info.Timeout = base.Module().Config().Timeout
return &MetricSet{
BaseMetricSet: base,
dialInfo: info,
}, nil
}
示例10: New
// New create a new instance of the partition MetricSet
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
config := defaultConfig
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
tls, err := outputs.LoadTLSConfig(config.TLS)
if err != nil {
return nil, err
}
cfg := sarama.NewConfig()
cfg.Net.DialTimeout = base.Module().Config().Timeout
cfg.Net.ReadTimeout = base.Module().Config().Timeout
cfg.ClientID = config.ClientID
cfg.Metadata.Retry.Max = config.Metadata.Retries
cfg.Metadata.Retry.Backoff = config.Metadata.Backoff
if tls != nil {
cfg.Net.TLS.Enable = true
cfg.Net.TLS.Config = tls.BuildModuleConfig("")
}
if config.Username != "" {
cfg.Net.SASL.Enable = true
cfg.Net.SASL.User = config.Username
cfg.Net.SASL.Password = config.Password
}
broker := sarama.NewBroker(base.Host())
return &MetricSet{
BaseMetricSet: base,
broker: broker,
cfg: cfg,
id: noID,
topics: config.Topics,
}, nil
}