项目作者: metrics-pli

项目描述 :
Exports collected metrics to Google Big Query
高级语言: TypeScript
项目地址: git://github.com/metrics-pli/bigquery-export.git
创建时间: 2018-05-14T15:35:28Z
项目社区:https://github.com/metrics-pli/bigquery-export

开源协议:MIT License

下载


bigquery-export

Exports collected metrics to Google Big Query
Can be hooked up very easily to a metricsPli instance.

You can debug logs via DEBUG=mpli:bqexport.
The bigquery config fields accepts all parameters that you can pass to
@google-cloud/bigquery.

  1. import MetricsPli, { ConfigInterface, TestInterface } from "@metrics-pli/core";
  2. import Exporter from "@metrics-pli/exporter-bigquery";
  3. const keyFilename = "/Users/jondoe/Documents/jons-plat-123.json";
  4. const exporterConfig = {
  5. bigquery: {
  6. projectId: "123123123",
  7. keyFilename,
  8. },
  9. dataset: "my_metrics_dataset",
  10. table: "my_metrics_table",
  11. batchSize: 75,
  12. batchTimeout: 60 * 1000,
  13. };
  14. const tests: TestInterface[] = [{
  15. name: "Homepage",
  16. url: "https://google.com/",
  17. }];
  18. const config: ConfigInterface = {};
  19. (async () => {
  20. const metricsPli = new MetricsPli(tests, config);
  21. const bqExporter = new Exporter(exporterConfig);
  22. await bqExporter.init();
  23. bqExporter.registerWith(metricsPli);
  24. // will also emit exporter error events
  25. metricsPli.on("error", console.error);
  26. metricsPli.on("info", console.info);
  27. await metricsPli.run();
  28. await bqExporter.close();
  29. })();