![](https://adatum.no/wp-content/themes/shapely/assets/images/placeholder_wide.jpg)
Azure managed Prometheus for existing AKS clusters
In the company I work for, we have multiple AKS clusters. They have different purpose, and are split between environments, like dev
and prod
. Nothing special at all. We recently decided to enable the clusters for Prometheus, and build our application dashboards using Grafana. A lot has changed since my last look at Azure Managed Prometheus. This time around I encountered a few challenges, below you’ll find a summary.
Our clusters are deployed using Terraform, and the monitoring “stack” with Bicep. Apart from a small difference in language, we also have decided that Prometheus and Grafana should exist in one region only, and we would only split the data source between dev
and production
environments. The Grafana instance is the same for both.
Enable monitoring
![Azure portal button to enable managed prometheus.](https://adatum.no/wp-content/uploads/2024/11/image-1024x125.png)
The button above makes it pretty simple to enable Azure Managed Prometheus for that specific cluster – but since we want to do this using code, we need to modify our modules. And what exactly does this Configure
button do? It creates a deployment which consist of a data collection rule, data collection endpoint, and a few Prometheus recording rules. During the process it also allows you to specify an existing managed Prometheus (Azure monitor metrics workspace) and managed Grafana.
![Deployments created by the automatic onboarding to prometheus](https://adatum.no/wp-content/uploads/2024/11/image-2-1024x156.png)
The data collection rule, and association is similar to what we already have with Log Analytics and container insights. That would mean a quick change to our existing Terraform code, adding a new collection rule. I thought…
All my issues is explained in various Microsoft Doc’s and GitHub repositories. However, piecing everything together together took a bit of time.
- With clusters in multiple regions. The data collection rule need to exist in the same location as the Azure monitor workspace (Prometheus). Unless you want the collection endpoint to also be in the same region. You will need to create two. One in the cluster region, and one in the monitor workspace region. I used this example as an inspiration, and this doc as a deployment reference guide.
- The automatic onboarding process deploy 1:1 relationship of the recording rules for the clusters. I did not want to manage the recording rules together with our clusters. And ended up creating them along-side Prometheus. By only specifying the
prometheusWorkspaceId
in thescope
, these rules are applied to all clusters sending data to the specific workspace. An example Bicep module here. You will also find them here, but without the UX rules. - We did not want to keep performance metrics sent to Log Analytics. If you don’t want that either. You’ll need to modify the data collection rule by specifying the streams you want. Specifically, remove
Microsoft-Perf
andMicrosoft-InsightsMetrics
![Portal experience with UX rules.](https://adatum.no/wp-content/uploads/2024/11/image-1-1024x372.png)