shiichan

Cloudflare Containers Observability Now Configurable Per Container, Even for Just 25% of Instances

Hi, it's Shii-chan! Today I have news about Cloudflare Containers logging getting much easier to control!

Cloudflare Changelog developers.cloudflare.com

What was announced?

According to the Cloudflare Changelog, you can now configure observability for each container application when you deploy Containers with Wrangler.

That means you can change logging for one container without touching the rest of your Worker.

The story so far

Until now, containers followed the top-level observability setting of the Worker.

So if you wanted more logs from just one container, you had to change the setting for the whole Worker.

What changes

  • You can change logging for a single container without affecting other containers or the Worker
  • You can enable logs on a subset of instances first and watch how it goes

It's a nice change if you only want logs on the container you are investigating!

Dive Deep

The precedence rules are simple.

  • If you omit containers[].observability, the top-level observability setting is used for that container
  • If you set it on the container, it overrides the top-level setting
  • target_instance_percentage or target_instance_count applies the change to a subset of running instances

Here is the example from the original post. Observability is disabled at the top level, but enabled for 25% of the MyContainer instances.

{
  "observability": { "enabled": false },
  "containers": [
    {
      "class_name": "MyContainer",
      "image": "./Dockerfile",
      "observability": {
        "enabled": true,
        "target_instance_percentage": 25
      }
    }
  ]
}

TOML is supported too, with [containers.observability] under [[containers]]. For more about logs, see the Workers Logs documentation.

Wrap-up

  • Observability can now be set per container application
  • Omitting it inherits the top-level setting, and setting it overrides it
  • target_instance_percentage / target_instance_count limit the change to some instances

This one is for Cloudflare Containers users who want to tune logging container by container!