// Fetch fetches info stats from the haproxy service. func (m *MetricSet) Fetch() (common.MapStr, error) { // haproxy doesn't accept a username or password so ignore them if they // are in the URL. hapc, err := haproxy.NewHaproxyClient(m.HostData().SanitizedURI) if err != nil { return nil, errors.Wrap(err, "failed creating haproxy client") } res, err := hapc.GetInfo() if err != nil { return nil, errors.Wrap(err, "failed fetching haproxy info") } return eventMapping(res) }
// Fetch methods implements the data gathering and data conversion to the right format // It returns the event which is then forward to the output. In case of an error, a // descriptive error must be returned. func (m *MetricSet) Fetch() ([]common.MapStr, error) { hapc, err := haproxy.NewHaproxyClient(m.statsAddr) if err != nil { return nil, fmt.Errorf("HAProxy Client error: %s", err) } res, err := hapc.GetStat() if err != nil { return nil, fmt.Errorf("HAProxy Client error fetching %s: %s", statsMethod, err) } m.counter++ return eventMapping(res), nil }