influxdb/gather
Dane Strandboge a7f3b67092
chore: clean up protobuf loose ends (#22823)
- Remove `gogo/protobuf` and `golang/protobuf` deps
- Fix mistake in `CONTRIBUTING.md`
- Use Prometheus `MetricType` type over our own copy-paste version
2021-11-05 10:30:30 -05: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 chore: clean up protobuf loose ends (#22823) 2021-11-05 10:30:30 -05:00
metrics_test.go chore: clean up protobuf loose ends (#22823) 2021-11-05 10:30:30 -05:00
prometheus.go chore: clean up protobuf loose ends (#22823) 2021-11-05 10:30:30 -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 chore: clean up protobuf loose ends (#22823) 2021-11-05 10:30:30 -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 chore: clean up protobuf loose ends (#22823) 2021-11-05 10:30:30 -05: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
}