Example #1
0
// 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(),
	}, nil
}
Example #2
0
// 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
}
Example #3
0
// 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
}
Example #4
0
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
}
Example #5
0
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
}
Example #6
0
// 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
}
Example #7
0
// 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
}
Example #8
0
File: info.go Project: ruflin/beats
// 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
}
Example #9
0
File: cpu.go Project: ruflin/beats
// 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
}
Example #10
0
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
}
Example #11
0
// 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
}
Example #12
0
// 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
}
Example #13
0
// 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
}
Example #14
0
// 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
}
Example #15
0
// 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
}
Example #16
0
// 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
}
Example #17
0
// 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()
}
Example #18
0
// 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
}
Example #19
0
// 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
}
Example #20
0
// 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
}
Example #21
0
// 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
}
Example #22
0
// 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
}
Example #23
0
// 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
}
Example #24
0
// 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
}
Example #25
0
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
}
Example #26
0
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
}
Example #27
0
// 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
}
Example #28
0
File: info.go Project: ruflin/beats
// 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
}
Example #29
0
func NewMetricSet(base mb.BaseMetricSet) (mb.MetricSet, error) {
	fmt.Println("someapp-status url=", base.HostData().SanitizedURI)
	return &MetricSet{BaseMetricSet: base}, nil
}
Example #30
0
// 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
}