EES-5687 - removed base alert templates for CPU, memory and response times #5489
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR:
dynamicMerticAlert.bicep
and reusable configuration items.POC for replacing base templates
Why the POC?
When carrying out work for EES-5687, I saw that a number of resources could potentially use a shared default configuration for common alert types - notably CPU percentage, memory percentage and response times. With this in mind, I created some
base
templates e.g.baseCpuPercentageAlert.bicep
which encapsulated common configuration and behaviour for all CPU percentage alerts. If necessary, the defaults could be overridden but in general, we'd end up with consistently-named CPU % alerts that generally behaved the same, and one place to change if we wanted to affect the behaviour of them all.@ntsim pointed out however that having this AND a resource-specific alert module that reused this base one e.g.
containerApps/cpuPercentageAlert.bicep
would cause multi-level ARM deploys and hinder debugging etc. He proposed removing the resource-specific ones and just calling the base ones directly from the low-level components' Bicep files e.g.containerApp.bicep
would callbaseCpuPercentageAlert.bicep
directly instead, allowing one less level of redirection.The proposed POC here
When playing with the above suggestion, I also toyed with making the
dynamicMetricAlert.bicep
module easier to call and with less boilerplate for the various callsites that use it. To prevent this POC branch from getting too big, I called this new version of itdynamicMetricAlertNew.bicep
temporarily.Because it was easier to call, I then looked at just calling it directly from the low-level component Bicep files e.g.
containerApp.bicep
would just calldynamicMetricAlertNew.bicep
directly and do away with thebaseCpuPercentageAlert.bicep
file altogether.I still wanted to keep the consistency of the naming and behaviour of the CPU alerts though, so I created a reusable chunk of configuration that could be used easily with
dynamicMetricAlertNew.bicep
wherever we were setting up a CPU alert, to ensure consistent behaviour and naming by default.The advantage of this approach is that we get to remove 2 layers of indirection (
containerApps/cpuPercentageAlert.bicep
ANDbaseCpuPercentageAlert.bicep
), but still retain the consistency of setting up CPU alerts across the board, as an example.POC for valid resource type / metric name combinations
Why the POC?
In the review of EES-5687, @ntsim suggested that we look to introduce some type checking for Cpu- and Memory-specific resource types and metric names, calling them for instance
CpuResourceType
andCpuMetricName
when used with a CPU-specific alert template. In this PR however, I've done away with scenario-specific alert templates, instead opting for callingdynamicMetricAlertNew.bicep
directly.The proposed POC here
Based on the above change in approach, I have therefore opted for another approach, listing out valid combinations of resourceType and metricName in a new user-defined type called
ResourceMetric
, which is a union of valid metrics versus resourceTypes inresourceMetrics.bicep
. This constrains combinations of resourceType and metricName that can be passed intodynamicMetricAlertNew.bicep
.What next if the above proposed approaches are OK?
The rest of the resourceType, metricName combinations will be added to
resourceMetrics.bicep
.dynamicMetricAlert.bicep
will be updated with the contents ofdynamicMetricAlertNew.bicep
, anddynamicMetricAlertNew.bicep
will be removed.All templates calling
dynamicMetricAlert.bicep
directly will be updated to use the new reduced-boilerplate syntax that was introduced indynamicMetricAlertNew.bicep
.As a separate PR, existing resource-specific alert templates that call
dynamicMetricAlert.bicep
can be removed in favour of callingdynamicMetricAlert.bicep
directly from the low-level component Bicep files. As an example,postrgreSqlFlexibleServers/clientConnectionsWaitingAlert.bicep
can be removed in favour of callingdynamicMetricAlert.bicep
directly inpostgresDatabase.bicep
.As another separate PR,
staticMetricAlert.bicep
can undergo the same treatment. We can then remove theResourceType
andMetricType
types fromalerts/types.bicep
as the new type laid out inresourceMetrics.bicep
is much more useful.