No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cloudmonitoring.js 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.queryTimeSeries = exports.ValueType = exports.Reducer = exports.MetricKind = exports.Aligner = exports.TimeSeriesView = exports.CLOUD_MONITORING_VERSION = void 0;
  4. const api_1 = require("../api");
  5. const apiv2_1 = require("../apiv2");
  6. const error_1 = require("../error");
  7. exports.CLOUD_MONITORING_VERSION = "v3";
  8. var TimeSeriesView;
  9. (function (TimeSeriesView) {
  10. TimeSeriesView["FULL"] = "FULL";
  11. TimeSeriesView["HEADERS"] = "HEADERS";
  12. })(TimeSeriesView = exports.TimeSeriesView || (exports.TimeSeriesView = {}));
  13. var Aligner;
  14. (function (Aligner) {
  15. Aligner["ALIGN_NONE"] = "ALIGN_NONE";
  16. Aligner["ALIGN_DELTA"] = "ALIGN_DELTA";
  17. Aligner["ALIGN_RATE"] = "ALIGN_RATE";
  18. Aligner["ALIGN_INTERPOLATE"] = "ALIGN_INTERPOLATE";
  19. Aligner["ALIGN_NEXT_OLDER"] = "ALIGN_NEXT_OLDER";
  20. Aligner["ALIGN_MIN"] = "ALIGN_MIN";
  21. Aligner["ALIGN_MAX"] = "ALIGN_MAX";
  22. Aligner["ALIGN_MEAN"] = "ALIGN_MEAN";
  23. Aligner["ALIGN_COUNT"] = "ALIGN_COUNT";
  24. Aligner["ALIGN_SUM"] = "ALIGN_SUM";
  25. Aligner["ALIGN_STDDEV"] = "ALIGN_STDDEV";
  26. Aligner["ALIGN_COUNT_TRUE"] = "ALIGN_COUNT_TRUE";
  27. Aligner["ALIGN_FRACTION_TRUE"] = "ALIGN_FRACTION_TRUE";
  28. })(Aligner = exports.Aligner || (exports.Aligner = {}));
  29. var MetricKind;
  30. (function (MetricKind) {
  31. MetricKind["METRIC_KIND_UNSPECIFIED"] = "METRIC_KIND_UNSPECIFIED";
  32. MetricKind["GAUGE"] = "GAUGE";
  33. MetricKind["DELTA"] = "DELTA";
  34. MetricKind["CUMULATIVE"] = "CUMULATIVE";
  35. })(MetricKind = exports.MetricKind || (exports.MetricKind = {}));
  36. var Reducer;
  37. (function (Reducer) {
  38. Reducer["REDUCE_NONE"] = "REDUCE_NONE";
  39. Reducer["REDUCE_MEAN"] = "REDUCE_MEAN";
  40. Reducer["REDUCE_MIN"] = "REDUCE_MIN";
  41. Reducer["REDUCE_MAX"] = "REDUCE_MAX";
  42. Reducer["REDUCE_SUM"] = "REDUCE_SUM";
  43. Reducer["REDUCE_STDDEV"] = "REDUCE_STDDEV";
  44. Reducer["REDUCE_COUNT"] = "REDUCE_COUNT";
  45. Reducer["REDUCE_COUNT_TRUE"] = "REDUCE_COUNT_TRUE";
  46. Reducer["REDUCE_FRACTION_TRUE"] = "REDUCE_FRACTION_TRUE";
  47. Reducer["REDUCE_PERCENTILE_99"] = "REDUCE_PERCENTILE_99";
  48. Reducer["REDUCE_PERCENTILE_95"] = "REDUCE_PERCENTILE_95";
  49. Reducer["REDUCE_PERCENTILE_50"] = "REDUCE_PERCENTILE_50";
  50. Reducer["REDUCE_PERCENTILE_05"] = "REDUCE_PERCENTILE_05";
  51. })(Reducer = exports.Reducer || (exports.Reducer = {}));
  52. var ValueType;
  53. (function (ValueType) {
  54. ValueType["VALUE_TYPE_UNSPECIFIED"] = "VALUE_TYPE_UNSPECIFIED";
  55. ValueType["BOOL"] = "BOOL";
  56. ValueType["INT64"] = "INT64";
  57. ValueType["DOUBLE"] = "DOUBLE";
  58. ValueType["STRING"] = "STRING";
  59. })(ValueType = exports.ValueType || (exports.ValueType = {}));
  60. async function queryTimeSeries(query, projectNumber) {
  61. const client = new apiv2_1.Client({
  62. urlPrefix: api_1.cloudMonitoringOrigin,
  63. apiVersion: exports.CLOUD_MONITORING_VERSION,
  64. });
  65. try {
  66. const res = await client.get(`/projects/${projectNumber}/timeSeries/`, {
  67. queryParams: query,
  68. });
  69. return res.body.timeSeries;
  70. }
  71. catch (err) {
  72. throw new error_1.FirebaseError(`Failed to get extension usage: ${err}`, {
  73. status: err.status,
  74. });
  75. }
  76. }
  77. exports.queryTimeSeries = queryTimeSeries;