Skip to content
This repository
Browse code

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

…te host is set if graphite is used at the output type
  • Loading branch information...
commit 134dc3dd582d86a853585ea52792ba8b772d8b05 1 parent 03bb9be
Mike Brittain authored
10  README
@@ -29,9 +29,9 @@ Usage
29 29
 
30 30
 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.
31 31
 
32  
-  $ sudo /usr/sbin/logster --dry-run SampleGangliaLogster /var/log/httpd/access_log
  32
+  $ sudo /usr/sbin/logster --dry-run --output=ganglia SampleLogster /var/log/httpd/access_log
33 33
 
34  
-  $ sudo /usr/sbin/logster --dry-run SampleGraphiteLogster /var/log/httpd/access_log
  34
+  $ sudo /usr/sbin/logster --dry-run --output=graphite --graphite-host=graphite.example.com:2003 SampleLogster /var/log/httpd/access_log
35 35
 
36 36
 Additional usage details can be found with the -h option:
37 37
 
@@ -41,6 +41,8 @@ usage: logster [options] parser logfile
41 41
 Tail a log file and filter each line to generate metrics that can be sent to
42 42
 common monitoring packages.
43 43
 
  44
+usage: logster [options] parser logfile
  45
+
44 46
 options:
45 47
   -h, --help            show this help message and exit
46 48
   -p METRIC_PREFIX, --metric-prefix=METRIC_PREFIX
@@ -57,5 +59,9 @@ options:
57 59
   -s STATE_DIR, --state-dir=STATE_DIR
58 60
                         Where to store the logtail state file.  Default
59 61
                         location /var/run
  62
+  -o OUTPUT, --output=OUTPUT
  63
+                        Where to send metrics (can specify multiple times).
  64
+                        Choices are 'graphite', 'ganglia', or 'stdout'.
60 65
   -d, --dry-run         Parse the log file but send stats to standard output.
61 66
   -D, --debug           Provide more verbose logging for debugging.
  67
+
2  SampleLogster.py
@@ -2,7 +2,7 @@
2 2
 ###  of response codes found in an Apache access log.
3 3
 ###
4 4
 ###  For example:
5  
-###  sudo ./logster --dry-run SampleGraphiteLogster /var/log/httpd/access_log
  5
+###  sudo ./logster --dry-run --output=ganglia SampleLogster /var/log/httpd/access_log
6 6
 ###
7 7
 ###
8 8
 ###  Copyright 2011, Etsy, Inc.
9  logster
@@ -80,7 +80,7 @@ cmdline.add_option('--state-dir', '-s', action='store', default=state_dir,
80 80
                     help='Where to store the logtail state file.  Default location %s' % state_dir)
81 81
 cmdline.add_option('--output', '-o', action='append',
82 82
                    choices=('graphite', 'ganglia', 'stdout'),
83  
-                   help="Output to send information to (can specify multiple times)")
  83
+                   help="Where to send metrics (can specify multiple times). Choices are 'graphite', 'ganglia', or 'stdout'.")
84 84
 cmdline.add_option('--dry-run', '-d', action='store_true', default=False,
85 85
                     help='Parse the log file but send stats to standard output.')
86 86
 cmdline.add_option('--debug', '-D', action='store_true', default=False,
@@ -92,7 +92,10 @@ if (len(arguments) != 2):
92 92
     cmdline.error("Supply at least two arguments: parser and logfile.")
93 93
 if not options.output:
94 94
     cmdline.print_help()
95  
-    cmdline.error("Supply where the data should be sent with -o")
  95
+    cmdline.error("Supply where the data should be sent with -o (or --output).")
  96
+if 'graphite' in options.output and not options.graphite_host:
  97
+    cmdline.print_help()
  98
+    cmdline.error("You must supply --graphite-host when using 'graphite' as an output type.")
96 99
 
97 100
 class_name = arguments[0]
98 101
 log_file   = arguments[1]
@@ -138,7 +141,7 @@ def submit_stdout(metrics, options):
138 141
     for metric in metrics:
139 142
         if (options.metric_prefix != ""):
140 143
             metric.name = options.metric_prefix + "_" + metric.name
141  
-        print "%s: %s" %(metric.name, metric.value)
  144
+        print "%s %s" %(metric.name, metric.value)
142 145
 
143 146
 def submit_ganglia(metrics, options):
144 147
     for metric in metrics:
4  logster_helper.py
@@ -23,11 +23,11 @@
23 23
 
24 24
 class MetricObject(object):
25 25
     """General representation of a metric that can be used in many contexts"""
26  
-    def __init__(self, name, value, units='', metric_type='float'):
  26
+    def __init__(self, name, value, units='', type='float'):
27 27
         self.name = name
28 28
         self.value = value
29 29
         self.units = units
30  
-        self.metric_type = metric_type
  30
+        self.type = type
31 31
         self.timestamp = int(time())
32 32
 
33 33
 class LogsterParser(object):

0 notes on commit 134dc3d

Please sign in to comment.
Something went wrong with that request. Please try again.