GCP Cloud Monitoring - Reduce Data and Cost
Cloud Monitoring can be used to monitor system status and send alert notifications. I mainly use to monitor hard disk capacity and some custom statuses. I installed Ops Agent on all machines to monitor hard disk status. But I later realized the bill was expensive, so I did some research on its fees and how to keep costs down.
Pricing
First of all, let’s understand the pricing of Cloud Monitoring. Mostly, only the first feature is used. The first 150 MiB of this part is a free quota. If we can keep below this, it can be used for free. This article is also for the description of this part.
Billing
Click Billing to find an item called Metric Volume, which is the cost of Cloud Monitoring data.
We can see that there is no such item in the first few days of the month. It only appears on the 5th because of the free quota 150 MiB for the first few days. After that, You can see that it costs about $4.3 per day. This is the case for 8 servers.
You can also see how much traffic is charged.
Usage
From the monitoring [Settings] tab, under GCP Projects, expand the project name, you can see the overall usage.
Click [View in Metrics Exploer] on the right side of Agent Metrics to check the usage report by time.
However, the cost cannot be calculated here. The calculation method is quite complicated. Some of which are free mertics, and some are discounted mertics. It can be seen that the usage displayed here is inconsistent with the billing. But it can be used to quickly check the usage changes after setting.
For the part of the billing mertics, I deduce it from the bill, 8 servers are $4.3 per day, one is $0.5375 per day, and $0.2580 per MiB. So by default, the billing usage generated by each server per day is 2.08 MiB.
Solutions
With the goal of reducing usage, apply the following strategies:
- Disable Ops Agent on unimportant servers.
- Report only necessary metrics.
- Reduce frequency.
We can modify the Ops Agent configuration file to achieve the purpose.
1 | sudo vi /etc/google-cloud-ops-agent/config.yaml |
Add the following settings
1 | metrics: |
Restart to apply
1 | sudo service google-cloud-ops-agent restart |
Older versions of Ops Agent may not support the above settings. For example, some of my old servers cannot install the latest Ops Agent, and there is no way to exclude metrics.