#15 on Fast Company’s Best Workplaces for Innovators List – Learn more

Iris 3: Automatic Google Cloud resource labeling for cost control

1 uovwkyzsxwpe 7tjclppng

Major improvements for your favorite Google Cloud resource labeler — including PubSub and CloudSQL support.

In 2018, DoiT International released Iris, an open-source project for automated labeling of resources in the Google Cloud. Now, I am happy to announce Iris 3, with additional features and new, modern implementation.

How Iris helps you

Iris automatically assigns labels to Google Cloud resources for easier and more detailed billing reports.

Each resource in Google Cloud in the GCP organization receives automatically generated labels to reflect fields of the resource. For example, a Google Compute Engine instance gets labels like [iris_name:nginx] and [iris_region:us-central1]. (The prefix is configurable.)

It may surprise you, but without such labels, the information simply is not available in the billing data.

With these labels, you can create reports in your favorite billing analytics tool.

How to use Iris

Let’s see how using Iris can save you time when creating reports on your cloud bills with two reporting systems:

  1. DoiT International’s Cloud Management Platform
  2. Google Cloud’s Billing Console

DoiT Cloud Management Platform

In Cloud Management Platform’s Cloud Reports GUI, build a report on your desired timespan and other fields, then click the Labels chip to select your label names(s), for example,iris_instance_type. Click on the new label chip (iris_instance_type) to filter by specific values. At this stage, you can exclude unlabeled resources as well, for example, those in projects that Iris 3 was configured to ignore.

Then drag the label chip to the left panel to indicate grouping, and you’re ready to go.

1 tfyll4nwaozphvlitm9ea
Reporting by instance type in the Cloud Management Platform

Google Cloud Platform Billing Reports

Though I’d love to have you with us at DoiT, not everyone is here yet, so you can do this in GCPs native billing reports.

In a view in the Billing Console, build a report on your desired timespan and other fields, then click the Labels on the lower-right pane, and enter the name of your label key(s), for example,iris_instance_type. You can select specific values at this stage, for filtering. (Unlabeled resources will automatically be excluded.) Then go up the Grouping and again enter your label.

1 cggq4yacnkdcsgdnaupj8a
Reporting by instance type in the Billing Console

Supported Google Cloud Products

Right now, the following resource types are supported:

  • Compute Engine Instances (including preemptible and those created by Managed Instance Groups), Disks, and Snapshots. (Labels are name, region, zone, and instance type)
  • Cloud Storage Buckets (name)
  • CloudSQL Instances (name and region)
  • BigQuery Datasets and Tables (name and location)
  • BigTable Instances (name, region, and zone)
  • PubSub Topics and Subscriptions (name)

You can easily add different kinds of labels, and resource types. See instructions here.

When does it run?

Iris can do this by schedule and on resource creation:

  • Every kind of resources gets labeled on a schedule, every 12 hours (configurable). Some kinds — Cloud SQL instances and boot disks created with an instance — only get labeled on schedule.
  • Most resources also get labeled immediately on creation: Iris 3 does this by listening to Google Cloud Operations (Stackdriver) logs.

New in Iris 3

Iris offers significant improvements both in the form of added features and a new, underlying platform.

New features

  • Labeling for PubSub Topics and Subscriptions, and Cloud SQL instances
  • An option for automatic copying of project labels into each resource in the project
  • An option to choose the projects that will be labeled (if only some projects need it; also saving costs); or alternatively to label resources in all projects across the entire organization
  • An option to save costs by using only scheduled labeling, without labeling on demand
  • Much easier plugin development and configuration. (Details here.)
  • Automated tests for quality
  • Bug fixes, optimizations, and improvements. (Details here.)

New platform

But the biggest change, and the reason for the new name and repo fork, was porting from Python 2 to the Python 3 version of Google App Engine Standard Environment. The Python 2 language has been end-of-life and unsupported since January 2020, and the Python 2 version of GAE has been deprecated for even longer.

Google has committed to long-term support for the Python 2 GAE, because of legacy customers who would find it difficult to migrate. But developing new features on this old version is somewhere between challenging and impossible, as the development and deployment tools, runtimes, and APIs show their age. Further, Google can no longer commit to patching all security vulnerabilities, which is a big red flag for a web application.

Migration required some new APIs: Among other changes, Task Queues support has been removed, and so PubSub was used instead.

But even better, this was an opportunity for a complete rewrite with a clean, standard code style, reduced code duplication, and other improvements that will ease your life as a developer and contributor of pull requests.

Why “Iris 3”?

This release is in a separate repo, with a new name.

This is because many users prefer to stick with the Python 2 GAE as long as possible — obsolete though it is! — due to its significant differences from the Python 3 GAE.

The “3”, of course, is not a version number: It’s in honor of the Python 3 GAE platform

Try Iris

Download Iris 3 from GitHub and follow instructions to deploy, develop, or test. I’m looking forward to your feedback and issue reports. And best of all, see the TODO.mdfile and send some pull requests!

GCP Auto-Tag vs. Iris 3

GCP Auto-Tag is another open-source project from DoiT for automatic labeling of instances and disks on creation.

The differences:

  • GCP Auto-Tag, unlike Iris 3, adds labels with the creator email; and, for disks, the name of the instance to which a disk is attached
  • GCP Auto-Tag labels boot disks on creation with the instance.
  • Iris 3, unlike Auto-Tag, adds labels with a name, zone, region, and instance type.
  • Iris 3 labels more resource types.
  • Iris 3 covers multiple projects in an organization and copies project labels onto resources.
  • Iris 3 labels resources which were created even before it was deployed.

Learn More

Read more about Iris:

Subscribe to updates, news and more.