Giter Club home page Giter Club logo

layer-metrics's People

Contributors

cmars avatar johnsca avatar rmescandon avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

layer-metrics's Issues

support metrics per application

Some metrics are best reported per-application, and not per unit. For example, members of a zookeeper cluster. My metric simply does a word count of a conf file:

metrics:
  servers:
    type: gauge
    description: number of zookeeper servers in the cluster
    command: grep ^server /etc/zookeeper/conf/zoo.cfg  | wc -l

When displaying this metric, I only want one count across the whole application, regardless of how many units are deployed. Instead, I get this:

$ juju metrics zookeeper
UNIT       	           TIMESTAMP	 METRIC	VALUE
zookeeper/0	2017-03-19T17:09:43Z	servers	    3
zookeeper/1	2017-03-19T17:04:45Z	servers	    3
zookeeper/2	2017-03-19T17:07:11Z	servers	    3

One approach to address this would be to classify the metric in metrics.yaml as something like "leader-only", so it would only run collect-metrics on the leader of an application. That yaml might looks something like this:

metrics:
  servers:
    type: gauge
    leader-only: true
    description: number of zookeeper servers in the cluster
    command: grep ^server /etc/zookeeper/conf/zoo.cfg  | wc -l

Or perhaps introduce a new metric type like "gauge-leader" that does the same thing -- only run metric collections on the leader of the application:

metrics:
  servers:
    type: gauge-leader
    description: number of zookeeper servers in the cluster
    command: grep ^server /etc/zookeeper/conf/zoo.cfg  | wc -l

error when metric does not include a "command"

I've included the basic juju-units metric in my charm's metrics.yaml:

$ cat ~/charms/xenial/hadoop-namenode/metrics.yaml
metrics:
  juju-units: {}

This metric has no command key, so my logs are littered with these errors:

unit-namenode-0: 18:07:30 INFO unit.unit-namenode-0.collect-metrics error: no metrics specified
unit-namenode-0: 18:07:30 INFO unit.unit-namenode-0.collect-metrics Traceback (most recent call last):
unit-namenode-0: 18:07:30 INFO unit.unit-namenode-0.collect-metrics   File "/var/lib/juju/agents/unit-namenode-0/charm/hooks/collect-metrics", line 33, in <module>
unit-namenode-0: 18:07:30 INFO unit.unit-namenode-0.collect-metrics     check_call(command)
unit-namenode-0: 18:07:30 INFO unit.unit-namenode-0.collect-metrics   File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
unit-namenode-0: 18:07:30 INFO unit.unit-namenode-0.collect-metrics     raise CalledProcessError(retcode, cmd)
unit-namenode-0: 18:07:30 INFO unit.unit-namenode-0.collect-metrics subprocess.CalledProcessError: Command '['add-metric']' returned non-zero exit status 2

Couple potential fixes in ./hooks/collect-metrics:

  • inject a command: /bin/true if a metric does not define a command
    for metric, value in values.items():
        command.append("%s=%s" % (metric, value))
    else:
        # fwiw, i'm totally guessing that this will work
        command.append("%s=/bin/true" % (metric))
    return command
  • guard the check_call with an if <command is valid>: check_call(command)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.