Permalink
Browse files

Updated docs, fixed 'type' parameter for MetricsObject, ensure graphi…

…te host is set if graphite is used at the output type
  • Loading branch information...
1 parent 03bb9be commit 134dc3dd582d86a853585ea52792ba8b772d8b05 @mikebrittain mikebrittain committed Apr 27, 2011
Showing with 17 additions and 8 deletions.
  1. +8 −2 README
  2. +1 −1 SampleLogster.py
  3. +6 −3 logster
  4. +2 −2 logster_helper.py
View
10 README
@@ -29,9 +29,9 @@ Usage
You can test logster from the command line. There are two sample parsers (SampleGangliaLogster and SampleGraphiteLogster) that can be used to generate stats from an Apache access log. The --dry-run option will allow you to see the metrics being generated on stdout rather than sending them to either Ganglia or Graphite.
- $ sudo /usr/sbin/logster --dry-run SampleGangliaLogster /var/log/httpd/access_log
+ $ sudo /usr/sbin/logster --dry-run --output=ganglia SampleLogster /var/log/httpd/access_log
- $ sudo /usr/sbin/logster --dry-run SampleGraphiteLogster /var/log/httpd/access_log
+ $ sudo /usr/sbin/logster --dry-run --output=graphite --graphite-host=graphite.example.com:2003 SampleLogster /var/log/httpd/access_log
Additional usage details can be found with the -h option:
@@ -41,6 +41,8 @@ usage: logster [options] parser logfile
Tail a log file and filter each line to generate metrics that can be sent to
common monitoring packages.
+usage: logster [options] parser logfile
+
options:
-h, --help show this help message and exit
-p METRIC_PREFIX, --metric-prefix=METRIC_PREFIX
@@ -57,5 +59,9 @@ options:
-s STATE_DIR, --state-dir=STATE_DIR
Where to store the logtail state file. Default
location /var/run
+ -o OUTPUT, --output=OUTPUT
+ Where to send metrics (can specify multiple times).
+ Choices are 'graphite', 'ganglia', or 'stdout'.
-d, --dry-run Parse the log file but send stats to standard output.
-D, --debug Provide more verbose logging for debugging.
+
View
@@ -2,7 +2,7 @@
### of response codes found in an Apache access log.
###
### For example:
-### sudo ./logster --dry-run SampleGraphiteLogster /var/log/httpd/access_log
+### sudo ./logster --dry-run --output=ganglia SampleLogster /var/log/httpd/access_log
###
###
### Copyright 2011, Etsy, Inc.
View
@@ -80,7 +80,7 @@ cmdline.add_option('--state-dir', '-s', action='store', default=state_dir,
help='Where to store the logtail state file. Default location %s' % state_dir)
cmdline.add_option('--output', '-o', action='append',
choices=('graphite', 'ganglia', 'stdout'),
- help="Output to send information to (can specify multiple times)")
+ help="Where to send metrics (can specify multiple times). Choices are 'graphite', 'ganglia', or 'stdout'.")
cmdline.add_option('--dry-run', '-d', action='store_true', default=False,
help='Parse the log file but send stats to standard output.')
cmdline.add_option('--debug', '-D', action='store_true', default=False,
@@ -92,7 +92,10 @@ if (len(arguments) != 2):
cmdline.error("Supply at least two arguments: parser and logfile.")
if not options.output:
cmdline.print_help()
- cmdline.error("Supply where the data should be sent with -o")
+ cmdline.error("Supply where the data should be sent with -o (or --output).")
+if 'graphite' in options.output and not options.graphite_host:
+ cmdline.print_help()
+ cmdline.error("You must supply --graphite-host when using 'graphite' as an output type.")
class_name = arguments[0]
log_file = arguments[1]
@@ -138,7 +141,7 @@ def submit_stdout(metrics, options):
for metric in metrics:
if (options.metric_prefix != ""):
metric.name = options.metric_prefix + "_" + metric.name
- print "%s: %s" %(metric.name, metric.value)
+ print "%s %s" %(metric.name, metric.value)
def submit_ganglia(metrics, options):
for metric in metrics:
View
@@ -23,11 +23,11 @@
class MetricObject(object):
"""General representation of a metric that can be used in many contexts"""
- def __init__(self, name, value, units='', metric_type='float'):
+ def __init__(self, name, value, units='', type='float'):
self.name = name
self.value = value
self.units = units
- self.metric_type = metric_type
+ self.type = type
self.timestamp = int(time())
class LogsterParser(object):

0 comments on commit 134dc3d

Please sign in to comment.