Metrcis API

The Avid Connector API exposes internal metrics like operation duration, message size and many more. The metrics
are automatically send to the platform. The platform can be configured to expose the metrics into different
backends like Graphite or CloudWatch.

Examples

In some cases it is not enough to know the duration of a operation and a service developer feels the need to
measure specific parts of her business logic. The Avid Connector API exposes for that reason a Metrics API.

Here are some examples of how to use the Metrics API:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var bal = require('proxy-bal');

# Get the metrics global instance (can be called multiple times)
var metrics = bal.metric.global();

var counter = metrics.counter("myservice.mycounter");
counter.inc();
counter.inc(4);
counter.dec()
counter.dec(2)

var meter = metrics.meter("myservice.mytimer");
meter.mark();
meter.mark(4);

var timer = metrics.timer("myservice.mytimer");
var watch = timer.watch();
mymodel.find("it", function() {
watch.stop();
});

var hist = metrics.histogram("myservice.myhist");
hist.update(fileSizeInBytes);

Names

  • Prefix metric names to prevent possible clashes with core metrics (.eg. iam, asset)
  • Dots are path in target systems like Graphite. Try to design you metric names in order to make it easy to capture e.g. all mongo queries with a wild card.
    • Good: iam.mongo.query.findPrinciple, iam.mongo.query.deletePrincipleByName
    • Bad: iam.mongo.query.find.principle, iam.mongo.query.delete.principle.by.name
  • Do not use unbound values like UUID in metric names. Metrics with unbound names are expensive to aggregate and to store.

Tag

In most cases you don’t have to worry about the metrics tag but if you have a deployment where you must run multiple instances of the same service on the same host machine you must make sure that metrics of each instance are unique by defining the ACS_METRICS_TAG environment variable.

Here is a naming example if you have to run 3 instances of the transcode service on the same host:

  • transcode-1
  • transcode-2
  • transcode-3