import { YAxisProps } from "monocdk/aws-...

21/11/2021  •  24 views
 
import { YAxisProps } from "monocdk/aws-cloudwatch";

export enum statType {
AVERAGE = 'Average',
P99 = 'p99',
SUM = 'Sum'
}

export type WidgetProperties = {
title?: string;
stat?: statType;
yAxis?: { left: YAxisProps };
region?: string;
period?: number;
view?: string;
stacked?: boolean;
}

type Widget = {
height: number;
width: number;
type: string;
properties: WidgetProperties;
}

export const metaData = {
height: 6,
width: 6,
label: "",
max: 300,
min: 0,
showUnits: false,
type: "metric",
period: 300,
view: "timeSeries",
stacked: false,
}

export enum Region {
US_AMAZON = 'USAmazon'
}

export enum Stages {
PROD = 'Prod',
GAMMA = 'Gamma',
}

export enum ServiceTypes {
AWS_ANNIVERSARY_BILLING_SERVICE = 'AWSAnniversaryBillingService',
AWS_ANNIVERSARY_BILLING_SERVICE_ORCHESTRATION_RUNNER_WORKER = 'AWSAnniversaryBillingServiceOrchestrationRunnerWorker'
}

export enum MetricTypes {
SERVICE = 'Service',
DATASET = 'DataSet',
MARKET_PLACE = 'Marketplace',
HOST_GROUP = 'HostGroup',
HOST = 'Host',
SERVICE_NAME = 'ServiceName',
METHOD_NAME = 'MethodName',
CLIENT = 'Client',
METRIC_CLASS = 'MetricClass',
INSTANCE = 'Instance',
QUEUENAME = 'QueueName'
}

export enum MetricValues {
ALL = 'ALL',
NONE = 'NONE',
RUN_ORCHESTRATION = 'runOrchestration',
INTEGRATION_TEST_QUEUE = 'integration_test_queue'
}

export function createWidgetsFromJson(stageProps: any, json: Array<any>): Widget[] {
var widgetArray: Widget[] = [];

for (var i = 0; i < json.length; i++) {
let widget = {} as Widget;

var widgetJson = json[i];
widget.properties = widgetJson.properties;

widget.properties.region = stageProps.region;

widget.properties.period = metaData.period;
widget.properties.view = metaData.view;
widget.properties.stacked = metaData.stacked;

widget.height = metaData.height;
widget.width = metaData.width;
widget.type = metaData.type;

widgetArray.push(widget);
}

return widgetArray;

}


https://paste.ac/fJPZImE