2018-05-05 01:27:31 +00:00
|
|
|
# Output Data Formats
|
2016-02-12 22:09:34 +00:00
|
|
|
|
2018-05-05 01:27:31 +00:00
|
|
|
In addition to output specific data formats, Telegraf supports a set of
|
|
|
|
standard data formats that may be selected from when configuring many output
|
|
|
|
plugins.
|
2016-04-08 22:04:45 +00:00
|
|
|
|
2018-03-29 20:31:43 +00:00
|
|
|
1. [InfluxDB Line Protocol](#influx)
|
|
|
|
1. [JSON](#json)
|
|
|
|
1. [Graphite](#graphite)
|
2016-04-08 22:04:45 +00:00
|
|
|
|
2018-05-05 01:27:31 +00:00
|
|
|
You will be able to identify the plugins with support by the presence of a
|
|
|
|
`data_format` config option, for example, in the `file` output plugin:
|
2016-02-12 22:09:34 +00:00
|
|
|
```toml
|
|
|
|
[[outputs.file]]
|
2016-02-18 21:26:51 +00:00
|
|
|
## Files to write to, "stdout" is a specially handled file.
|
2016-02-13 18:50:43 +00:00
|
|
|
files = ["stdout"]
|
2016-02-12 22:09:34 +00:00
|
|
|
|
2016-04-08 22:04:45 +00:00
|
|
|
## Data format to output.
|
2017-04-27 21:59:18 +00:00
|
|
|
## Each data format has its own unique set of configuration options, read
|
2016-02-18 21:26:51 +00:00
|
|
|
## more about them here:
|
|
|
|
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
|
2016-02-12 22:09:34 +00:00
|
|
|
data_format = "influx"
|
|
|
|
```
|
|
|
|
|
2018-05-05 01:27:31 +00:00
|
|
|
## Influx
|
2016-02-12 22:09:34 +00:00
|
|
|
|
2018-05-05 01:27:31 +00:00
|
|
|
The `influx` data format outputs metrics using
|
2018-03-29 20:31:43 +00:00
|
|
|
[InfluxDB Line Protocol](https://docs.influxdata.com/influxdb/latest/write_protocols/line_protocol_tutorial/).
|
2018-05-05 01:27:31 +00:00
|
|
|
This is the recommended format unless another format is required for
|
2018-03-29 20:31:43 +00:00
|
|
|
interoperability.
|
2016-02-12 22:09:34 +00:00
|
|
|
|
2018-05-05 01:27:31 +00:00
|
|
|
### Influx Configuration
|
2016-02-12 22:09:34 +00:00
|
|
|
```toml
|
|
|
|
[[outputs.file]]
|
2016-02-18 21:26:51 +00:00
|
|
|
## Files to write to, "stdout" is a specially handled file.
|
2016-02-12 22:09:34 +00:00
|
|
|
files = ["stdout", "/tmp/metrics.out"]
|
|
|
|
|
2016-04-08 22:04:45 +00:00
|
|
|
## Data format to output.
|
2017-04-27 21:59:18 +00:00
|
|
|
## Each data format has its own unique set of configuration options, read
|
2016-02-18 21:26:51 +00:00
|
|
|
## more about them here:
|
|
|
|
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
|
2016-02-12 22:09:34 +00:00
|
|
|
data_format = "influx"
|
2018-03-29 20:31:43 +00:00
|
|
|
|
|
|
|
## Maximum line length in bytes. Useful only for debugging.
|
|
|
|
# influx_max_line_bytes = 0
|
|
|
|
|
|
|
|
## When true, fields will be output in ascending lexical order. Enabling
|
|
|
|
## this option will result in decreased performance and is only recommended
|
|
|
|
## when you need predictable ordering while debugging.
|
|
|
|
# influx_sort_fields = false
|
|
|
|
|
|
|
|
## When true, Telegraf will output unsigned integers as unsigned values,
|
|
|
|
## i.e.: `42u`. You will need a version of InfluxDB supporting unsigned
|
|
|
|
## integer values. Enabling this option will result in field type errors if
|
|
|
|
## existing data has been written.
|
|
|
|
# influx_uint_support = false
|
2016-02-12 22:09:34 +00:00
|
|
|
```
|
|
|
|
|
2018-05-05 01:27:31 +00:00
|
|
|
## Graphite
|
2016-02-12 22:09:34 +00:00
|
|
|
|
2018-05-21 23:39:33 +00:00
|
|
|
The Graphite data format is translated from Telegraf Metrics using either the
|
|
|
|
template pattern or tag support method. You can select between the two
|
|
|
|
methods using the [`graphite_tag_support`](#graphite-tag-support) option. When set, the tag support
|
|
|
|
method is used, otherwise the [`template` pattern](#template-pattern) is used.
|
|
|
|
|
|
|
|
#### Template Pattern
|
|
|
|
|
|
|
|
The `template` option describes how Telegraf traslates metrics into _dot_
|
|
|
|
buckets. The default template is:
|
2016-02-12 22:09:34 +00:00
|
|
|
|
|
|
|
```
|
2016-04-08 22:04:45 +00:00
|
|
|
template = "host.tags.measurement.field"
|
2016-02-12 22:09:34 +00:00
|
|
|
```
|
|
|
|
|
2016-04-08 22:04:45 +00:00
|
|
|
In the above template, we have four parts:
|
|
|
|
|
|
|
|
1. _host_ is a tag key. This can be any tag key that is in the Telegraf
|
|
|
|
metric(s). If the key doesn't exist, it will be ignored. If it does exist, the
|
|
|
|
tag value will be filled in.
|
|
|
|
1. _tags_ is a special keyword that outputs all remaining tag values, separated
|
|
|
|
by dots and in alphabetical order (by tag key). These will be filled after all
|
|
|
|
tag keys are filled.
|
|
|
|
1. _measurement_ is a special keyword that outputs the measurement name.
|
|
|
|
1. _field_ is a special keyword that outputs the field name.
|
|
|
|
|
2018-05-21 23:39:33 +00:00
|
|
|
**Example Conversion**:
|
2016-02-12 22:09:34 +00:00
|
|
|
|
|
|
|
```
|
2016-02-12 23:52:33 +00:00
|
|
|
cpu,cpu=cpu-total,dc=us-east-1,host=tars usage_idle=98.09,usage_user=0.89 1455320660004257758
|
2016-02-12 22:09:34 +00:00
|
|
|
=>
|
2016-02-12 23:52:33 +00:00
|
|
|
tars.cpu-total.us-east-1.cpu.usage_user 0.89 1455320690
|
|
|
|
tars.cpu-total.us-east-1.cpu.usage_idle 98.09 1455320690
|
2016-02-12 22:09:34 +00:00
|
|
|
```
|
|
|
|
|
2017-08-29 23:22:03 +00:00
|
|
|
Fields with string values will be skipped. Boolean fields will be converted
|
|
|
|
to 1 (true) or 0 (false).
|
2017-08-29 22:59:38 +00:00
|
|
|
|
2018-05-21 23:39:33 +00:00
|
|
|
#### Graphite Tag Support
|
|
|
|
|
|
|
|
When the `graphite_tag_support` option is enabled, the template pattern is not
|
|
|
|
used. Instead, tags are encoded using
|
|
|
|
[Graphite tag support](http://graphite.readthedocs.io/en/latest/tags.html)
|
|
|
|
added in Graphite 1.1. The `metric_path` is a combination of the optional
|
|
|
|
`prefix` option, measurement name, and field name.
|
|
|
|
|
|
|
|
The tag `name` is reserved by Graphite, any conflicting tags and will be encoded as `_name`.
|
2018-05-21 22:59:56 +00:00
|
|
|
|
2018-05-21 23:39:33 +00:00
|
|
|
**Example Conversion**:
|
2018-05-21 22:59:56 +00:00
|
|
|
```
|
|
|
|
cpu,cpu=cpu-total,dc=us-east-1,host=tars usage_idle=98.09,usage_user=0.89 1455320660004257758
|
|
|
|
=>
|
|
|
|
cpu.usage_user;cpu=cpu-total;dc=us-east-1;host=tars 0.89 1455320690
|
|
|
|
cpu.usage_idle;cpu=cpu-total;dc=us-east-1;host=tars 98.09 1455320690
|
|
|
|
```
|
|
|
|
|
2018-05-05 01:27:31 +00:00
|
|
|
### Graphite Configuration
|
2016-02-12 22:09:34 +00:00
|
|
|
|
|
|
|
```toml
|
|
|
|
[[outputs.file]]
|
2016-02-18 21:26:51 +00:00
|
|
|
## Files to write to, "stdout" is a specially handled file.
|
2016-02-12 22:09:34 +00:00
|
|
|
files = ["stdout", "/tmp/metrics.out"]
|
|
|
|
|
2016-04-08 22:04:45 +00:00
|
|
|
## Data format to output.
|
2017-04-27 21:59:18 +00:00
|
|
|
## Each data format has its own unique set of configuration options, read
|
2016-02-18 21:26:51 +00:00
|
|
|
## more about them here:
|
|
|
|
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
|
2016-04-08 22:04:45 +00:00
|
|
|
data_format = "graphite"
|
2016-02-12 22:09:34 +00:00
|
|
|
|
2018-05-21 23:39:33 +00:00
|
|
|
## Prefix added to each graphite bucket
|
2016-02-12 22:09:34 +00:00
|
|
|
prefix = "telegraf"
|
2018-05-21 23:39:33 +00:00
|
|
|
## Graphite template pattern
|
2016-04-08 22:04:45 +00:00
|
|
|
template = "host.tags.measurement.field"
|
2018-05-21 22:59:56 +00:00
|
|
|
|
2018-05-21 23:39:33 +00:00
|
|
|
## Support Graphite tags, recommended to enable when using Graphite 1.1 or later.
|
|
|
|
# graphite_tag_support = false
|
2016-02-12 22:09:34 +00:00
|
|
|
```
|
2016-03-17 17:50:39 +00:00
|
|
|
|
2018-05-05 01:27:31 +00:00
|
|
|
## JSON
|
2016-03-17 17:50:39 +00:00
|
|
|
|
2018-05-05 01:27:31 +00:00
|
|
|
The JSON output data format output for a single metric is in the
|
|
|
|
form:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"fields": {
|
|
|
|
"field_1": 30,
|
|
|
|
"field_2": 4,
|
|
|
|
"field_N": 59,
|
|
|
|
"n_images": 660
|
|
|
|
},
|
|
|
|
"name": "docker",
|
|
|
|
"tags": {
|
|
|
|
"host": "raynor"
|
|
|
|
},
|
|
|
|
"timestamp": 1458229140
|
|
|
|
}
|
|
|
|
```
|
2016-03-17 17:50:39 +00:00
|
|
|
|
2018-05-05 01:27:31 +00:00
|
|
|
When an output plugin needs to emit multiple metrics at one time, it may use
|
|
|
|
the batch format. The use of batch format is determined by the plugin,
|
|
|
|
reference the documentation for the specific plugin.
|
2016-03-17 17:50:39 +00:00
|
|
|
```json
|
|
|
|
{
|
2018-05-05 01:27:31 +00:00
|
|
|
"metrics": [
|
|
|
|
{
|
|
|
|
"fields": {
|
|
|
|
"field_1": 30,
|
|
|
|
"field_2": 4,
|
|
|
|
"field_N": 59,
|
|
|
|
"n_images": 660
|
|
|
|
},
|
|
|
|
"name": "docker",
|
|
|
|
"tags": {
|
|
|
|
"host": "raynor"
|
|
|
|
},
|
|
|
|
"timestamp": 1458229140
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"fields": {
|
|
|
|
"field_1": 30,
|
|
|
|
"field_2": 4,
|
|
|
|
"field_N": 59,
|
|
|
|
"n_images": 660
|
|
|
|
},
|
|
|
|
"name": "docker",
|
|
|
|
"tags": {
|
|
|
|
"host": "raynor"
|
|
|
|
},
|
|
|
|
"timestamp": 1458229140
|
|
|
|
}
|
|
|
|
]
|
2016-03-17 17:50:39 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2018-05-05 01:27:31 +00:00
|
|
|
### JSON Configuration
|
2016-03-17 17:50:39 +00:00
|
|
|
|
|
|
|
```toml
|
|
|
|
[[outputs.file]]
|
|
|
|
## Files to write to, "stdout" is a specially handled file.
|
|
|
|
files = ["stdout", "/tmp/metrics.out"]
|
|
|
|
|
2016-04-08 22:04:45 +00:00
|
|
|
## Data format to output.
|
2017-04-27 21:59:18 +00:00
|
|
|
## Each data format has its own unique set of configuration options, read
|
2016-03-17 17:50:39 +00:00
|
|
|
## more about them here:
|
|
|
|
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
|
|
|
|
data_format = "json"
|
2017-03-30 00:12:29 +00:00
|
|
|
|
2018-05-05 01:27:31 +00:00
|
|
|
## The resolution to use for the metric timestamp. Must be a duration string
|
|
|
|
## such as "1ns", "1us", "1ms", "10ms", "1s". Durations are truncated to
|
|
|
|
## the power of 10 less than the specified units.
|
|
|
|
json_timestamp_units = "1s"
|
|
|
|
```
|