Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thick-coats-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gradientedge/cdk-utils-azure': minor
---

Add option to create api management logging with app insights and/or az monitor
30 changes: 22 additions & 8 deletions packages/azure/src/construct/rest-api/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export class AzureRestApi extends CommonAzureConstruct {
* @summary Method to create the API Management logger with Application Insights integration
*/
protected createApiManagementLogger() {
if (this.props.apiManagement.useExistingApiManagement) return
if (this.props.apiManagement.useExistingApiManagement && !this.props.apiManagementDiagnosticAppInsights) return

const apiAppNamedValue = this.apiManagementManager.createNamedValue(`${this.id}-am-nv`, this, {
displayName: this.applicationInsights.name,
Expand Down Expand Up @@ -288,13 +288,27 @@ export class AzureRestApi extends CommonAzureConstruct {
protected createApiDiagnostic() {
if (this.props.apiManagement.useExistingApiManagement) return

this.apiManagementManager.createApiDiagnostic(`${this.id}-all-apis`, this, {
...this.props.apiManagementDiagnostic,
apiId: this.api.apim.id,
resourceGroupName: this.resourceGroup.name,
serviceName: this.api.apim.name,
loggerId: this.api.logger.id,
})
if (this.props.apiManagementDiagnosticAppInsights) {
this.apiManagementManager.createApiDiagnostic(`${this.id}-all-apis-app-insights`, this, {
...this.props.apiManagementDiagnosticAppInsights,
diagnosticId: 'applicationinsights',
apiId: this.api.apim.id,
resourceGroupName: this.resourceGroup.name,
serviceName: this.api.apim.name,
loggerId: this.api.logger.id,
})
}

if (this.props.apiManagementDiagnosticAzMonitor) {
this.apiManagementManager.createApiDiagnostic(`${this.id}-all-apis-az-monitor`, this, {
...this.props.apiManagementDiagnosticAzMonitor,
diagnosticId: 'azuremonitor',
apiId: this.api.apim.id,
resourceGroupName: this.resourceGroup.name,
serviceName: this.api.apim.name,
loggerId: pulumi.interpolate`${this.api.apim.id}/loggers/azuremonitor`,
})
}
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/azure/src/construct/rest-api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export interface AzureRestApiProps extends CommonAzureStackProps {
/** API Management service properties */
apiManagement: ApiManagementProps
/** API diagnostic properties for logging */
apiManagementDiagnostic: ApiDiagnosticProps
apiManagementDiagnosticAppInsights: ApiDiagnosticProps
apiManagementDiagnosticAzMonitor: ApiDiagnosticProps
/** Monitor diagnostic settings for the API Management service */
apiManagementDiagnosticSettings: MonitorDiagnosticSettingProps
}
Expand Down