UNPKG

@cloud-carbon-footprint/gcp

Version:

The core logic to get cloud usage data and estimate energy and carbon emissions from Google Cloud Platform.

36 lines (35 loc) 1.41 kB
import { v3 } from '@google-cloud/monitoring'; import { google } from '@google-cloud/monitoring/build/protos/protos'; import Aligner = google.monitoring.v3.Aggregation.Aligner; import Reducer = google.monitoring.v3.Aggregation.Reducer; import { Logger } from '@cloud-carbon-footprint/common'; import { ServiceWithCPUUtilization, ComputeUsage, Cost } from '@cloud-carbon-footprint/core'; export default class ComputeEngine extends ServiceWithCPUUtilization { private client; serviceName: string; computeEngineLogger: Logger; constructor(client: v3.MetricServiceClient); getUsage(start: Date, end: Date, region: string): Promise<ComputeUsage[]>; private getCpuUtilization; buildTimeSeriesRequest(startDate: Date, endDate: Date, projectName: string, metricType: string, crossSeriesReducer: Reducer, region: string): { name: string; filter: string; aggregation: { alignmentPeriod: { seconds: number; }; perSeriesAligner: Aligner; crossSeriesReducer: Reducer; }; view: google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView; interval: { startTime: { seconds: number; }; endTime: { seconds: number; }; }; }; getCosts(start: Date, end: Date, region: string): Promise<Cost[]>; }