BLOG

The hidden costs of Google Cloud Datastore

1 laccckob6rseynehwfeceg

Table of contents

Datastore export costs donโ€™t show up in Google Cloud Monitoring. Hereโ€™s how to set up real-time alerts to better keep track of exportย costs.

Google Cloud Datastore monitoring, available in GCP Operations (formerly Stackdriver) as well as the App Engine Dashboard, shows metrics for your Datastore operations, allowing you to track where cloud costs or infrastructure load comes from.

1 laccckob6rseynehwfeceg
Reveal the hidden costs of Google Cloud Datastore

Or at least, mostly.

0 s5otpyghceq4wp17
Datastore Monitoring in GCP Operations Dashboard duringย Export
0 sppmwrqwai2l3qlg
Datastore Monitoring in GCP Operations Dashboard duringย Export

Read operations which are part of Datastore Export, are not reflected in the monitoring. You can see that in the two images to the left.

Compare these to the visualization in the dashboard for normal Datastore operations. (See the Appendix at the end of the post.)

So, if you do a massive backup using Export, you will pay for, but not easily see the source of, the costs. Worse, since Exports are usually set up to run periodically, using a cron job or the equivalent, massive Exports may be happening frequently and without your knowledge.

You can track costs in GCP Billing or with reOptimize, but that lags by a day and does not show the precise source of the costs.

Set up real-time alerts for when Datastore is inย use

Instead, look for an ExportEntities entry in the GCP logs. Find it using this advanced Log Viewer filter (or go straight to it here).

https://gist.github.com/JoshuaFox/20419549c002838b1e76f4bddfd9840b#file-log-filter-to-see-export

You can even set up an alert on this log query to remind you that your Datastore is in (potentially massive) use.

The steps to do this are just the usual ones for a Log-based Metric.

  • Go to the Log Viewer query.
  • Select โ€œCreate Metricโ€.
  • Give it a name like DatastoreExport, and leave the other default values (Counter Metric). Click โ€œCreate Metric.โ€ You will now be taken to the Metrics page.
  • Click the three vertical dots on the far right of your metric as in this screenshot, and choose โ€œCreate alert from metric.โ€
0 qiuocyj4ychyf bj
Log Metrics; choose to Createย alert

You may have to close the condition panel now, as the auto-filled values are buggy (and show an error indication).

  • Give your alerting policy a name, for example, exporting-alert.
  • Click โ€œAdd Conditionโ€ to (again) open the condition panel.
  • Give a Target of your new log-based metric (logging/user/DatastoreExport), and a trigger condition of โ€œis above 0โ€. Click โ€œAddโ€.
0 rnai y peei3era
Creating an alertingย policy
  • Click โ€œAdd notification channel,โ€ choose โ€œEmailโ€, and enter your address, and click โ€œAdd.โ€

You will now get an email when Export runs.

Appendix

These dashboard images show the normal operation of Monitoringโ€Šโ€”โ€ŠDatastore operations are correctly presented.

0 n1sz83vdxef71gjs
Datastore Monitoring in GCP Operations Dashboard during normal operations
0 ebeabwjju3hcd4y0
Datastore Monitoring in GCP Operations Dashboard during normal operations
0 j byiirtmdmdfnxf
Datastore billing status in AppEngine Dashboard during both normal operations andย Export
0 hczuuid2rnxl430w
Discovering the (possibly cron-triggered) Export, that incurred theย cost

Schedule a call with our team

You will receive a calendar invite to the email address provided below for a 15-minute call with one of our team members to discuss your needs.

You will be presented with date and time options on the next step