influxdb/gather
Daniel Moran 00afd95cb7
refactor: automated move of errors and id from root to kit (#21101)
Co-authored-by: Sam Arnold <sarnold@influxdata.com>
2021-03-30 14:10:02 -04:00
..
README.md chore: Remove several instances of WithLogger (#15996) 2019-12-04 15:10:23 -08:00
handler.go fix: correct various typos (#19987) 2020-11-11 13:54:21 -05:00
metrics.go refactor: automated move of errors and id from root to kit (#21101) 2021-03-30 14:10:02 -04:00
metrics_test.go fix: correct various typos (#19987) 2020-11-11 13:54:21 -05:00
prometheus.go fix: Allow self signed certificates to ScraperTarget (#20047) 2020-11-17 13:35:41 -05:00
recorder.go fix: Ensure orgID and bucketID are passed to WritePoints API 2020-10-08 15:43:37 -07:00
scheduler.go fix: Allow self signed certificates to ScraperTarget (#20047) 2020-11-17 13:35:41 -05:00
scheduler_test.go test: replace influxlogger with zaptest logger (#20589) 2021-02-11 10:12:39 -05:00
scraper.go refactor: rewrite imports to include the /v2 suffix for version 2 2020-04-03 12:39:20 -05:00
scraper_test.go refactor: automated move of errors and id from root to kit (#21101) 2021-03-30 14:10:02 -04:00

README.md

How to use this package

Make sure nats is running. Both publisher and subscriber are open

// NATS streaming server
m.natsServer = nats.NewServer(nats.Config{FilestoreDir: m.natsPath})
if err := m.natsServer.Open(); err != nil {
    m.logger.Error("Failed to start nats streaming server", zap.Error(err))
    return err
}

publisher := nats.NewAsyncPublisher("nats-publisher")
if err := publisher.Open(); err != nil {
    m.logger.Error("Failed to connect to streaming server", zap.Error(err))
    return err
}

subscriber := nats.NewQueueSubscriber("nats-subscriber")
if err := subscriber.Open(); err != nil {
    m.logger.Error("Failed to connect to streaming server", zap.Error(err))
    return err
}

Make sure the scraperTargetStorageService is accessible

scraperTargetSvc influxdb.ScraperTargetStoreService = m.boltClient

Setup recorder, Make sure subscriber subscribes use the correct recorder with the correct write service

recorder := gather.PlatformWriter{
    Timeout: time.Millisecond * 30,
    Writer: writer,
}
subscriber.Subscribe(MetricsSubject, "", &RecorderHandler{
    Logger:   logger,
    Recorder: recorder,
})

Start the scheduler

scraperScheduler, err := gather.NewScheduler(10, m.logger, scraperTargetSvc, publisher, subscriber, 0, 0)
if err != nil {
    m.logger.Error("Failed to create scraper subscriber", zap.Error(err))
    return err
}