# Cost management

On October 4th, I enabled a monitoring service that automatically pings the website every hour and reports back to me if the site is down. I didn't anticipate that this would drive up Azure App Services costs so much. Who knew!? 

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636815704691/1I67U6tw7.png)

I could reduce the costs in a number of different ways.  Probably the easiest is by scaling down the service plan that the site is running on to have fewer resources.

The chart below shows that I was getting pretty similar charges for US east and central last month (the donut chart in the bottom middle), which is surprising to me.  I thought my scale out settings were set to only run one node, so I expected to only see charges for US east.

![costs.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636815191019/fXCitVNdG.png)

After digging into a little more, I'm thinking the load from the new monitoring service wasn't the source of the increased costs.  I think I made some other inadvertent change to the service around the same time, that made a second node spin up in US central.  Not good!  

This is corrected now and I'm only seeing charges for US east now.  I've added a hard budget for the Azure subscription and have setup email alerts at 75% and 95% of the budget, so I shouldn't get any surprises going forward.

![costs-barchart.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636815065743/32cNjxgzm.png)

I think it's time to setup infrastructure automation with Terraform[1] to keep tighter control on what's deployed and to reduce point-and-click mistakes. 

Lesson learned!

[1] https://docs.microsoft.com/en-us/azure/developer/terraform/overview
