File: reporting.rst

package info (click to toggle)
metrics-clojure 2.9.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 404 kB
  • sloc: makefile: 135; xml: 99; python: 22
file content (89 lines) | stat: -rw-r--r-- 2,424 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Reporting
=========

Once you've started tracking some metrics there are several ways you can read
their values.

More reporting methods will be added in the future.  Pull requests are welcome.

Console
-------

metrics-clojure supports reporting metrics through the console (on standard
error)::

    (require '[metrics.reporters.console :as console])

    (def CR (console/reporter reg {}))
    (console/start CR 10)

This will tell ``metrics`` to print all metrics to the console every ten
seconds.

Optional arguments to console/reporter are:

- :stream
- :locale
- :clock
- :rate-unit
- :duration-unit
- :filter

CSV Reporting
-------------

metrics-clojure supports reporting metrics into csv files (one file per metric)::

    (require '[metrics.reporters.csv :as csv])

    (def CR (csv/reporter reg "/tmp/csv_reporter" {}))
    (csv/start CR 1)

This will tell ``metrics`` to append the most recent value or each
metric (every second), to a file named after the metric, in
``/tmp/csv_reporter``. The directory name is required. The directory
(and parents) will be created if they doesn't exist, it will throw an
exception if it is not writable, or if the given path is not a
directory.

To use this reporter, you may need to sanitize your metric names to
ensure that they are valid filenames for your system.

Optional arguments to csv/reporter are:

- :locale
- :rate-unit
- :duration-unit
- :filter

JMX and ``jvisualvm``
---------------------

metrics-clojure also supports `JMX reporting
<http://metrics.dropwizard.io/3.1.0/manual/core/#jmx>`_, since it's built into
``metrics`` itself.::

    (require '[metrics.reporters.jmx :as jmx])

    (def JR (jmx/reporter reg {}))
    (jmx/start JR)

This will tell ``metrics`` to make all metrics available via ``JMX`` under ``metrics`` domain.

Once this is done, you can open ``jvisualvm`` (which you probably already have as
it's included in many Java distributions), connect to a process, and view
metrics in the MBeans tab.

Optional arguments to jmx/reporter are:

- :domain
- :rate-unit
- :duration-unit
- :filter

Note that there are options available to the JMX reporter that are not
visible through the Clojure interface. I'm not that familiar with JMX,
and didn't know how to handle things like ObjectNameFactory.

See https://github.com/dropwizard/metrics/blob/master/metrics-core/src/main/java/com/codahale/metrics/JmxReporter.java
for the original code.