Skip to content

Commit

Permalink
Merge pull request #143 from hmuthusamy/feature/adot-addon-bug-fix-sy…
Browse files Browse the repository at this point in the history
…ncup

ADOT addition and bugfix in addition to sync ts files
  • Loading branch information
elamaran11 authored Jan 26, 2024
2 parents 043ab04 + 82c2862 commit 3a9b3f4
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 11 deletions.
55 changes: 51 additions & 4 deletions lib/existing-eks-opensource-observability-pattern/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { ObservabilityBuilder } from '@aws-quickstart/eks-blueprints';
import * as cdk from "aws-cdk-lib";
import * as eks from 'aws-cdk-lib/aws-eks';
import * as fs from 'fs';
import { IstioIngressGatewayHelmAddon } from '../single-new-eks-opensource-observability-pattern/istio/istioIngressGatewayAddon';
import { IstioCniHelmAddon } from '../single-new-eks-opensource-observability-pattern/istio/istiocniAddon';

export default class ExistingEksOpenSourceobservabilityPattern {
async buildAsync(scope: cdk.App, id: string) {
Expand Down Expand Up @@ -62,8 +64,26 @@ export default class ExistingEksOpenSourceobservabilityPattern {
let doc = utils.readYamlDocument(__dirname + '/../common/resources/otel-collector-config.yml');
doc = utils.changeTextBetweenTokens(
doc,
"{{ if enableAPIserverJob }}",
"{{ end }}",
"{{ start enableJavaMonJob }}",
"{{ stop enableJavaMonJob }}",
jsonStringnew.context["java.pattern.enabled"]
);
doc = utils.changeTextBetweenTokens(
doc,
"{{ start enableNginxMonJob }}",
"{{ stop enableNginxMonJob }}",
jsonStringnew.context["nginx.pattern.enabled"]
);
doc = utils.changeTextBetweenTokens(
doc,
"{{ start enableIstioMonJob }}",
"{{ stop enableIstioMonJob }}",
jsonStringnew.context["istio.pattern.enabled"]
);
doc = utils.changeTextBetweenTokens(
doc,
"{{ start enableAPIserverJob }}",
"{{ stop enableAPIserverJob }}",
jsonStringnew.context["apiserver.pattern.enabled"]
);
doc = utils.changeTextBetweenTokens(
Expand All @@ -81,6 +101,12 @@ export default class ExistingEksOpenSourceobservabilityPattern {
console.log(doc);
fs.writeFileSync(__dirname + '/../common/resources/otel-collector-config-new.yml', doc);

if (utils.valueFromContext(scope, "adotcollectormetrics.pattern.enabled", false)) {
ampAddOnProps.openTelemetryCollector = {
manifestPath: __dirname + '/../common/resources/otel-collector-config-new.yml'
};
}

if (utils.valueFromContext(scope, "java.pattern.enabled", false)) {
ampAddOnProps.openTelemetryCollector = {
manifestPath: __dirname + '/../common/resources/otel-collector-config-new.yml',
Expand All @@ -106,15 +132,25 @@ export default class ExistingEksOpenSourceobservabilityPattern {
ampAddOnProps.openTelemetryCollector = {
manifestPath: __dirname + '/../common/resources/otel-collector-config-new.yml',
manifestParameterMap: {
javaScrapeSampleLimit: 1000,
javaPrometheusMetricsEndpoint: "/metrics"
nginxScrapeSampleLimit: 1000,
nginxPrometheusMetricsEndpoint: "/metrics"
}
};
ampAddOnProps.ampRules?.ruleFilePaths.push(
__dirname + '/../common/resources/amp-config/nginx/alerting-rules.yml'
);
}

if (utils.valueFromContext(scope, "istio.pattern.enabled", false)) {
ampAddOnProps.openTelemetryCollector = {
manifestPath: __dirname + '/../common/resources/otel-collector-config-new.yml'
};
ampAddOnProps.ampRules?.ruleFilePaths.push(
__dirname + '/../common/resources/amp-config/istio/alerting-rules.yml',
__dirname + '/../common/resources/amp-config/istio/recording-rules.yml'
);
}

Reflect.defineMetadata("ordered", true, blueprints.addons.GrafanaOperatorAddon);
const addOns: Array<blueprints.ClusterAddOn> = [
new blueprints.addons.CloudWatchLogsAddon({
Expand All @@ -126,6 +162,17 @@ export default class ExistingEksOpenSourceobservabilityPattern {
new GrafanaOperatorSecretAddon(),
];

if (utils.valueFromContext(scope, "istio.pattern.enabled", false)) {
addOns.push(new blueprints.addons.IstioBaseAddOn({
version: "1.18.2"
}));
addOns.push(new blueprints.addons.IstioControlPlaneAddOn({
version: "1.18.2"
}));
addOns.push(new IstioIngressGatewayHelmAddon);
addOns.push(new IstioCniHelmAddon);
}

ObservabilityBuilder.builder()
.account(account)
.region(region)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,21 @@ export default class SingleNewEksFargateOpenSourceObservabilityConstruct {
let doc = utils.readYamlDocument(__dirname + '/../common/resources/otel-collector-config.yml');
doc = utils.changeTextBetweenTokens(
doc,
"{{ if enableAPIserverJob }}",
"{{ end }}",
true
"{{ start enableJavaMonJob }}",
"{{ stop enableJavaMonJob }}",
jsonStringnew.context["java.pattern.enabled"]
);
doc = utils.changeTextBetweenTokens(
doc,
"{{ start enableNginxMonJob }}",
"{{ stop enableNginxMonJob }}",
jsonStringnew.context["nginx.pattern.enabled"]
);
doc = utils.changeTextBetweenTokens(
doc,
"{{ start enableAPIserverJob }}",
"{{ stop enableAPIserverJob }}",
jsonStringnew.context["apiserver.pattern.enabled"]
);
doc = utils.changeTextBetweenTokens(
doc,
Expand All @@ -54,11 +66,16 @@ export default class SingleNewEksFargateOpenSourceObservabilityConstruct {
doc,
"{{ start enableAdotMetricsCollectionTelemetry }}",
"{{ stop enableAdotMetricsCollectionTelemetry }}",
true
jsonStringnew.context["adotcollectormetrics.pattern.enabled"]
);
console.log(doc);
fs.writeFileSync(__dirname + '/../common/resources/otel-collector-config-new.yml', doc);

if (utils.valueFromContext(scope, "adotcollectormetrics.pattern.enabled", false)) {
ampAddOnProps.openTelemetryCollector = {
manifestPath: __dirname + '/../common/resources/otel-collector-config-new.yml'
};
}

if (utils.valueFromContext(scope, "java.pattern.enabled", false)) {
ampAddOnProps.openTelemetryCollector = {
Expand All @@ -73,7 +90,7 @@ export default class SingleNewEksFargateOpenSourceObservabilityConstruct {
__dirname + '/../common/resources/amp-config/java/recording-rules.yml'
);
}

if (utils.valueFromContext(scope, "apiserver.pattern.enabled", false)) {
ampAddOnProps.enableAPIServerJob = true,
ampAddOnProps.ampRules?.ruleFilePaths.push(
Expand All @@ -85,8 +102,8 @@ export default class SingleNewEksFargateOpenSourceObservabilityConstruct {
ampAddOnProps.openTelemetryCollector = {
manifestPath: __dirname + '/../common/resources/otel-collector-config-new.yml',
manifestParameterMap: {
javaScrapeSampleLimit: 1000,
javaPrometheusMetricsEndpoint: "/metrics"
nginxScrapeSampleLimit: 1000,
nginxPrometheusMetricsEndpoint: "/metrics"
}
};
ampAddOnProps.ampRules?.ruleFilePaths.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ export default class SingleNewEksGravitonOpenSourceObservabilityPattern {
console.log(doc);
fs.writeFileSync(__dirname + '/../common/resources/otel-collector-config-new.yml', doc);

if (utils.valueFromContext(scope, "adotcollectormetrics.pattern.enabled", false)) {
ampAddOnProps.openTelemetryCollector = {
manifestPath: __dirname + '/../common/resources/otel-collector-config-new.yml'
};
}

if (utils.valueFromContext(scope, "java.pattern.enabled", false)) {
ampAddOnProps.openTelemetryCollector = {
manifestPath: __dirname + '/../common/resources/otel-collector-config-new.yml',
Expand Down
6 changes: 6 additions & 0 deletions lib/single-new-eks-opensource-observability-pattern/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export default class SingleNewEksOpenSourceobservabilityPattern {
console.log(doc);
fs.writeFileSync(__dirname + '/../common/resources/otel-collector-config-new.yml', doc);

if (utils.valueFromContext(scope, "adotcollectormetrics.pattern.enabled", false)) {
ampAddOnProps.openTelemetryCollector = {
manifestPath: __dirname + '/../common/resources/otel-collector-config-new.yml'
};
}

if (utils.valueFromContext(scope, "java.pattern.enabled", false)) {
ampAddOnProps.openTelemetryCollector = {
manifestPath: __dirname + '/../common/resources/otel-collector-config-new.yml',
Expand Down

0 comments on commit 3a9b3f4

Please sign in to comment.