• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..14-Sep-2018-

README.mdH A D14-Sep-20188.5 KiB193140

config.goH A D14-Sep-20187.4 KiB289209

config_test.goH A D14-Sep-20184.8 KiB171143

errors.goH A D14-Sep-2018317 159

parser.goH A D14-Sep-201811.1 KiB423291

parser_test.goH A D14-Sep-201820.5 KiB725629

service.goH A D14-Sep-201812.3 KiB490394

service_test.goH A D14-Sep-20187.9 KiB307229

README.md

1# The Graphite Input
2
3## A Note On UDP/IP OS Buffer Sizes
4
5If you're using UDP input and running Linux or FreeBSD, please adjust your UDP buffer
6size limit, [see here for more details.](../udp/README.md#a-note-on-udpip-os-buffer-sizes)
7
8## Configuration
9
10Each Graphite input allows the binding address, target database, and protocol to be set. If the database does not exist, it will be created automatically when the input is initialized. The write-consistency-level can also be set. If any write operations do not meet the configured consistency guarantees, an error will occur and the data will not be indexed. The default consistency-level is `ONE`.
11
12Each Graphite input also performs internal batching of the points it receives, as batched writes to the database are more efficient. The default _batch size_ is 1000, _pending batch_ factor is 5, with a _batch timeout_ of 1 second. This means the input will write batches of maximum size 1000, but if a batch has not reached 1000 points within 1 second of the first point being added to a batch, it will emit that batch regardless of size. The pending batch factor controls how many batches can be in memory at once, allowing the input to transmit a batch, while still building other batches.
13
14## Parsing Metrics
15
16The Graphite plugin allows measurements to be saved using the Graphite line protocol. By default, enabling the Graphite plugin will allow you to collect metrics and store them using the metric name as the measurement.  If you send a metric named `servers.localhost.cpu.loadavg.10`, it will store the full metric name as the measurement with no extracted tags.
17
18While this default setup works, it is not the ideal way to store measurements in InfluxDB since it does not take advantage of tags.  It also will not perform optimally with large dataset sizes since queries will be forced to use regexes which is known to not scale well.
19
20To extract tags from metrics, one or more templates must be configured to parse metrics into tags and measurements.
21
22## Templates
23
24Templates allow matching parts of a metric name to be used as tag keys in the stored metric.  They have a similar format to Graphite metric names.  The values in between the separators are used as the tag keys.  The location of the tag key that matches the same position as the Graphite metric section is used as the value.  If there is no value, the Graphite portion is skipped.
25
26The special value _measurement_ is used to define the measurement name.  It can have a trailing `*` to indicate that the remainder of the metric should be used.  If a _measurement_ is not specified, the full metric name is used.
27
28### Basic Matching
29
30`servers.localhost.cpu.loadavg.10`
31* Template: `.host.resource.measurement*`
32* Output:  _measurement_ =`loadavg.10` _tags_ =`host=localhost resource=cpu`
33
34### Multiple Measurement & Tags Matching
35
36The _measurement_ can be specified multiple times in a template to provide more control over the measurement name. Tags can also be
37matched multiple times. Multiple values will be joined together using the _Separator_ config variable.  By default, this value is `.`.
38
39`servers.localhost.localdomain.cpu.cpu0.user`
40* Template: `.host.host.measurement.cpu.measurement`
41* Output: _measurement_ = `cpu.user` _tags_ = `host=localhost.localdomain cpu=cpu0`
42
43Since `.` requires queries on measurements to be double-quoted, you may want to set this to `_` to simplify querying parsed metrics.
44
45`servers.localhost.cpu.cpu0.user`
46* Separator: `_`
47* Template: `.host.measurement.cpu.measurement`
48* Output: _measurement_ = `cpu_user` _tags_ = `host=localhost cpu=cpu0`
49
50### Adding Tags
51
52Additional tags can be added to a metric if they don't exist on the received metric.  You can add additional tags by specifying them after the pattern.  Tags have the same format as the line protocol.  Multiple tags are separated by commas.
53
54`servers.localhost.cpu.loadavg.10`
55* Template: `.host.resource.measurement* region=us-west,zone=1a`
56* Output:  _measurement_ = `loadavg.10` _tags_ = `host=localhost resource=cpu region=us-west zone=1a`
57
58### Fields
59
60A field key can be specified by using the keyword _field_. By default if no _field_ keyword is specified then the metric will be written to a field named _value_.
61
62The field key can also be derived from the second "half" of the input metric-name by specifying ```field*``` (eg ```measurement.measurement.field*```). This cannot be used in conjunction with "measurement*"!
63
64It's possible to amend measurement metrics with additional fields, e.g:
65
66Input:
67```
68sensu.metric.net.server0.eth0.rx_packets 461295119435 1444234982
69sensu.metric.net.server0.eth0.tx_bytes 1093086493388480 1444234982
70sensu.metric.net.server0.eth0.rx_bytes 1015633926034834 1444234982
71sensu.metric.net.server0.eth0.tx_errors 0 1444234982
72sensu.metric.net.server0.eth0.rx_errors 0 1444234982
73sensu.metric.net.server0.eth0.tx_dropped 0 1444234982
74sensu.metric.net.server0.eth0.rx_dropped 0 1444234982
75```
76
77With template:
78```
79sensu.metric.* ..measurement.host.interface.field
80```
81
82Becomes database entry:
83```
84> select * from net
85name: net
86---------
87time      host  interface rx_bytes    rx_dropped  rx_errors rx_packets    tx_bytes    tx_dropped  tx_errors
881444234982000000000 server0  eth0    1.015633926034834e+15 0   0   4.61295119435e+11 1.09308649338848e+15  0 0
89```
90
91## Multiple Templates
92
93One template may not match all metrics.  For example, using multiple plugins with diamond will produce metrics in different formats.  If you need to use multiple templates, you'll need to define a prefix filter that must match before the template can be applied.
94
95### Filters
96
97Filters have a similar format to templates but work more like wildcard expressions.  When multiple filters would match a metric, the more specific one is chosen.  Filters are configured by adding them before the template.
98
99For example,
100
101```
102servers.localhost.cpu.loadavg.10
103servers.host123.elasticsearch.cache_hits 100
104servers.host456.mysql.tx_count 10
105servers.host789.prod.mysql.tx_count 10
106```
107* `servers.*` would match all values
108* `servers.*.mysql` would match `servers.host456.mysql.tx_count 10`
109* `servers.localhost.*` would match `servers.localhost.cpu.loadavg`
110* `servers.*.*.mysql` would match `servers.host789.prod.mysql.tx_count 10`
111
112## Default Templates
113
114If no template filters are defined or you want to just have one basic template, you can define a default template.  This template will apply to any metric that has not already matched a filter.
115
116```
117dev.http.requests.200
118prod.myapp.errors.count
119dev.db.queries.count
120```
121
122* `env.app.measurement*` would create
123  * _measurement_=`requests.200` _tags_=`env=dev,app=http`
124  * _measurement_= `errors.count` _tags_=`env=prod,app=myapp`
125  * _measurement_=`queries.count` _tags_=`env=dev,app=db`
126
127## Global Tags
128
129If you need to add the same set of tags to all metrics, you can define them globally at the plugin level and not within each template description.
130
131## Minimal Config
132```
133[[graphite]]
134  enabled = true
135  # bind-address = ":2003"
136  # protocol = "tcp"
137  # consistency-level = "one"
138
139  ### If matching multiple measurement files, this string will be used to join the matched values.
140  # separator = "."
141
142  ### Default tags that will be added to all metrics.  These can be overridden at the template level
143  ### or by tags extracted from metric
144  # tags = ["region=us-east", "zone=1c"]
145
146  ### Each template line requires a template pattern.  It can have an optional
147  ### filter before the template and separated by spaces.  It can also have optional extra
148  ### tags following the template.  Multiple tags should be separated by commas and no spaces
149  ### similar to the line protocol format.  The can be only one default template.
150  # templates = [
151  #   "*.app env.service.resource.measurement",
152  #   # Default template
153  #   "server.*",
154 #]
155```
156
157## Customized Config
158```
159[[graphite]]
160   enabled = true
161   separator = "_"
162   tags = ["region=us-east", "zone=1c"]
163   templates = [
164     # filter + template
165     "*.app env.service.resource.measurement",
166
167     # filter + template + extra tag
168     "stats.* .host.measurement* region=us-west,agent=sensu",
169
170     # filter + template with field key
171     "stats.* .host.measurement.field",
172
173     # default template. Ignore the first Graphite component "servers"
174     ".measurement*",
175 ]
176```
177
178## Two Graphite Listeners, UDP & TCP, Config
179
180```
181[[graphite]]
182  enabled = true
183  bind-address = ":2003"
184  protocol = "tcp"
185  # consistency-level = "one"
186
187[[graphite]]
188  enabled = true
189  bind-address = ":2004" # the bind address
190  protocol = "udp" # protocol to read via
191  udp-read-buffer = 8388608 # (8*1024*1024) UDP read buffer size
192```
193