// 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 }
// 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 }
// 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 }
// 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 }
// 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 }
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 }
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 }
// 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 }
// 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 }
// 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 }
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 }
// 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 }
// 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 }
// 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 }
// 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 }
// 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 } hostToDSN := make(map[string]string, len(base.Module().Config().Hosts)) for _, host := range base.Module().Config().Hosts { // TODO (akroh): Apply validation to the mysql DSN format. dsn := mysql.CreateDSN(host, config.Username, config.Password) hostToDSN[host] = dsn } return &MetricSet{ BaseMetricSet: base, hostToDSN: hostToDSN, connections: map[string]*sql.DB{}, }, nil }
// 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 } metricSet := &MetricSet{ BaseMetricSet: base, URLs: make(map[string]string, len(base.Module().Config().Hosts)), } // Parse the config, create URLs, and check for errors. var errs multierror.Errors for _, host := range base.Module().Config().Hosts { u, err := getURL(config.Username, config.Password, config.ServerStatusPath, host) if err != nil { errs = append(errs, err) continue } metricSet.URLs[host] = u.String() debugf("apache-status URL=%s", redactPassword(*u)) } return metricSet, errs.Err() }
// 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 }
// 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 }
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 }
// New create a new instance of the docker diskio MetricSet func New(base mb.BaseMetricSet) (mb.MetricSet, error) { logp.Warn("EXPERIMENTAL: The diskio 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, blkioService: &BLkioService{ BlkioSTatsPerContainer: make(map[string]BlkioRaw), }, }, nil }
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 }
// 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) { config := struct { ForceCachedEntries []string `config:"force_collect"` Pid string `config:"pid"` }{ ForceCachedEntries: []string{}, Pid: "0", } if err := base.Module().UnpackConfig(&config); err != nil { return nil, err } inst := &HSPerfData{} inst.ForceCachedEntryName = make(map[string]int) for _, entry := range config.ForceCachedEntries { inst.ForceCachedEntryName[entry] = 1 } perfDataPath, err := GetHSPerfDataPath(config.Pid) if err != nil { return nil, err } prevData := make(map[string]int64) return &MetricSet{ BaseMetricSet: base, parser: inst, previousData: prevData, hsPerfDataPath: perfDataPath, isFirst: true, pid: config.Pid, }, nil }
// 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 }{ Procs: []string{".*"}, } if err := base.Module().UnpackConfig(&config); err != nil { return nil, err } m := &MetricSet{ BaseMetricSet: base, stats: &system.ProcStats{ ProcStats: true, Procs: config.Procs, }, } err := m.stats.InitProcStats() if err != nil { return nil, err } return m, nil }
// New is a mb.MetricSetFactory that returns a new MetricSet. func New(base mb.BaseMetricSet) (mb.MetricSet, error) { // Unpack additional configuration options. config := struct { Interfaces []string `config:"interfaces"` }{} err := base.Module().UnpackConfig(&config) if err != nil { return nil, err } var interfaceSet map[string]struct{} if len(config.Interfaces) > 0 { interfaceSet = make(map[string]struct{}, len(config.Interfaces)) for _, ifc := range config.Interfaces { interfaceSet[strings.ToLower(ifc)] = struct{}{} } debugf("network io stats will be included for %v", interfaceSet) } return &MetricSet{ BaseMetricSet: base, interfaces: interfaceSet, }, nil }
// 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 }
// New creates a haproxy info MetricSet. func New(base mb.BaseMetricSet) (mb.MetricSet, error) { logp.Warn("EXPERIMENTAL: The %v %v metricset is experimental", base.Module().Name(), base.Name()) return &MetricSet{BaseMetricSet: base}, nil }
// New creates new instance of MetricSet func New(base mb.BaseMetricSet) (mb.MetricSet, error) { return &MetricSet{ BaseMetricSet: base, client: &http.Client{Timeout: base.Module().Config().Timeout}, }, nil }