Merge branch 'master' of https://github.com/influxdata/telegraf into plugin-webhook-particle
This commit is contained in:
commit
d1cbb704cc
119
CHANGELOG.md
119
CHANGELOG.md
|
@ -1,22 +1,5 @@
|
||||||
## v1.0 [unreleased]
|
## v1.0 [unreleased]
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
- [#1413](https://github.com/influxdata/telegraf/issues/1413): Separate container_version from container_image tag.
|
|
||||||
- [#1525](https://github.com/influxdata/telegraf/pull/1525): Support setting per-device and total metrics for Docker network and blockio.
|
|
||||||
- [#1466](https://github.com/influxdata/telegraf/pull/1466): MongoDB input plugin: adding per DB stats from db.stats()
|
|
||||||
|
|
||||||
### Bugfixes
|
|
||||||
|
|
||||||
- [#1519](https://github.com/influxdata/telegraf/pull/1519): Fix error race conditions and partial failures.
|
|
||||||
- [#1477](https://github.com/influxdata/telegraf/issues/1477): nstat: fix inaccurate config panic.
|
|
||||||
- [#1481](https://github.com/influxdata/telegraf/issues/1481): jolokia: fix handling multiple multi-dimensional attributes.
|
|
||||||
- [#1430](https://github.com/influxdata/telegraf/issues/1430): Fix prometheus character sanitizing. Sanitize more win_perf_counters characters.
|
|
||||||
- [#1534](https://github.com/influxdata/telegraf/pull/1534): Add diskio io_time to FreeBSD & report timing metrics as ms (as linux does).
|
|
||||||
- [#1379](https://github.com/influxdata/telegraf/issues/1379): Fix covering Amazon Linux for post remove flow.
|
|
||||||
|
|
||||||
## v1.0 beta 3 [2016-07-18]
|
|
||||||
|
|
||||||
### Release Notes
|
### Release Notes
|
||||||
|
|
||||||
**Breaking Change**: Aerospike main server node measurements have been renamed
|
**Breaking Change**: Aerospike main server node measurements have been renamed
|
||||||
|
@ -49,8 +32,15 @@ should now look like:
|
||||||
path = "/"
|
path = "/"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- `flush_jitter` behavior has been changed. The random jitter will now be
|
||||||
|
evaluated at every flush interval, rather than once at startup. This makes it
|
||||||
|
consistent with the behavior of `collection_jitter`.
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
|
- [#1413](https://github.com/influxdata/telegraf/issues/1413): Separate container_version from container_image tag.
|
||||||
|
- [#1525](https://github.com/influxdata/telegraf/pull/1525): Support setting per-device and total metrics for Docker network and blockio.
|
||||||
|
- [#1466](https://github.com/influxdata/telegraf/pull/1466): MongoDB input plugin: adding per DB stats from db.stats()
|
||||||
- [#1503](https://github.com/influxdata/telegraf/pull/1503): Add tls support for certs to RabbitMQ input plugin
|
- [#1503](https://github.com/influxdata/telegraf/pull/1503): Add tls support for certs to RabbitMQ input plugin
|
||||||
- [#1289](https://github.com/influxdata/telegraf/pull/1289): webhooks input plugin. Thanks @francois2metz and @cduez!
|
- [#1289](https://github.com/influxdata/telegraf/pull/1289): webhooks input plugin. Thanks @francois2metz and @cduez!
|
||||||
- [#1247](https://github.com/influxdata/telegraf/pull/1247): rollbar webhook plugin.
|
- [#1247](https://github.com/influxdata/telegraf/pull/1247): rollbar webhook plugin.
|
||||||
|
@ -65,73 +55,11 @@ should now look like:
|
||||||
- [#1434](https://github.com/influxdata/telegraf/pull/1434): Add measurement name arg to logparser plugin.
|
- [#1434](https://github.com/influxdata/telegraf/pull/1434): Add measurement name arg to logparser plugin.
|
||||||
- [#1479](https://github.com/influxdata/telegraf/pull/1479): logparser: change resp_code from a field to a tag.
|
- [#1479](https://github.com/influxdata/telegraf/pull/1479): logparser: change resp_code from a field to a tag.
|
||||||
- [#1411](https://github.com/influxdata/telegraf/pull/1411): Implement support for fetching hddtemp data
|
- [#1411](https://github.com/influxdata/telegraf/pull/1411): Implement support for fetching hddtemp data
|
||||||
|
|
||||||
### Bugfixes
|
|
||||||
|
|
||||||
- [#1472](https://github.com/influxdata/telegraf/pull/1472): diskio input plugin: set 'skip_serial_number = true' by default to avoid high cardinality.
|
|
||||||
- [#1426](https://github.com/influxdata/telegraf/pull/1426): nil metrics panic fix.
|
|
||||||
- [#1384](https://github.com/influxdata/telegraf/pull/1384): Fix datarace in apache input plugin.
|
|
||||||
- [#1399](https://github.com/influxdata/telegraf/issues/1399): Add `read_repairs` statistics to riak plugin.
|
|
||||||
- [#1405](https://github.com/influxdata/telegraf/issues/1405): Fix memory/connection leak in prometheus input plugin.
|
|
||||||
- [#1378](https://github.com/influxdata/telegraf/issues/1378): Trim BOM from config file for Windows support.
|
|
||||||
- [#1339](https://github.com/influxdata/telegraf/issues/1339): Prometheus client output panic on service reload.
|
|
||||||
- [#1461](https://github.com/influxdata/telegraf/pull/1461): Prometheus parser, protobuf format header fix.
|
|
||||||
- [#1334](https://github.com/influxdata/telegraf/issues/1334): Prometheus output, metric refresh and caching fixes.
|
|
||||||
- [#1432](https://github.com/influxdata/telegraf/issues/1432): Panic fix for multiple graphite outputs under very high load.
|
|
||||||
- [#1412](https://github.com/influxdata/telegraf/pull/1412): Instrumental output has better reconnect behavior
|
|
||||||
- [#1460](https://github.com/influxdata/telegraf/issues/1460): Remove PID from procstat plugin to fix cardinality issues.
|
|
||||||
- [#1427](https://github.com/influxdata/telegraf/issues/1427): Cassandra input: version 2.x "column family" fix.
|
|
||||||
- [#1463](https://github.com/influxdata/telegraf/issues/1463): Shared WaitGroup in Exec plugin
|
|
||||||
- [#1436](https://github.com/influxdata/telegraf/issues/1436): logparser: honor modifiers in "pattern" config.
|
|
||||||
- [#1418](https://github.com/influxdata/telegraf/issues/1418): logparser: error and exit on file permissions/missing errors.
|
|
||||||
- [#1499](https://github.com/influxdata/telegraf/pull/1499): Make the user able to specify full path for HAproxy stats
|
|
||||||
- [#1521](https://github.com/influxdata/telegraf/pull/1521): Fix Redis url, an extra "tcp://" was added.
|
|
||||||
|
|
||||||
## v1.0 beta 2 [2016-06-21]
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
- [#1340](https://github.com/influxdata/telegraf/issues/1340): statsd: do not log every dropped metric.
|
- [#1340](https://github.com/influxdata/telegraf/issues/1340): statsd: do not log every dropped metric.
|
||||||
- [#1368](https://github.com/influxdata/telegraf/pull/1368): Add precision rounding to all metrics on collection.
|
- [#1368](https://github.com/influxdata/telegraf/pull/1368): Add precision rounding to all metrics on collection.
|
||||||
- [#1390](https://github.com/influxdata/telegraf/pull/1390): Add support for Tengine
|
- [#1390](https://github.com/influxdata/telegraf/pull/1390): Add support for Tengine
|
||||||
- [#1320](https://github.com/influxdata/telegraf/pull/1320): Logparser input plugin for parsing grok-style log patterns.
|
- [#1320](https://github.com/influxdata/telegraf/pull/1320): Logparser input plugin for parsing grok-style log patterns.
|
||||||
- [#1397](https://github.com/influxdata/telegraf/issues/1397): ElasticSearch: now supports connecting to ElasticSearch via SSL
|
- [#1397](https://github.com/influxdata/telegraf/issues/1397): ElasticSearch: now supports connecting to ElasticSearch via SSL
|
||||||
|
|
||||||
### Bugfixes
|
|
||||||
|
|
||||||
- [#1330](https://github.com/influxdata/telegraf/issues/1330): Fix exec plugin panic when using single binary.
|
|
||||||
- [#1336](https://github.com/influxdata/telegraf/issues/1336): Fixed incorrect prometheus metrics source selection.
|
|
||||||
- [#1112](https://github.com/influxdata/telegraf/issues/1112): Set default Zookeeper chroot to empty string.
|
|
||||||
- [#1335](https://github.com/influxdata/telegraf/issues/1335): Fix overall ping timeout to be calculated based on per-ping timeout.
|
|
||||||
- [#1374](https://github.com/influxdata/telegraf/pull/1374): Change "default" retention policy to "".
|
|
||||||
- [#1377](https://github.com/influxdata/telegraf/issues/1377): Graphite output mangling '%' character.
|
|
||||||
- [#1396](https://github.com/influxdata/telegraf/pull/1396): Prometheus input plugin now supports x509 certs authentication
|
|
||||||
|
|
||||||
## v1.0 beta 1 [2016-06-07]
|
|
||||||
|
|
||||||
### Release Notes
|
|
||||||
|
|
||||||
- `flush_jitter` behavior has been changed. The random jitter will now be
|
|
||||||
evaluated at every flush interval, rather than once at startup. This makes it
|
|
||||||
consistent with the behavior of `collection_jitter`.
|
|
||||||
|
|
||||||
- All AWS plugins now utilize a standard mechanism for evaluating credentials.
|
|
||||||
This allows all AWS plugins to support environment variables, shared credential
|
|
||||||
files & profiles, and role assumptions. See the specific plugin README for
|
|
||||||
details.
|
|
||||||
|
|
||||||
- The AWS CloudWatch input plugin can now declare a wildcard value for a metric
|
|
||||||
dimension. This causes the plugin to read all metrics that contain the specified
|
|
||||||
dimension key regardless of value. This is used to export collections of metrics
|
|
||||||
without having to know the dimension values ahead of time.
|
|
||||||
|
|
||||||
- The AWS CloudWatch input plugin can now be configured with the `cache_ttl`
|
|
||||||
attribute. This configures the TTL of the internal metric cache. This is useful
|
|
||||||
in conjunction with wildcard dimension values as it will control the amount of
|
|
||||||
time before a new metric is included by the plugin.
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
- [#1262](https://github.com/influxdata/telegraf/pull/1261): Add graylog input pluging.
|
- [#1262](https://github.com/influxdata/telegraf/pull/1261): Add graylog input pluging.
|
||||||
- [#1294](https://github.com/influxdata/telegraf/pull/1294): consul input plugin. Thanks @harnash
|
- [#1294](https://github.com/influxdata/telegraf/pull/1294): consul input plugin. Thanks @harnash
|
||||||
- [#1164](https://github.com/influxdata/telegraf/pull/1164): conntrack input plugin. Thanks @robinpercy!
|
- [#1164](https://github.com/influxdata/telegraf/pull/1164): conntrack input plugin. Thanks @robinpercy!
|
||||||
|
@ -150,6 +78,38 @@ time before a new metric is included by the plugin.
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
||||||
|
- [#1519](https://github.com/influxdata/telegraf/pull/1519): Fix error race conditions and partial failures.
|
||||||
|
- [#1477](https://github.com/influxdata/telegraf/issues/1477): nstat: fix inaccurate config panic.
|
||||||
|
- [#1481](https://github.com/influxdata/telegraf/issues/1481): jolokia: fix handling multiple multi-dimensional attributes.
|
||||||
|
- [#1430](https://github.com/influxdata/telegraf/issues/1430): Fix prometheus character sanitizing. Sanitize more win_perf_counters characters.
|
||||||
|
- [#1534](https://github.com/influxdata/telegraf/pull/1534): Add diskio io_time to FreeBSD & report timing metrics as ms (as linux does).
|
||||||
|
- [#1379](https://github.com/influxdata/telegraf/issues/1379): Fix covering Amazon Linux for post remove flow.
|
||||||
|
- [#1584](https://github.com/influxdata/telegraf/issues/1584): procstat missing fields: read/write bytes & count
|
||||||
|
- [#1472](https://github.com/influxdata/telegraf/pull/1472): diskio input plugin: set 'skip_serial_number = true' by default to avoid high cardinality.
|
||||||
|
- [#1426](https://github.com/influxdata/telegraf/pull/1426): nil metrics panic fix.
|
||||||
|
- [#1384](https://github.com/influxdata/telegraf/pull/1384): Fix datarace in apache input plugin.
|
||||||
|
- [#1399](https://github.com/influxdata/telegraf/issues/1399): Add `read_repairs` statistics to riak plugin.
|
||||||
|
- [#1405](https://github.com/influxdata/telegraf/issues/1405): Fix memory/connection leak in prometheus input plugin.
|
||||||
|
- [#1378](https://github.com/influxdata/telegraf/issues/1378): Trim BOM from config file for Windows support.
|
||||||
|
- [#1339](https://github.com/influxdata/telegraf/issues/1339): Prometheus client output panic on service reload.
|
||||||
|
- [#1461](https://github.com/influxdata/telegraf/pull/1461): Prometheus parser, protobuf format header fix.
|
||||||
|
- [#1334](https://github.com/influxdata/telegraf/issues/1334): Prometheus output, metric refresh and caching fixes.
|
||||||
|
- [#1432](https://github.com/influxdata/telegraf/issues/1432): Panic fix for multiple graphite outputs under very high load.
|
||||||
|
- [#1412](https://github.com/influxdata/telegraf/pull/1412): Instrumental output has better reconnect behavior
|
||||||
|
- [#1460](https://github.com/influxdata/telegraf/issues/1460): Remove PID from procstat plugin to fix cardinality issues.
|
||||||
|
- [#1427](https://github.com/influxdata/telegraf/issues/1427): Cassandra input: version 2.x "column family" fix.
|
||||||
|
- [#1463](https://github.com/influxdata/telegraf/issues/1463): Shared WaitGroup in Exec plugin
|
||||||
|
- [#1436](https://github.com/influxdata/telegraf/issues/1436): logparser: honor modifiers in "pattern" config.
|
||||||
|
- [#1418](https://github.com/influxdata/telegraf/issues/1418): logparser: error and exit on file permissions/missing errors.
|
||||||
|
- [#1499](https://github.com/influxdata/telegraf/pull/1499): Make the user able to specify full path for HAproxy stats
|
||||||
|
- [#1521](https://github.com/influxdata/telegraf/pull/1521): Fix Redis url, an extra "tcp://" was added.
|
||||||
|
- [#1330](https://github.com/influxdata/telegraf/issues/1330): Fix exec plugin panic when using single binary.
|
||||||
|
- [#1336](https://github.com/influxdata/telegraf/issues/1336): Fixed incorrect prometheus metrics source selection.
|
||||||
|
- [#1112](https://github.com/influxdata/telegraf/issues/1112): Set default Zookeeper chroot to empty string.
|
||||||
|
- [#1335](https://github.com/influxdata/telegraf/issues/1335): Fix overall ping timeout to be calculated based on per-ping timeout.
|
||||||
|
- [#1374](https://github.com/influxdata/telegraf/pull/1374): Change "default" retention policy to "".
|
||||||
|
- [#1377](https://github.com/influxdata/telegraf/issues/1377): Graphite output mangling '%' character.
|
||||||
|
- [#1396](https://github.com/influxdata/telegraf/pull/1396): Prometheus input plugin now supports x509 certs authentication
|
||||||
- [#1252](https://github.com/influxdata/telegraf/pull/1252) & [#1279](https://github.com/influxdata/telegraf/pull/1279): Fix systemd service. Thanks @zbindenren & @PierreF!
|
- [#1252](https://github.com/influxdata/telegraf/pull/1252) & [#1279](https://github.com/influxdata/telegraf/pull/1279): Fix systemd service. Thanks @zbindenren & @PierreF!
|
||||||
- [#1221](https://github.com/influxdata/telegraf/pull/1221): Fix influxdb n_shards counter.
|
- [#1221](https://github.com/influxdata/telegraf/pull/1221): Fix influxdb n_shards counter.
|
||||||
- [#1258](https://github.com/influxdata/telegraf/pull/1258): Fix potential kernel plugin integer parse error.
|
- [#1258](https://github.com/influxdata/telegraf/pull/1258): Fix potential kernel plugin integer parse error.
|
||||||
|
@ -159,6 +119,7 @@ time before a new metric is included by the plugin.
|
||||||
- [#1316](https://github.com/influxdata/telegraf/pull/1316): Removed leaked "database" tag on redis metrics. Thanks @PierreF!
|
- [#1316](https://github.com/influxdata/telegraf/pull/1316): Removed leaked "database" tag on redis metrics. Thanks @PierreF!
|
||||||
- [#1323](https://github.com/influxdata/telegraf/issues/1323): Processes plugin: fix potential error with /proc/net/stat directory.
|
- [#1323](https://github.com/influxdata/telegraf/issues/1323): Processes plugin: fix potential error with /proc/net/stat directory.
|
||||||
- [#1322](https://github.com/influxdata/telegraf/issues/1322): Fix rare RHEL 5.2 panic in gopsutil diskio gathering function.
|
- [#1322](https://github.com/influxdata/telegraf/issues/1322): Fix rare RHEL 5.2 panic in gopsutil diskio gathering function.
|
||||||
|
- [#1586](https://github.com/influxdata/telegraf/pull/1586): Remove IF NOT EXISTS from influxdb output database creation.
|
||||||
|
|
||||||
## v0.13.1 [2016-05-24]
|
## v0.13.1 [2016-05-24]
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ Output plugins READMEs are less structured,
|
||||||
but any information you can provide on how the data will look is appreciated.
|
but any information you can provide on how the data will look is appreciated.
|
||||||
See the [OpenTSDB output](https://github.com/influxdata/telegraf/tree/master/plugins/outputs/opentsdb)
|
See the [OpenTSDB output](https://github.com/influxdata/telegraf/tree/master/plugins/outputs/opentsdb)
|
||||||
for a good example.
|
for a good example.
|
||||||
|
1. **Optional:** Write a [tickscript](https://docs.influxdata.com/kapacitor/v1.0/tick/syntax/) for your plugin and add it to [Kapacitor](https://github.com/influxdata/kapacitor/tree/master/examples/telegraf). Or mention @jackzampolin in a PR comment with some common queries that you would want to alert on and he will write one for you.
|
||||||
|
|
||||||
## GoDoc
|
## GoDoc
|
||||||
|
|
||||||
|
|
2
Godeps
2
Godeps
|
@ -45,7 +45,7 @@ github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6
|
||||||
github.com/prometheus/common e8eabff8812b05acf522b45fdcd725a785188e37
|
github.com/prometheus/common e8eabff8812b05acf522b45fdcd725a785188e37
|
||||||
github.com/prometheus/procfs 406e5b7bfd8201a36e2bb5f7bdae0b03380c2ce8
|
github.com/prometheus/procfs 406e5b7bfd8201a36e2bb5f7bdae0b03380c2ce8
|
||||||
github.com/samuel/go-zookeeper 218e9c81c0dd8b3b18172b2bbfad92cc7d6db55f
|
github.com/samuel/go-zookeeper 218e9c81c0dd8b3b18172b2bbfad92cc7d6db55f
|
||||||
github.com/shirou/gopsutil ee66bc560c366dd33b9a4046ba0b644caba46bed
|
github.com/shirou/gopsutil 4d0c402af66c78735c5ccf820dc2ca7de5e4ff08
|
||||||
github.com/soniah/gosnmp b1b4f885b12c5dcbd021c5cee1c904110de6db7d
|
github.com/soniah/gosnmp b1b4f885b12c5dcbd021c5cee1c904110de6db7d
|
||||||
github.com/sparrc/aerospike-client-go d4bb42d2c2d39dae68e054116f4538af189e05d5
|
github.com/sparrc/aerospike-client-go d4bb42d2c2d39dae68e054116f4538af189e05d5
|
||||||
github.com/streadway/amqp b4f3ceab0337f013208d31348b578d83c0064744
|
github.com/streadway/amqp b4f3ceab0337f013208d31348b578d83c0064744
|
||||||
|
|
|
@ -39,12 +39,6 @@ var fOutputList = flag.Bool("output-list", false,
|
||||||
"print available output plugins.")
|
"print available output plugins.")
|
||||||
var fUsage = flag.String("usage", "",
|
var fUsage = flag.String("usage", "",
|
||||||
"print usage for a plugin, ie, 'telegraf -usage mysql'")
|
"print usage for a plugin, ie, 'telegraf -usage mysql'")
|
||||||
var fInputFiltersLegacy = flag.String("filter", "",
|
|
||||||
"filter the inputs to enable, separator is :")
|
|
||||||
var fOutputFiltersLegacy = flag.String("outputfilter", "",
|
|
||||||
"filter the outputs to enable, separator is :")
|
|
||||||
var fConfigDirectoryLegacy = flag.String("configdirectory", "",
|
|
||||||
"directory containing additional *.conf files")
|
|
||||||
|
|
||||||
// Telegraf version, populated linker.
|
// Telegraf version, populated linker.
|
||||||
// ie, -ldflags "-X main.version=`git describe --always --tags`"
|
// ie, -ldflags "-X main.version=`git describe --always --tags`"
|
||||||
|
@ -110,24 +104,11 @@ func main() {
|
||||||
args := flag.Args()
|
args := flag.Args()
|
||||||
|
|
||||||
var inputFilters []string
|
var inputFilters []string
|
||||||
if *fInputFiltersLegacy != "" {
|
|
||||||
fmt.Printf("WARNING '--filter' flag is deprecated, please use" +
|
|
||||||
" '--input-filter'")
|
|
||||||
inputFilter := strings.TrimSpace(*fInputFiltersLegacy)
|
|
||||||
inputFilters = strings.Split(":"+inputFilter+":", ":")
|
|
||||||
}
|
|
||||||
if *fInputFilters != "" {
|
if *fInputFilters != "" {
|
||||||
inputFilter := strings.TrimSpace(*fInputFilters)
|
inputFilter := strings.TrimSpace(*fInputFilters)
|
||||||
inputFilters = strings.Split(":"+inputFilter+":", ":")
|
inputFilters = strings.Split(":"+inputFilter+":", ":")
|
||||||
}
|
}
|
||||||
|
|
||||||
var outputFilters []string
|
var outputFilters []string
|
||||||
if *fOutputFiltersLegacy != "" {
|
|
||||||
fmt.Printf("WARNING '--outputfilter' flag is deprecated, please use" +
|
|
||||||
" '--output-filter'")
|
|
||||||
outputFilter := strings.TrimSpace(*fOutputFiltersLegacy)
|
|
||||||
outputFilters = strings.Split(":"+outputFilter+":", ":")
|
|
||||||
}
|
|
||||||
if *fOutputFilters != "" {
|
if *fOutputFilters != "" {
|
||||||
outputFilter := strings.TrimSpace(*fOutputFilters)
|
outputFilter := strings.TrimSpace(*fOutputFilters)
|
||||||
outputFilters = strings.Split(":"+outputFilter+":", ":")
|
outputFilters = strings.Split(":"+outputFilter+":", ":")
|
||||||
|
@ -145,34 +126,28 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if *fOutputList {
|
// switch for flags which just do something and exit immediately
|
||||||
|
switch {
|
||||||
|
case *fOutputList:
|
||||||
fmt.Println("Available Output Plugins:")
|
fmt.Println("Available Output Plugins:")
|
||||||
for k, _ := range outputs.Outputs {
|
for k, _ := range outputs.Outputs {
|
||||||
fmt.Printf(" %s\n", k)
|
fmt.Printf(" %s\n", k)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
case *fInputList:
|
||||||
|
|
||||||
if *fInputList {
|
|
||||||
fmt.Println("Available Input Plugins:")
|
fmt.Println("Available Input Plugins:")
|
||||||
for k, _ := range inputs.Inputs {
|
for k, _ := range inputs.Inputs {
|
||||||
fmt.Printf(" %s\n", k)
|
fmt.Printf(" %s\n", k)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
case *fVersion:
|
||||||
|
|
||||||
if *fVersion {
|
|
||||||
v := fmt.Sprintf("Telegraf - version %s", version)
|
v := fmt.Sprintf("Telegraf - version %s", version)
|
||||||
fmt.Println(v)
|
fmt.Println(v)
|
||||||
return
|
return
|
||||||
}
|
case *fSampleConfig:
|
||||||
|
|
||||||
if *fSampleConfig {
|
|
||||||
config.PrintSampleConfig(inputFilters, outputFilters)
|
config.PrintSampleConfig(inputFilters, outputFilters)
|
||||||
return
|
return
|
||||||
}
|
case *fUsage != "":
|
||||||
|
|
||||||
if *fUsage != "" {
|
|
||||||
if err := config.PrintInputConfig(*fUsage); err != nil {
|
if err := config.PrintInputConfig(*fUsage); err != nil {
|
||||||
if err2 := config.PrintOutputConfig(*fUsage); err2 != nil {
|
if err2 := config.PrintOutputConfig(*fUsage); err2 != nil {
|
||||||
log.Fatalf("%s and %s", err, err2)
|
log.Fatalf("%s and %s", err, err2)
|
||||||
|
@ -191,15 +166,6 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *fConfigDirectoryLegacy != "" {
|
|
||||||
fmt.Printf("WARNING '--configdirectory' flag is deprecated, please use" +
|
|
||||||
" '--config-directory'")
|
|
||||||
err = c.LoadDirectory(*fConfigDirectoryLegacy)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if *fConfigDirectory != "" {
|
if *fConfigDirectory != "" {
|
||||||
err = c.LoadDirectory(*fConfigDirectory)
|
err = c.LoadDirectory(*fConfigDirectory)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
## By default, precision will be set to the same timestamp order as the
|
## By default, precision will be set to the same timestamp order as the
|
||||||
## collection interval, with the maximum being 1s.
|
## collection interval, with the maximum being 1s.
|
||||||
## Precision will NOT be used for service inputs, such as logparser and statsd.
|
## Precision will NOT be used for service inputs, such as logparser and statsd.
|
||||||
## Valid values are "Nns", "Nus" (or "Nµs"), "Nms", "Ns".
|
## Valid values are "ns", "us" (or "µs"), "ms", "s".
|
||||||
precision = ""
|
precision = ""
|
||||||
## Run telegraf in debug mode
|
## Run telegraf in debug mode
|
||||||
debug = false
|
debug = false
|
||||||
|
@ -1577,7 +1577,7 @@
|
||||||
# ## /var/log/**.log -> recursively find all .log files in /var/log
|
# ## /var/log/**.log -> recursively find all .log files in /var/log
|
||||||
# ## /var/log/*/*.log -> find all .log files with a parent dir in /var/log
|
# ## /var/log/*/*.log -> find all .log files with a parent dir in /var/log
|
||||||
# ## /var/log/apache.log -> only tail the apache log file
|
# ## /var/log/apache.log -> only tail the apache log file
|
||||||
# files = ["/var/log/influxdb/influxdb.log"]
|
# files = ["/var/log/apache/access.log"]
|
||||||
# ## Read file from beginning.
|
# ## Read file from beginning.
|
||||||
# from_beginning = false
|
# from_beginning = false
|
||||||
#
|
#
|
||||||
|
@ -1590,9 +1590,9 @@
|
||||||
# ## Other common built-in patterns are:
|
# ## Other common built-in patterns are:
|
||||||
# ## %{COMMON_LOG_FORMAT} (plain apache & nginx access logs)
|
# ## %{COMMON_LOG_FORMAT} (plain apache & nginx access logs)
|
||||||
# ## %{COMBINED_LOG_FORMAT} (access logs + referrer & agent)
|
# ## %{COMBINED_LOG_FORMAT} (access logs + referrer & agent)
|
||||||
# patterns = ["%{INFLUXDB_HTTPD_LOG}"]
|
# patterns = ["%{COMBINED_LOG_FORMAT}"]
|
||||||
# ## Name of the outputted measurement name.
|
# ## Name of the outputted measurement name.
|
||||||
# measurement = "influxdb_log"
|
# measurement = "apache_access_log"
|
||||||
# ## Full path(s) to custom pattern files.
|
# ## Full path(s) to custom pattern files.
|
||||||
# custom_pattern_files = []
|
# custom_pattern_files = []
|
||||||
# ## Custom patterns can also be defined here. Put one pattern per line.
|
# ## Custom patterns can also be defined here. Put one pattern per line.
|
||||||
|
|
|
@ -219,7 +219,7 @@ var header = `# Telegraf Configuration
|
||||||
## By default, precision will be set to the same timestamp order as the
|
## By default, precision will be set to the same timestamp order as the
|
||||||
## collection interval, with the maximum being 1s.
|
## collection interval, with the maximum being 1s.
|
||||||
## Precision will NOT be used for service inputs, such as logparser and statsd.
|
## Precision will NOT be used for service inputs, such as logparser and statsd.
|
||||||
## Valid values are "Nns", "Nus" (or "Nµs"), "Nms", "Ns".
|
## Valid values are "ns", "us" (or "µs"), "ms", "s".
|
||||||
precision = ""
|
precision = ""
|
||||||
## Run telegraf in debug mode
|
## Run telegraf in debug mode
|
||||||
debug = false
|
debug = false
|
||||||
|
|
|
@ -14,17 +14,22 @@ regex patterns.
|
||||||
## /var/log/**.log -> recursively find all .log files in /var/log
|
## /var/log/**.log -> recursively find all .log files in /var/log
|
||||||
## /var/log/*/*.log -> find all .log files with a parent dir in /var/log
|
## /var/log/*/*.log -> find all .log files with a parent dir in /var/log
|
||||||
## /var/log/apache.log -> only tail the apache log file
|
## /var/log/apache.log -> only tail the apache log file
|
||||||
files = ["/var/log/influxdb/influxdb.log"]
|
files = ["/var/log/apache/access.log"]
|
||||||
## Read file from beginning.
|
## Read file from beginning.
|
||||||
from_beginning = false
|
from_beginning = false
|
||||||
|
|
||||||
## Parse logstash-style "grok" patterns:
|
## Parse logstash-style "grok" patterns:
|
||||||
## Telegraf builtin parsing patterns: https://goo.gl/dkay10
|
## Telegraf built-in parsing patterns: https://goo.gl/dkay10
|
||||||
[inputs.logparser.grok]
|
[inputs.logparser.grok]
|
||||||
## This is a list of patterns to check the given log file(s) for.
|
## This is a list of patterns to check the given log file(s) for.
|
||||||
## Note that adding patterns here increases processing time. The most
|
## Note that adding patterns here increases processing time. The most
|
||||||
## efficient configuration is to have one file & pattern per logparser.
|
## efficient configuration is to have one pattern per logparser.
|
||||||
patterns = ["%{INFLUXDB_HTTPD_LOG}"]
|
## Other common built-in patterns are:
|
||||||
|
## %{COMMON_LOG_FORMAT} (plain apache & nginx access logs)
|
||||||
|
## %{COMBINED_LOG_FORMAT} (access logs + referrer & agent)
|
||||||
|
patterns = ["%{COMBINED_LOG_FORMAT}"]
|
||||||
|
## Name of the outputted measurement name.
|
||||||
|
measurement = "apache_access_log"
|
||||||
## Full path(s) to custom pattern files.
|
## Full path(s) to custom pattern files.
|
||||||
custom_pattern_files = []
|
custom_pattern_files = []
|
||||||
## Custom patterns can also be defined here. Put one pattern per line.
|
## Custom patterns can also be defined here. Put one pattern per line.
|
||||||
|
@ -32,8 +37,6 @@ regex patterns.
|
||||||
'''
|
'''
|
||||||
```
|
```
|
||||||
|
|
||||||
> **Note:** The InfluxDB log pattern in the default configuration only works for Influx versions 1.0.0-beta1 or higher.
|
|
||||||
|
|
||||||
## Grok Parser
|
## Grok Parser
|
||||||
|
|
||||||
The grok parser uses a slightly modified version of logstash "grok" patterns,
|
The grok parser uses a slightly modified version of logstash "grok" patterns,
|
||||||
|
@ -69,6 +72,7 @@ Timestamp modifiers can be used to convert captures to the timestamp of the
|
||||||
- tag (converts the field into a tag)
|
- tag (converts the field into a tag)
|
||||||
- drop (drops the field completely)
|
- drop (drops the field completely)
|
||||||
- Timestamp modifiers:
|
- Timestamp modifiers:
|
||||||
|
- ts (This will auto-learn the timestamp format)
|
||||||
- ts-ansic ("Mon Jan _2 15:04:05 2006")
|
- ts-ansic ("Mon Jan _2 15:04:05 2006")
|
||||||
- ts-unix ("Mon Jan _2 15:04:05 MST 2006")
|
- ts-unix ("Mon Jan _2 15:04:05 MST 2006")
|
||||||
- ts-ruby ("Mon Jan 02 15:04:05 -0700 2006")
|
- ts-ruby ("Mon Jan 02 15:04:05 -0700 2006")
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
)
|
)
|
||||||
|
|
||||||
var timeFormats = map[string]string{
|
var timeLayouts = map[string]string{
|
||||||
"ts-ansic": "Mon Jan _2 15:04:05 2006",
|
"ts-ansic": "Mon Jan _2 15:04:05 2006",
|
||||||
"ts-unix": "Mon Jan _2 15:04:05 MST 2006",
|
"ts-unix": "Mon Jan _2 15:04:05 MST 2006",
|
||||||
"ts-ruby": "Mon Jan 02 15:04:05 -0700 2006",
|
"ts-ruby": "Mon Jan 02 15:04:05 -0700 2006",
|
||||||
|
@ -27,27 +27,33 @@ var timeFormats = map[string]string{
|
||||||
"ts-rfc3339": "2006-01-02T15:04:05Z07:00",
|
"ts-rfc3339": "2006-01-02T15:04:05Z07:00",
|
||||||
"ts-rfc3339nano": "2006-01-02T15:04:05.999999999Z07:00",
|
"ts-rfc3339nano": "2006-01-02T15:04:05.999999999Z07:00",
|
||||||
"ts-httpd": "02/Jan/2006:15:04:05 -0700",
|
"ts-httpd": "02/Jan/2006:15:04:05 -0700",
|
||||||
"ts-epoch": "EPOCH",
|
// These three are not exactly "layouts", but they are special cases that
|
||||||
"ts-epochnano": "EPOCH_NANO",
|
// will get handled in the ParseLine function.
|
||||||
|
"ts-epoch": "EPOCH",
|
||||||
|
"ts-epochnano": "EPOCH_NANO",
|
||||||
|
"ts": "GENERIC_TIMESTAMP", // try parsing all known timestamp layouts.
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
INT = "int"
|
INT = "int"
|
||||||
TAG = "tag"
|
TAG = "tag"
|
||||||
FLOAT = "float"
|
FLOAT = "float"
|
||||||
STRING = "string"
|
STRING = "string"
|
||||||
DURATION = "duration"
|
DURATION = "duration"
|
||||||
DROP = "drop"
|
DROP = "drop"
|
||||||
|
EPOCH = "EPOCH"
|
||||||
|
EPOCH_NANO = "EPOCH_NANO"
|
||||||
|
GENERIC_TIMESTAMP = "GENERIC_TIMESTAMP"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// matches named captures that contain a type.
|
// matches named captures that contain a modifier.
|
||||||
// ie,
|
// ie,
|
||||||
// %{NUMBER:bytes:int}
|
// %{NUMBER:bytes:int}
|
||||||
// %{IPORHOST:clientip:tag}
|
// %{IPORHOST:clientip:tag}
|
||||||
// %{HTTPDATE:ts1:ts-http}
|
// %{HTTPDATE:ts1:ts-http}
|
||||||
// %{HTTPDATE:ts2:ts-"02 Jan 06 15:04"}
|
// %{HTTPDATE:ts2:ts-"02 Jan 06 15:04"}
|
||||||
typedRe = regexp.MustCompile(`%{\w+:(\w+):(ts-".+"|t?s?-?\w+)}`)
|
modifierRe = regexp.MustCompile(`%{\w+:(\w+):(ts-".+"|t?s?-?\w+)}`)
|
||||||
// matches a plain pattern name. ie, %{NUMBER}
|
// matches a plain pattern name. ie, %{NUMBER}
|
||||||
patternOnlyRe = regexp.MustCompile(`%{(\w+)}`)
|
patternOnlyRe = regexp.MustCompile(`%{(\w+)}`)
|
||||||
)
|
)
|
||||||
|
@ -87,6 +93,12 @@ type Parser struct {
|
||||||
// "RESPONSE_CODE": "%{NUMBER:rc:tag}"
|
// "RESPONSE_CODE": "%{NUMBER:rc:tag}"
|
||||||
// }
|
// }
|
||||||
patterns map[string]string
|
patterns map[string]string
|
||||||
|
// foundTsLayouts is a slice of timestamp patterns that have been found
|
||||||
|
// in the log lines. This slice gets updated if the user uses the generic
|
||||||
|
// 'ts' modifier for timestamps. This slice is checked first for matches,
|
||||||
|
// so that previously-matched layouts get priority over all other timestamp
|
||||||
|
// layouts.
|
||||||
|
foundTsLayouts []string
|
||||||
|
|
||||||
g *grok.Grok
|
g *grok.Grok
|
||||||
tsModder *tsModder
|
tsModder *tsModder
|
||||||
|
@ -140,6 +152,7 @@ func (p *Parser) Compile() error {
|
||||||
|
|
||||||
func (p *Parser) ParseLine(line string) (telegraf.Metric, error) {
|
func (p *Parser) ParseLine(line string) (telegraf.Metric, error) {
|
||||||
var err error
|
var err error
|
||||||
|
// values are the parsed fields from the log line
|
||||||
var values map[string]string
|
var values map[string]string
|
||||||
// the matching pattern string
|
// the matching pattern string
|
||||||
var patternName string
|
var patternName string
|
||||||
|
@ -165,6 +178,7 @@ func (p *Parser) ParseLine(line string) (telegraf.Metric, error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// t is the modifier of the field
|
||||||
var t string
|
var t string
|
||||||
// check if pattern has some modifiers
|
// check if pattern has some modifiers
|
||||||
if types, ok := p.typeMap[patternName]; ok {
|
if types, ok := p.typeMap[patternName]; ok {
|
||||||
|
@ -210,20 +224,50 @@ func (p *Parser) ParseLine(line string) (telegraf.Metric, error) {
|
||||||
tags[k] = v
|
tags[k] = v
|
||||||
case STRING:
|
case STRING:
|
||||||
fields[k] = strings.Trim(v, `"`)
|
fields[k] = strings.Trim(v, `"`)
|
||||||
case "EPOCH":
|
case EPOCH:
|
||||||
iv, err := strconv.ParseInt(v, 10, 64)
|
iv, err := strconv.ParseInt(v, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("ERROR parsing %s to int: %s", v, err)
|
log.Printf("ERROR parsing %s to int: %s", v, err)
|
||||||
} else {
|
} else {
|
||||||
timestamp = time.Unix(iv, 0)
|
timestamp = time.Unix(iv, 0)
|
||||||
}
|
}
|
||||||
case "EPOCH_NANO":
|
case EPOCH_NANO:
|
||||||
iv, err := strconv.ParseInt(v, 10, 64)
|
iv, err := strconv.ParseInt(v, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("ERROR parsing %s to int: %s", v, err)
|
log.Printf("ERROR parsing %s to int: %s", v, err)
|
||||||
} else {
|
} else {
|
||||||
timestamp = time.Unix(0, iv)
|
timestamp = time.Unix(0, iv)
|
||||||
}
|
}
|
||||||
|
case GENERIC_TIMESTAMP:
|
||||||
|
var foundTs bool
|
||||||
|
// first try timestamp layouts that we've already found
|
||||||
|
for _, layout := range p.foundTsLayouts {
|
||||||
|
ts, err := time.Parse(layout, v)
|
||||||
|
if err == nil {
|
||||||
|
timestamp = ts
|
||||||
|
foundTs = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if we haven't found a timestamp layout yet, try all timestamp
|
||||||
|
// layouts.
|
||||||
|
if !foundTs {
|
||||||
|
for _, layout := range timeLayouts {
|
||||||
|
ts, err := time.Parse(layout, v)
|
||||||
|
if err == nil {
|
||||||
|
timestamp = ts
|
||||||
|
foundTs = true
|
||||||
|
p.foundTsLayouts = append(p.foundTsLayouts, layout)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if we still haven't found a timestamp layout, log it and we will
|
||||||
|
// just use time.Now()
|
||||||
|
if !foundTs {
|
||||||
|
log.Printf("ERROR parsing timestamp [%s], could not find any "+
|
||||||
|
"suitable time layouts.", v)
|
||||||
|
}
|
||||||
case DROP:
|
case DROP:
|
||||||
// goodbye!
|
// goodbye!
|
||||||
default:
|
default:
|
||||||
|
@ -267,7 +311,7 @@ func (p *Parser) compileCustomPatterns() error {
|
||||||
|
|
||||||
// check if pattern contains modifiers. Parse them out if it does.
|
// check if pattern contains modifiers. Parse them out if it does.
|
||||||
for name, pattern := range p.patterns {
|
for name, pattern := range p.patterns {
|
||||||
if typedRe.MatchString(pattern) {
|
if modifierRe.MatchString(pattern) {
|
||||||
// this pattern has modifiers, so parse out the modifiers
|
// this pattern has modifiers, so parse out the modifiers
|
||||||
pattern, err = p.parseTypedCaptures(name, pattern)
|
pattern, err = p.parseTypedCaptures(name, pattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -280,13 +324,13 @@ func (p *Parser) compileCustomPatterns() error {
|
||||||
return p.g.AddPatternsFromMap(p.patterns)
|
return p.g.AddPatternsFromMap(p.patterns)
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseTypedCaptures parses the capture types, and then deletes the type from
|
// parseTypedCaptures parses the capture modifiers, and then deletes the
|
||||||
// the line so that it is a valid "grok" pattern again.
|
// modifier from the line so that it is a valid "grok" pattern again.
|
||||||
// ie,
|
// ie,
|
||||||
// %{NUMBER:bytes:int} => %{NUMBER:bytes} (stores %{NUMBER}->bytes->int)
|
// %{NUMBER:bytes:int} => %{NUMBER:bytes} (stores %{NUMBER}->bytes->int)
|
||||||
// %{IPORHOST:clientip:tag} => %{IPORHOST:clientip} (stores %{IPORHOST}->clientip->tag)
|
// %{IPORHOST:clientip:tag} => %{IPORHOST:clientip} (stores %{IPORHOST}->clientip->tag)
|
||||||
func (p *Parser) parseTypedCaptures(name, pattern string) (string, error) {
|
func (p *Parser) parseTypedCaptures(name, pattern string) (string, error) {
|
||||||
matches := typedRe.FindAllStringSubmatch(pattern, -1)
|
matches := modifierRe.FindAllStringSubmatch(pattern, -1)
|
||||||
|
|
||||||
// grab the name of the capture pattern
|
// grab the name of the capture pattern
|
||||||
patternName := "%{" + name + "}"
|
patternName := "%{" + name + "}"
|
||||||
|
@ -298,16 +342,18 @@ func (p *Parser) parseTypedCaptures(name, pattern string) (string, error) {
|
||||||
hasTimestamp := false
|
hasTimestamp := false
|
||||||
for _, match := range matches {
|
for _, match := range matches {
|
||||||
// regex capture 1 is the name of the capture
|
// regex capture 1 is the name of the capture
|
||||||
// regex capture 2 is the type of the capture
|
// regex capture 2 is the modifier of the capture
|
||||||
if strings.HasPrefix(match[2], "ts-") {
|
if strings.HasPrefix(match[2], "ts") {
|
||||||
if hasTimestamp {
|
if hasTimestamp {
|
||||||
return pattern, fmt.Errorf("logparser pattern compile error: "+
|
return pattern, fmt.Errorf("logparser pattern compile error: "+
|
||||||
"Each pattern is allowed only one named "+
|
"Each pattern is allowed only one named "+
|
||||||
"timestamp data type. pattern: %s", pattern)
|
"timestamp data type. pattern: %s", pattern)
|
||||||
}
|
}
|
||||||
if f, ok := timeFormats[match[2]]; ok {
|
if layout, ok := timeLayouts[match[2]]; ok {
|
||||||
p.tsMap[patternName][match[1]] = f
|
// built-in time format
|
||||||
|
p.tsMap[patternName][match[1]] = layout
|
||||||
} else {
|
} else {
|
||||||
|
// custom time format
|
||||||
p.tsMap[patternName][match[1]] = strings.TrimSuffix(strings.TrimPrefix(match[2], `ts-"`), `"`)
|
p.tsMap[patternName][match[1]] = strings.TrimSuffix(strings.TrimPrefix(match[2], `ts-"`), `"`)
|
||||||
}
|
}
|
||||||
hasTimestamp = true
|
hasTimestamp = true
|
||||||
|
|
|
@ -38,32 +38,6 @@ func Benchmark_ParseLine_CombinedLogFormat(b *testing.B) {
|
||||||
benchM = m
|
benchM = m
|
||||||
}
|
}
|
||||||
|
|
||||||
func Benchmark_ParseLine_InfluxLog(b *testing.B) {
|
|
||||||
p := &Parser{
|
|
||||||
Patterns: []string{"%{INFLUXDB_HTTPD_LOG}"},
|
|
||||||
}
|
|
||||||
p.Compile()
|
|
||||||
|
|
||||||
var m telegraf.Metric
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
m, _ = p.ParseLine(`[httpd] 192.168.1.1 - - [14/Jun/2016:11:33:29 +0100] "POST /write?consistency=any&db=telegraf&precision=ns&rp= HTTP/1.1" 204 0 "-" "InfluxDBClient" 6f61bc44-321b-11e6-8050-000000000000 2513`)
|
|
||||||
}
|
|
||||||
benchM = m
|
|
||||||
}
|
|
||||||
|
|
||||||
func Benchmark_ParseLine_InfluxLog_NoMatch(b *testing.B) {
|
|
||||||
p := &Parser{
|
|
||||||
Patterns: []string{"%{INFLUXDB_HTTPD_LOG}"},
|
|
||||||
}
|
|
||||||
p.Compile()
|
|
||||||
|
|
||||||
var m telegraf.Metric
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
m, _ = p.ParseLine(`[retention] 2016/06/14 14:38:24 retention policy shard deletion check commencing`)
|
|
||||||
}
|
|
||||||
benchM = m
|
|
||||||
}
|
|
||||||
|
|
||||||
func Benchmark_ParseLine_CustomPattern(b *testing.B) {
|
func Benchmark_ParseLine_CustomPattern(b *testing.B) {
|
||||||
p := &Parser{
|
p := &Parser{
|
||||||
Patterns: []string{"%{TEST_LOG_A}", "%{TEST_LOG_B}"},
|
Patterns: []string{"%{TEST_LOG_A}", "%{TEST_LOG_B}"},
|
||||||
|
@ -108,9 +82,9 @@ func TestMeasurementName(t *testing.T) {
|
||||||
assert.Equal(t, "my_web_log", m.Name())
|
assert.Equal(t, "my_web_log", m.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuiltinInfluxdbHttpd(t *testing.T) {
|
func TestCustomInfluxdbHttpd(t *testing.T) {
|
||||||
p := &Parser{
|
p := &Parser{
|
||||||
Patterns: []string{"%{INFLUXDB_HTTPD_LOG}"},
|
Patterns: []string{`\[httpd\] %{COMBINED_LOG_FORMAT} %{UUID:uuid:drop} %{NUMBER:response_time_us:int}`},
|
||||||
}
|
}
|
||||||
assert.NoError(t, p.Compile())
|
assert.NoError(t, p.Compile())
|
||||||
|
|
||||||
|
@ -333,6 +307,55 @@ func TestParseEpochErrors(t *testing.T) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestParseGenericTimestamp(t *testing.T) {
|
||||||
|
p := &Parser{
|
||||||
|
Patterns: []string{`\[%{HTTPDATE:ts:ts}\] response_time=%{POSINT:response_time:int} mymetric=%{NUMBER:metric:float}`},
|
||||||
|
}
|
||||||
|
assert.NoError(t, p.Compile())
|
||||||
|
|
||||||
|
metricA, err := p.ParseLine(`[09/Jun/2016:03:37:03 +0000] response_time=20821 mymetric=10890.645`)
|
||||||
|
require.NotNil(t, metricA)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t,
|
||||||
|
map[string]interface{}{
|
||||||
|
"response_time": int64(20821),
|
||||||
|
"metric": float64(10890.645),
|
||||||
|
},
|
||||||
|
metricA.Fields())
|
||||||
|
assert.Equal(t, map[string]string{}, metricA.Tags())
|
||||||
|
assert.Equal(t, time.Unix(1465443423, 0).UTC(), metricA.Time().UTC())
|
||||||
|
|
||||||
|
metricB, err := p.ParseLine(`[09/Jun/2016:03:37:04 +0000] response_time=20821 mymetric=10890.645`)
|
||||||
|
require.NotNil(t, metricB)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t,
|
||||||
|
map[string]interface{}{
|
||||||
|
"response_time": int64(20821),
|
||||||
|
"metric": float64(10890.645),
|
||||||
|
},
|
||||||
|
metricB.Fields())
|
||||||
|
assert.Equal(t, map[string]string{}, metricB.Tags())
|
||||||
|
assert.Equal(t, time.Unix(1465443424, 0).UTC(), metricB.Time().UTC())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestParseGenericTimestampNotFound(t *testing.T) {
|
||||||
|
p := &Parser{
|
||||||
|
Patterns: []string{`\[%{NOTSPACE:ts:ts}\] response_time=%{POSINT:response_time:int} mymetric=%{NUMBER:metric:float}`},
|
||||||
|
}
|
||||||
|
assert.NoError(t, p.Compile())
|
||||||
|
|
||||||
|
metricA, err := p.ParseLine(`[foobar] response_time=20821 mymetric=10890.645`)
|
||||||
|
require.NotNil(t, metricA)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t,
|
||||||
|
map[string]interface{}{
|
||||||
|
"response_time": int64(20821),
|
||||||
|
"metric": float64(10890.645),
|
||||||
|
},
|
||||||
|
metricA.Fields())
|
||||||
|
assert.Equal(t, map[string]string{}, metricA.Tags())
|
||||||
|
}
|
||||||
|
|
||||||
func TestCompileFileAndParse(t *testing.T) {
|
func TestCompileFileAndParse(t *testing.T) {
|
||||||
p := &Parser{
|
p := &Parser{
|
||||||
Patterns: []string{"%{TEST_LOG_A}", "%{TEST_LOG_B}"},
|
Patterns: []string{"%{TEST_LOG_A}", "%{TEST_LOG_B}"},
|
||||||
|
|
|
@ -55,15 +55,13 @@ EXAMPLE_LOG \[%{HTTPDATE:ts:ts-httpd}\] %{NUMBER:myfloat:float} %{RESPONSE_CODE}
|
||||||
# Wider-ranging username matching vs. logstash built-in %{USER}
|
# Wider-ranging username matching vs. logstash built-in %{USER}
|
||||||
NGUSERNAME [a-zA-Z\.\@\-\+_%]+
|
NGUSERNAME [a-zA-Z\.\@\-\+_%]+
|
||||||
NGUSER %{NGUSERNAME}
|
NGUSER %{NGUSERNAME}
|
||||||
|
# Wider-ranging client IP matching
|
||||||
|
CLIENT (?:%{IPORHOST}|%{HOSTPORT}|::1)
|
||||||
|
|
||||||
##
|
##
|
||||||
## COMMON LOG PATTERNS
|
## COMMON LOG PATTERNS
|
||||||
##
|
##
|
||||||
|
|
||||||
# InfluxDB log patterns
|
|
||||||
CLIENT (?:%{IPORHOST}|%{HOSTPORT}|::1)
|
|
||||||
INFLUXDB_HTTPD_LOG \[httpd\] %{COMBINED_LOG_FORMAT} %{UUID:uuid:drop} %{NUMBER:response_time_us:int}
|
|
||||||
|
|
||||||
# apache & nginx logs, this is also known as the "common log format"
|
# apache & nginx logs, this is also known as the "common log format"
|
||||||
# see https://en.wikipedia.org/wiki/Common_Log_Format
|
# see https://en.wikipedia.org/wiki/Common_Log_Format
|
||||||
COMMON_LOG_FORMAT %{CLIENT:client_ip} %{NGUSER:ident} %{NGUSER:auth} \[%{HTTPDATE:ts:ts-httpd}\] "(?:%{WORD:verb:tag} %{NOTSPACE:request}(?: HTTP/%{NUMBER:http_version:float})?|%{DATA})" %{NUMBER:resp_code:tag} (?:%{NUMBER:resp_bytes:int}|-)
|
COMMON_LOG_FORMAT %{CLIENT:client_ip} %{NGUSER:ident} %{NGUSER:auth} \[%{HTTPDATE:ts:ts-httpd}\] "(?:%{WORD:verb:tag} %{NOTSPACE:request}(?: HTTP/%{NUMBER:http_version:float})?|%{DATA})" %{NUMBER:resp_code:tag} (?:%{NUMBER:resp_bytes:int}|-)
|
||||||
|
|
|
@ -51,15 +51,13 @@ EXAMPLE_LOG \[%{HTTPDATE:ts:ts-httpd}\] %{NUMBER:myfloat:float} %{RESPONSE_CODE}
|
||||||
# Wider-ranging username matching vs. logstash built-in %{USER}
|
# Wider-ranging username matching vs. logstash built-in %{USER}
|
||||||
NGUSERNAME [a-zA-Z\.\@\-\+_%]+
|
NGUSERNAME [a-zA-Z\.\@\-\+_%]+
|
||||||
NGUSER %{NGUSERNAME}
|
NGUSER %{NGUSERNAME}
|
||||||
|
# Wider-ranging client IP matching
|
||||||
|
CLIENT (?:%{IPORHOST}|%{HOSTPORT}|::1)
|
||||||
|
|
||||||
##
|
##
|
||||||
## COMMON LOG PATTERNS
|
## COMMON LOG PATTERNS
|
||||||
##
|
##
|
||||||
|
|
||||||
# InfluxDB log patterns
|
|
||||||
CLIENT (?:%{IPORHOST}|%{HOSTPORT}|::1)
|
|
||||||
INFLUXDB_HTTPD_LOG \[httpd\] %{COMBINED_LOG_FORMAT} %{UUID:uuid:drop} %{NUMBER:response_time_us:int}
|
|
||||||
|
|
||||||
# apache & nginx logs, this is also known as the "common log format"
|
# apache & nginx logs, this is also known as the "common log format"
|
||||||
# see https://en.wikipedia.org/wiki/Common_Log_Format
|
# see https://en.wikipedia.org/wiki/Common_Log_Format
|
||||||
COMMON_LOG_FORMAT %{CLIENT:client_ip} %{NGUSER:ident} %{NGUSER:auth} \[%{HTTPDATE:ts:ts-httpd}\] "(?:%{WORD:verb:tag} %{NOTSPACE:request}(?: HTTP/%{NUMBER:http_version:float})?|%{DATA})" %{NUMBER:resp_code:tag} (?:%{NUMBER:resp_bytes:int}|-)
|
COMMON_LOG_FORMAT %{CLIENT:client_ip} %{NGUSER:ident} %{NGUSER:auth} \[%{HTTPDATE:ts:ts-httpd}\] "(?:%{WORD:verb:tag} %{NOTSPACE:request}(?: HTTP/%{NUMBER:http_version:float})?|%{DATA})" %{NUMBER:resp_code:tag} (?:%{NUMBER:resp_bytes:int}|-)
|
||||||
|
|
|
@ -45,7 +45,7 @@ const sampleConfig = `
|
||||||
## /var/log/**.log -> recursively find all .log files in /var/log
|
## /var/log/**.log -> recursively find all .log files in /var/log
|
||||||
## /var/log/*/*.log -> find all .log files with a parent dir in /var/log
|
## /var/log/*/*.log -> find all .log files with a parent dir in /var/log
|
||||||
## /var/log/apache.log -> only tail the apache log file
|
## /var/log/apache.log -> only tail the apache log file
|
||||||
files = ["/var/log/influxdb/influxdb.log"]
|
files = ["/var/log/apache/access.log"]
|
||||||
## Read file from beginning.
|
## Read file from beginning.
|
||||||
from_beginning = false
|
from_beginning = false
|
||||||
|
|
||||||
|
@ -58,9 +58,9 @@ const sampleConfig = `
|
||||||
## Other common built-in patterns are:
|
## Other common built-in patterns are:
|
||||||
## %{COMMON_LOG_FORMAT} (plain apache & nginx access logs)
|
## %{COMMON_LOG_FORMAT} (plain apache & nginx access logs)
|
||||||
## %{COMBINED_LOG_FORMAT} (access logs + referrer & agent)
|
## %{COMBINED_LOG_FORMAT} (access logs + referrer & agent)
|
||||||
patterns = ["%{INFLUXDB_HTTPD_LOG}"]
|
patterns = ["%{COMBINED_LOG_FORMAT}"]
|
||||||
## Name of the outputted measurement name.
|
## Name of the outputted measurement name.
|
||||||
measurement = "influxdb_log"
|
measurement = "apache_access_log"
|
||||||
## Full path(s) to custom pattern files.
|
## Full path(s) to custom pattern files.
|
||||||
custom_pattern_files = []
|
custom_pattern_files = []
|
||||||
## Custom patterns can also be defined here. Put one pattern per line.
|
## Custom patterns can also be defined here. Put one pattern per line.
|
||||||
|
|
|
@ -71,7 +71,7 @@ func (p *SpecProcessor) pushMetrics() {
|
||||||
fields[prefix+"read_count"] = io.ReadCount
|
fields[prefix+"read_count"] = io.ReadCount
|
||||||
fields[prefix+"write_count"] = io.WriteCount
|
fields[prefix+"write_count"] = io.WriteCount
|
||||||
fields[prefix+"read_bytes"] = io.ReadBytes
|
fields[prefix+"read_bytes"] = io.ReadBytes
|
||||||
fields[prefix+"write_bytes"] = io.WriteCount
|
fields[prefix+"write_bytes"] = io.WriteBytes
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu_time, err := p.proc.Times()
|
cpu_time, err := p.proc.Times()
|
||||||
|
|
|
@ -17,6 +17,8 @@ func TestTailFromBeginning(t *testing.T) {
|
||||||
tmpfile, err := ioutil.TempFile("", "")
|
tmpfile, err := ioutil.TempFile("", "")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer os.Remove(tmpfile.Name())
|
defer os.Remove(tmpfile.Name())
|
||||||
|
_, err = tmpfile.WriteString("cpu,mytag=foo usage_idle=100\n")
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
tt := NewTail()
|
tt := NewTail()
|
||||||
tt.FromBeginning = true
|
tt.FromBeginning = true
|
||||||
|
@ -28,12 +30,10 @@ func TestTailFromBeginning(t *testing.T) {
|
||||||
|
|
||||||
acc := testutil.Accumulator{}
|
acc := testutil.Accumulator{}
|
||||||
require.NoError(t, tt.Start(&acc))
|
require.NoError(t, tt.Start(&acc))
|
||||||
|
time.Sleep(time.Millisecond * 100)
|
||||||
_, err = tmpfile.WriteString("cpu,mytag=foo usage_idle=100\n")
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NoError(t, tt.Gather(&acc))
|
require.NoError(t, tt.Gather(&acc))
|
||||||
// arbitrary sleep to wait for message to show up
|
// arbitrary sleep to wait for message to show up
|
||||||
time.Sleep(time.Millisecond * 250)
|
time.Sleep(time.Millisecond * 150)
|
||||||
|
|
||||||
acc.AssertContainsTaggedFields(t, "cpu",
|
acc.AssertContainsTaggedFields(t, "cpu",
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
|
|
|
@ -146,7 +146,7 @@ func (i *InfluxDB) Connect() error {
|
||||||
func createDatabase(c client.Client, database string) error {
|
func createDatabase(c client.Client, database string) error {
|
||||||
// Create Database if it doesn't exist
|
// Create Database if it doesn't exist
|
||||||
_, err := c.Query(client.Query{
|
_, err := c.Query(client.Query{
|
||||||
Command: fmt.Sprintf("CREATE DATABASE IF NOT EXISTS \"%s\"", database),
|
Command: fmt.Sprintf("CREATE DATABASE \"%s\"", database),
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,29 +83,17 @@ targets = {
|
||||||
}
|
}
|
||||||
|
|
||||||
supported_builds = {
|
supported_builds = {
|
||||||
"darwin": [ "amd64" ],
|
|
||||||
"windows": [ "amd64" ],
|
"windows": [ "amd64" ],
|
||||||
"linux": [ "amd64", "i386", "armhf", "armel", "arm64", "static_amd64" ],
|
"linux": [ "amd64", "i386", "armhf", "armel", "arm64", "static_amd64" ],
|
||||||
"freebsd": [ "amd64" ]
|
"freebsd": [ "amd64" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
supported_packages = {
|
supported_packages = {
|
||||||
"darwin": [ "tar" ],
|
|
||||||
"linux": [ "deb", "rpm", "tar" ],
|
"linux": [ "deb", "rpm", "tar" ],
|
||||||
"windows": [ "zip" ],
|
"windows": [ "zip" ],
|
||||||
"freebsd": [ "tar" ]
|
"freebsd": [ "tar" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
supported_tags = {
|
|
||||||
# "linux": {
|
|
||||||
# "amd64": ["sensors"]
|
|
||||||
# }
|
|
||||||
}
|
|
||||||
|
|
||||||
prereq_cmds = {
|
|
||||||
# "linux": "sudo apt-get install lm-sensors libsensors4-dev"
|
|
||||||
}
|
|
||||||
|
|
||||||
################
|
################
|
||||||
#### Telegraf Functions
|
#### Telegraf Functions
|
||||||
################
|
################
|
||||||
|
|
Loading…
Reference in New Issue