Skip to content

Commit

Permalink
[DCMAW-8782] Configure async backend api to send metrics to Dynatrace (
Browse files Browse the repository at this point in the history
…#281)

​DCMAW-8782

### What changed
Update backend-api template.yaml to allow lambda functions to send
metrics to Dynatrace.
Update test for new global environment variables

### Why did it change
We are creating Dynatrace dashboards for the async resources.

Stack successfully deployed:


![image](https://github.com/user-attachments/assets/a888e483-e434-4be4-adca-661578e46cb7)


Tests successfully run:

![image](https://github.com/user-attachments/assets/ea8da2ae-dfa8-40d7-8d1d-5ee439e5106d)


![image](https://github.com/user-attachments/assets/0962f3f2-8a27-42c2-ad10-ee0a3861e9ac)

Dynatrace gathering metrics:

![image](https://github.com/user-attachments/assets/baebd7c8-a5c8-43f1-8668-f0a15071f6a2)
  • Loading branch information
mthkbarber authored Dec 5, 2024
1 parent f3467da commit 9e397e9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
33 changes: 33 additions & 0 deletions backend-api/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ Parameters:
Default: none

Mappings:
EnvironmentConfiguration:
dev:
dynatraceSecretArn: arn:aws:secretsmanager:eu-west-2:216552277552:secret:DynatraceNonProductionVariables
build:
dynatraceSecretArn: arn:aws:secretsmanager:eu-west-2:216552277552:secret:DynatraceNonProductionVariables
staging:
dynatraceSecretArn: arn:aws:secretsmanager:eu-west-2:216552277552:secret:DynatraceNonProductionVariables
integration:
dynatraceSecretArn: arn:aws:secretsmanager:eu-west-2:216552277552:secret:DynatraceNonProductionVariables
production:
dynatraceSecretArn: arn:aws:secretsmanager:eu-west-2:216552277552:secret:DynatraceProductionVariables

PrivateApigw:
dev:
ApiBurstLimit: 10
Expand Down Expand Up @@ -210,6 +222,27 @@ Globals:
# ISSUER should be updated with DNS once available
ISSUER: mockIssuer
SESSION_TABLE_NAME: !Ref SessionsTable
AWS_LAMBDA_EXEC_WRAPPER: /opt/dynatrace
DT_CONNECTION_AUTH_TOKEN: !Sub
- '{{resolve:secretsmanager:${SecretArn}:SecretString:DT_CONNECTION_AUTH_TOKEN}}'
- SecretArn: !FindInMap [ EnvironmentConfiguration, !Ref Environment, dynatraceSecretArn ]
DT_CONNECTION_BASE_URL: !Sub
- '{{resolve:secretsmanager:${SecretArn}:SecretString:DT_CONNECTION_BASE_URL}}'
- SecretArn: !FindInMap [ EnvironmentConfiguration, !Ref Environment, dynatraceSecretArn ]
DT_CLUSTER_ID: !Sub
- '{{resolve:secretsmanager:${SecretArn}:SecretString:DT_CLUSTER_ID}}'
- SecretArn: !FindInMap [ EnvironmentConfiguration, !Ref Environment, dynatraceSecretArn ]
DT_LOG_COLLECTION_AUTH_TOKEN: !Sub
- '{{resolve:secretsmanager:${SecretArn}:SecretString:DT_LOG_COLLECTION_AUTH_TOKEN}}'
- SecretArn: !FindInMap [ EnvironmentConfiguration, !Ref Environment, dynatraceSecretArn ]
DT_TENANT: !Sub
- '{{resolve:secretsmanager:${SecretArn}:SecretString:DT_TENANT}}'
- SecretArn: !FindInMap [ EnvironmentConfiguration, !Ref Environment, dynatraceSecretArn ]
DT_OPEN_TELEMETRY_ENABLE_INTEGRATION: "true"
Layers:
- !Sub
- '{{resolve:secretsmanager:${SecretArn}:SecretString:NODEJS_LAYER}}'
- SecretArn: !FindInMap [ EnvironmentConfiguration, !Ref Environment, dynatraceSecretArn ]

Resources:

Expand Down
7 changes: 7 additions & 0 deletions backend-api/tests/infra-tests/application.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,13 @@ describe("Backend application infrastructure", () => {
"ISSUER",
"TXMA_SQS",
"SESSION_TABLE_NAME",
"AWS_LAMBDA_EXEC_WRAPPER",
"DT_CONNECTION_AUTH_TOKEN",
"DT_CONNECTION_BASE_URL",
"DT_CLUSTER_ID",
"DT_LOG_COLLECTION_AUTH_TOKEN",
"DT_TENANT",
"DT_OPEN_TELEMETRY_ENABLE_INTEGRATION",
];
const envVars =
template.toJSON().Globals.Function.Environment.Variables;
Expand Down

0 comments on commit 9e397e9

Please sign in to comment.