influxdb/gather
Jacob Marble f56c42794b
chore(tracing): Cleanup (#13296)
* chore(tracing): Cleanup

* broken test

* fix unused var

* fix test
2019-04-10 19:28:21 -07:00
..
README.md add(gather): add writer interface 2019-01-11 13:09:18 -05:00
handler.go add(gather): add writer interface 2019-01-11 13:09:18 -05:00
metrics.go fix(scraper): remove enriched type label 2019-01-17 10:22:22 -06:00
metrics_test.go fix(scraper): remove enriched type label 2019-01-17 10:22:22 -06:00
prometheus.go add(gather): add writer interface 2019-01-11 13:09:18 -05:00
recorder.go Revert "Merge point parse & explode." 2019-03-02 06:23:04 -07:00
scheduler.go chore(tracing): Cleanup (#13296) 2019-04-10 19:28:21 -07:00
scheduler_test.go add(gather): add writer interface 2019-01-11 13:09:18 -05:00
scraper.go add(gather): add writer interface 2019-01-11 13:09:18 -05:00
scraper_test.go feat(influxdb): add urm for scraper 2019-01-23 08:46:32 -08: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
}