-
Notifications
You must be signed in to change notification settings - Fork 384
CustomCollectors
krasmussen edited this page May 15, 2013
·
7 revisions
Diamond collectors run within the diamond process and collect metrics that can be published to a graphite server.
Collectors are subclasses of diamond.collector.Collector. In their simplest form, they need to implement a single method called "collect".
import diamond.collector
class ExampleCollector(diamond.collector.Collector):
def collect(self):
# Set Metric Name
metric_name = "my.example.metric"
# Set Metric Value
metric_value = 42
# Publish Metric
self.publish(metric_name, metric_value)
To run this collector in test mode you can invoke the diamond server with the -r option and specify the collector path.
diamond -f -r path/to/ExampleCollector.py -c conf/diamond.conf.example
running diamond in the foreground (-f) while logging to stdout (-l) is a good way to quickly see if a custom collector is unable to load.
... diamond -f -l ...
For detailed description and example please take a look at the example collector in the Collectors Directory.