ANN: Metrics in Juju 2.0

Casey Marshall casey.marshall at
Mon Oct 3 15:22:05 UTC 2016

I’m pleased to announce Juju Metrics, new in Juju 2.0!

Knowing an application's configuration isn’t enough to effectively operate
and manage it. Consider that a well-designed application will have as few
configurable parameters as possible. As an operator, you may find yourself
wanting to know more about the resources that an application in your model
consumes and provides -- resources such as:


   Storage GiB used

   Number of user accounts

   Number of recently active users

   Active database connections

Juju Metrics complete the operational picture with application
observability; by modeling, sampling and collecting measurements of
resources such as these. Juju collects application metrics at a cadence
appropriate for taking a model-level assessment of application utilization
and capacity planning. Charm authors and communities can now collaborate on
figuring out the critical metrics for service assurance and ops, and share
that through the charms.

There are many instrumentation and time-series data collection solutions
supporting devops. Juju’s metrics complement these fine-grained,
lower-level data sources with a model-level overview -- possibly a starting
point for deeper analysis.

At a glance, operators can pull the most recent measurements across the
entire model:

$ juju metrics --all
UNIT                TIMESTAMP               METRIC      VALUE
auth-sso/0          2016-09-19T22:14:29Z    users       28
auth-sso/0          2016-09-19T22:14:31Z    tokens      6
ceph-mon/0          2016-09-19T22:15:36Z    gb-usage    5.2711902345
webapp/0            2016-09-19T22:17:57Z    requests    11903
webapp/1            2016-09-19T22:17:52Z    requests    13719

View measurements for specific units or applications:

$ juju metrics webapp/0
UNIT                TIMESTAMP               METRIC      VALUE
webapp/0            2016-09-19T22:17:57Z    requests    13719

$ juju metrics sso-auth
auth-sso/0          2016-09-19T22:14:29Z    users       28
auth-sso/0          2016-09-19T22:14:31Z    tokens      6

How about adding metrics to a charm? With the reactive framework, it’s
quick and easy!


   Add layer:metrics to your charm’s layer.yaml

   Declare measurements in your charm’s metrics.yaml

metrics.yaml declares each metric’s type and the command line that measures
it. For example, the hypothetical auth-sso charm in the example above might
declare metrics:

   type: gauge
   description: Number of users
   command: scripts/
   type: gauge
   description: Number of active tokens
   command: scripts/

The command lines given in command: attributes above simply need to write
the current gauge value -- a positive decimal number -- to standard output.
Juju 2.0 will initially support type: gauge metrics for the operational use
cases shown above; others such as type: absolute are experimental, and will
be better supported in Juju 2.1.

I’d like to encourage you to kick the tires on this new feature, and let’s
start measuring things in our charms!

For more information, here are links to documentation:

Metrics, User Guide:

Metrics, Developer Guide:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Juju mailing list