Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL output plugin #3428

Closed
wants to merge 79 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
8d5e772
Remove non-existent field from net_response readme
danielnelson Dec 3, 2019
5a3ac97
Document that json tag_keys are not saved as fields.
danielnelson Dec 4, 2019
f7ab7de
Fix prometheus histogram and summary merging (#6756)
danielnelson Dec 4, 2019
280a414
Add minimum system requirements to readme
danielnelson Dec 5, 2019
bf03bb3
Build packages with Go 1.13.5 (#6767)
danielnelson Dec 7, 2019
2ed2949
Override github.com/satori/go.uuid revision for transitive deps (#6768)
danielnelson Dec 7, 2019
edbb08b
Fix unix socket dial arguments in uwsgi input (#6769)
danielnelson Dec 9, 2019
b4d2158
Update changelog
danielnelson Dec 9, 2019
78de395
Use actual database name in db creation failed log (#6780)
danielnelson Dec 10, 2019
7df0ade
Replace colon chars in prometheus output labels with metric_version=1…
danielnelson Dec 10, 2019
54b72db
Update changelog
danielnelson Dec 10, 2019
91d7c6e
Document --service-display-name flag for Windows service
danielnelson Dec 10, 2019
6b01bb8
Add documentation about listening on port < 1024 (#6785)
reimda Dec 11, 2019
7cf5ea7
Set TrimLeadingSpace when TrimSpace is on in csv parser (#6773)
DSpeichert Dec 11, 2019
5cd6339
Add option to control collecting global variables to mysql input (#6790)
benhymans Dec 11, 2019
cee3267
Update changelog
danielnelson Dec 11, 2019
4485194
Interpret SNMP v1 traps as described in RFC 2576 3.1 (#6793)
reimda Dec 11, 2019
5f5e314
Fix off by one bug in snmp trap v1 generic trap field (#6797)
reimda Dec 12, 2019
19876ee
Update sample config
danielnelson Dec 12, 2019
a045305
Set 1.13.0 release date
danielnelson Dec 12, 2019
773e4ca
Telegraf 1.13.0
danielnelson Dec 12, 2019
c9731bf
initial import of postgres output plugin
svenklemm Oct 19, 2017
b57e5e4
make address configurable
svenklemm Oct 20, 2017
9ff32b3
add helper functions for create table and insert
svenklemm Oct 22, 2017
eeecc47
add tests
svenklemm Oct 22, 2017
4337a32
fix sql placeholder
svenklemm Oct 24, 2017
21cabc0
let pgx handle time conversion, remove old code
svenklemm Oct 24, 2017
1380298
adjust test cases to datatype changes
svenklemm Oct 24, 2017
cf16e1f
remove debug prints
svenklemm Oct 27, 2017
c4a8a24
check if table exists before creating
svenklemm Oct 27, 2017
26b12dc
allow skipping tags
svenklemm Oct 28, 2017
96639c2
refactoring
svenklemm Nov 5, 2017
01f9de1
implement TagsAsForeignkeys
svenklemm Nov 5, 2017
8d9b9a2
fix tests
svenklemm Nov 5, 2017
bb78f5f
add SampleConfig
svenklemm Nov 5, 2017
6ecd59d
register driver
svenklemm Nov 5, 2017
db5609d
update README
svenklemm Nov 5, 2017
89f87d5
prepare for create table template
svenklemm Nov 6, 2017
bdd220f
quote identifier
svenklemm Nov 7, 2017
f1819f8
refactor generateInsert
svenklemm Nov 7, 2017
5123a63
use timestamp for time column to allow pg10 partitioning
svenklemm Nov 7, 2017
af02b9b
remove nondeterministic tests
svenklemm Nov 8, 2017
1a909dc
use template for create table query generation
svenklemm Nov 8, 2017
62629ac
make TableTemplate configurable
svenklemm Nov 8, 2017
8c0953c
add quoteLiteral helper function
svenklemm Nov 18, 2017
e53efb3
add tests for quoting
svenklemm Nov 18, 2017
544c1b1
add TABLELITERAL to template variables
svenklemm Nov 18, 2017
a8ccb89
fix template in doc
svenklemm Nov 18, 2017
235d12d
dont add primary key
svenklemm Nov 18, 2017
b2f2bab
allow using jsonb for fields and tags and make it default
svenklemm Nov 26, 2017
571b545
document jsonb settings
svenklemm Nov 28, 2017
cd21135
document template better
svenklemm Jan 17, 2018
89059a0
rework TagsAsForeignkeys to have produce 1 foreign key in measurement
svenklemm Jan 23, 2018
c732174
make tag table suffix configurable
svenklemm Jan 23, 2018
7d7ee00
comment out noisy log messages when fk reference is not found
svenklemm Feb 5, 2018
0b9142e
handle missing columns
svenklemm Feb 5, 2018
7ed8a01
remove dead code
svenklemm Feb 11, 2018
db9991f
postgresql output: boolean columns
saaros Apr 16, 2018
dc620f2
postgresql output: batch inserts to the same table/column set
saaros Apr 17, 2018
9ad545f
use timestamptz for time column
svenklemm May 12, 2018
0de9b92
adjust test to timestamptz change
svenklemm May 13, 2018
8a62338
fix code formatting (gofmt)
svenklemm Jun 11, 2018
1d4a442
include type in error message about unknown type
svenklemm Jul 5, 2018
236cc8c
handle uint64 as datatype
svenklemm Jul 5, 2018
3842a86
fix Printf call
svenklemm Jul 5, 2018
38d492f
show all config parameters in readme
svenklemm Jul 17, 2018
401f39a
use CREATE TABLE IF NOT EXISTS
svenklemm Oct 16, 2018
79aa3c5
remove commented out code, initialize vars with values
svenklemm Oct 25, 2018
172e45d
fix TABLELITERAL quoting
svenklemm Nov 27, 2018
bb8821b
pg output: Support defining schema for metrics tables
rikonen Nov 25, 2018
87b111c
pg output: Retry writing metrics after adding missing columns
rikonen Nov 29, 2018
48299b2
pg output: Don't try closing nil rows
rikonen Nov 29, 2018
7597ddd
adjust test output
svenklemm Nov 29, 2018
f728b1e
add schema config settting to README
svenklemm Nov 29, 2018
9ec0fc5
Fix adding tags when using tags as foreign key
svenklemm Nov 29, 2018
4aeefcb
Refactor PostgreSQL output plugin code
May 29, 2019
b3f405d
Optimize insert performance of metrics and tag_id lookup
Jul 14, 2019
dad46ba
Attempt reconnect to db if conn is lost and support PG env variables
Jul 18, 2019
cf20265
error thrown on insufficient permissions
Dec 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ defaults:
GOFLAGS: -p=8
go-1_12: &go-1_12
docker:
- image: 'quay.io/influxdb/telegraf-ci:1.12.12'
- image: 'quay.io/influxdb/telegraf-ci:1.12.14'
go-1_13: &go-1_13
docker:
- image: 'quay.io/influxdb/telegraf-ci:1.13.3'
- image: 'quay.io/influxdb/telegraf-ci:1.13.5'

version: 2
jobs:
Expand Down
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## v1.13 [unreleased]
## v1.13 [2019-12-12]

#### Release Notes

- Official packages built with Go 1.13.3.
- Official packages built with Go 1.13.5.
- The `prometheus` input and `prometheus_client` output have a new mapping to
and from Telegraf metrics, which can be enabled by setting `metric_version = 2`.
The original mapping is deprecated. When both plugins have the same setting,
Expand Down Expand Up @@ -66,6 +66,7 @@
- [#6735](https://github.com/influxdata/telegraf/pull/6735): Support resolution of symlinks in filecount input.
- [#6746](https://github.com/influxdata/telegraf/pull/6746): Set message timestamp to the metric time in kafka output.
- [#6740](https://github.com/influxdata/telegraf/pull/6740): Add base64decode operation to string processor.
- [#6790](https://github.com/influxdata/telegraf/pull/6790): Add option to control collecting global variables to mysql input.

#### Bugfixes

Expand All @@ -78,6 +79,9 @@
- [#6705](https://github.com/influxdata/telegraf/issues/6705): Remove trailing underscore trimming from json flattener.
- [#6421](https://github.com/influxdata/telegraf/issues/6421): Revert change causing cpu usage to be capped at 100 percent.
- [#6523](https://github.com/influxdata/telegraf/issues/6523): Accept any media type in the prometheus input.
- [#6769](https://github.com/influxdata/telegraf/issues/6769): Fix unix socket dial arguments in uwsgi input.
- [#6757](https://github.com/influxdata/telegraf/issues/6757): Replace colon chars in prometheus output labels with metric_version=1.
- [#6773](https://github.com/influxdata/telegraf/issues/6773): Set TrimLeadingSpace when TrimSpace is on in csv parser.

## v1.12.6 [2019-11-19]

Expand Down
16 changes: 12 additions & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 15 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
name = "github.com/aws/aws-sdk-go"
version = "1.19.41"

[[constraint]]
name = "github.com/bsm/sarama-cluster"
version = "2.1.13"

[[constraint]]
name = "github.com/couchbase/go-couchbase"
branch = "master"
Expand All @@ -36,7 +40,7 @@

[[constraint]]
name = "github.com/eclipse/paho.mqtt.golang"
version = "1"
version = "~1.1.1"

[[constraint]]
name = "github.com/go-sql-driver/mysql"
Expand Down Expand Up @@ -100,7 +104,7 @@

[[constraint]]
name = "github.com/Microsoft/ApplicationInsights-Go"
branch = "master"
version = "0.4.2"

[[constraint]]
name = "github.com/miekg/dns"
Expand Down Expand Up @@ -304,3 +308,12 @@
[[constraint]]
name = "github.com/safchain/ethtool"
revision = "42ed695e3de80b9d695f280295fd7994639f209d"

[[override]]
name = "github.com/satori/go.uuid"
revision = "b2ce2384e17bbe0c6d34077efa39dbab3e09123b"

[[constraint]]
branch = "master"
name = "github.com/golang/groupcache"

8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ plugin-%:

.PHONY: ci-1.13
ci-1.13:
docker build -t quay.io/influxdb/telegraf-ci:1.13.3 - < scripts/ci-1.13.docker
docker push quay.io/influxdb/telegraf-ci:1.13.3
docker build -t quay.io/influxdb/telegraf-ci:1.13.5 - < scripts/ci-1.13.docker
docker push quay.io/influxdb/telegraf-ci:1.13.5

.PHONY: ci-1.12
ci-1.12:
docker build -t quay.io/influxdb/telegraf-ci:1.12.12 - < scripts/ci-1.12.docker
docker push quay.io/influxdb/telegraf-ci:1.12.12
docker build -t quay.io/influxdb/telegraf-ci:1.12.14 - < scripts/ci-1.12.docker
docker push quay.io/influxdb/telegraf-ci:1.12.14
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ There are many ways to contribute:
- Answer questions and discuss here on github and on the [Community Site](https://community.influxdata.com/)
- [Contribute plugins](CONTRIBUTING.md)

## Minimum Requirements

Telegraf shares the same [minimum requirements][] as Go:
- Linux kernel version 2.6.23 or later
- Windows 7 or later
- FreeBSD 11.2 or later
- MacOS 10.11 El Capitan or later

[minimum requirements]: https://github.com/golang/go/wiki/MinimumRequirements#minimum-requirements

## Installation:

You can download the binaries directly from the [downloads](https://www.influxdata.com/downloads) page
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ platform: x64

install:
- IF NOT EXIST "C:\Cache" mkdir C:\Cache
- IF NOT EXIST "C:\Cache\go1.13.3.msi" curl -o "C:\Cache\go1.13.3.msi" https://storage.googleapis.com/golang/go1.13.3.windows-amd64.msi
- IF NOT EXIST "C:\Cache\go1.13.5.msi" curl -o "C:\Cache\go1.13.5.msi" https://storage.googleapis.com/golang/go1.13.5.windows-amd64.msi
- IF NOT EXIST "C:\Cache\gnuwin32-bin.zip" curl -o "C:\Cache\gnuwin32-bin.zip" https://dl.influxdata.com/telegraf/ci/make-3.81-bin.zip
- IF NOT EXIST "C:\Cache\gnuwin32-dep.zip" curl -o "C:\Cache\gnuwin32-dep.zip" https://dl.influxdata.com/telegraf/ci/make-3.81-dep.zip
- IF EXIST "C:\Go" rmdir /S /Q C:\Go
- msiexec.exe /i "C:\Cache\go1.13.3.msi" /quiet
- msiexec.exe /i "C:\Cache\go1.13.5.msi" /quiet
- 7z x "C:\Cache\gnuwin32-bin.zip" -oC:\GnuWin32 -y
- 7z x "C:\Cache\gnuwin32-dep.zip" -oC:\GnuWin32 -y
- go get -d github.com/golang/dep
Expand Down
13 changes: 8 additions & 5 deletions docs/WINDOWS_SERVICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,21 @@ Telegraf can manage its own service through the --service flag:

## Install multiple services

You can install multiple telegraf instances with --service-name flag:
Running multiple instances of Telegraf is seldom needed, as you can run
multiple instances of each plugin and route metric flow using the metric
filtering options. However, if you do need to run multiple telegraf instances
on a single system, you can install the service with the `--service-name` and
`--service-display-name` flags to give the services unique names:

```
> C:\"Program Files"\Telegraf\telegraf.exe --service install --service-name telegraf-1
> C:\"Program Files"\Telegraf\telegraf.exe --service install --service-name telegraf-2
> C:\"Program Files"\Telegraf\telegraf.exe --service uninstall --service-name telegraf-1
> C:\"Program Files"\Telegraf\telegraf.exe --service install --service-name telegraf-1 --service-display-name "Telegraf 1"
> C:\"Program Files"\Telegraf\telegraf.exe --service install --service-name telegraf-2 --service-display-name "Telegraf 2"
```

## Troubleshooting

When Telegraf runs as a Windows service, Telegraf logs messages to Windows events log before configuration file with logging settings is loaded.
Check event log for an error reported by `telegraf` service in case of Telegraf service reports failure on its start: Event Viewer->Windows Logs->Application
Check event log for an error reported by `telegraf` service in case of Telegraf service reports failure on its start: Event Viewer->Windows Logs->Application

**Troubleshooting common error #1067**

Expand Down
13 changes: 12 additions & 1 deletion etc/telegraf.conf
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,10 @@
# # [[processors.strings.left]]
# # field = "message"
# # width = 10
#
# ## Decode a base64 encoded utf-8 string
# # [[processors.strings.base64decode]]
# # field = "message"


# # Restricts the number of tags that can pass through this filter and chooses which tags to preserve when over the limit.
Expand Down Expand Up @@ -3469,6 +3473,9 @@
# ## gather metrics from SHOW BINARY LOGS command output
# # gather_binary_logs = false
#
# ## gather metrics from PERFORMANCE_SCHEMA.GLOBAL_VARIABLES
# # gather_global_variables = true
#
# ## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE
# # gather_table_io_waits = false
#
Expand Down Expand Up @@ -5741,7 +5748,11 @@
# ## Transport, local address, and port to listen on. Transport must
# ## be "udp://". Omit local address to listen on all interfaces.
# ## example: "udp://127.0.0.1:1234"
# # service_address = udp://:162
# ##
# ## Special permissions may be required to listen on a port less than
# ## 1024. See README.md for details
# ##
# # service_address = "udp://:162"
# ## Timeout running snmptranslate command
# # timeout = "5s"

Expand Down
3 changes: 3 additions & 0 deletions plugins/inputs/mysql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ This plugin gathers the statistic data from MySQL server
## gather metrics from SHOW BINARY LOGS command output
# gather_binary_logs = false

## gather metrics from SHOW GLOBAL VARIABLES command output
# gather_global_variables = true

## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE
# gather_table_io_waits = false

Expand Down
22 changes: 15 additions & 7 deletions plugins/inputs/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Mysql struct {
GatherTableSchema bool `toml:"gather_table_schema"`
GatherFileEventsStats bool `toml:"gather_file_events_stats"`
GatherPerfEventsStatements bool `toml:"gather_perf_events_statements"`
GatherGlobalVars bool `toml:"gather_global_variables"`
IntervalSlow string `toml:"interval_slow"`
MetricVersion int `toml:"metric_version"`

Expand Down Expand Up @@ -94,6 +95,9 @@ const sampleConfig = `
## gather metrics from SHOW BINARY LOGS command output
# gather_binary_logs = false

## gather metrics from PERFORMANCE_SCHEMA.GLOBAL_VARIABLES
# gather_global_variables = true

## gather metrics from PERFORMANCE_SCHEMA.TABLE_IO_WAITS_SUMMARY_BY_TABLE
# gather_table_io_waits = false

Expand Down Expand Up @@ -134,6 +138,7 @@ const (
defaultPerfEventsStatementsDigestTextLimit = 120
defaultPerfEventsStatementsLimit = 250
defaultPerfEventsStatementsTimeLimit = 86400
defaultGatherGlobalVars = true
)

func (m *Mysql) SampleConfig() string {
Expand Down Expand Up @@ -431,14 +436,16 @@ func (m *Mysql) gatherServer(serv string, acc telegraf.Accumulator) error {
return err
}

// Global Variables may be gathered less often
if len(m.IntervalSlow) > 0 {
if uint32(time.Since(m.lastT).Seconds()) >= m.scanIntervalSlow {
err = m.gatherGlobalVariables(db, serv, acc)
if err != nil {
return err
if m.GatherGlobalVars {
// Global Variables may be gathered less often
if len(m.IntervalSlow) > 0 {
if uint32(time.Since(m.lastT).Seconds()) >= m.scanIntervalSlow {
err = m.gatherGlobalVariables(db, serv, acc)
if err != nil {
return err
}
m.lastT = time.Now()
}
m.lastT = time.Now()
}
}

Expand Down Expand Up @@ -1767,6 +1774,7 @@ func init() {
PerfEventsStatementsDigestTextLimit: defaultPerfEventsStatementsDigestTextLimit,
PerfEventsStatementsLimit: defaultPerfEventsStatementsLimit,
PerfEventsStatementsTimeLimit: defaultPerfEventsStatementsTimeLimit,
GatherGlobalVars: defaultGatherGlobalVars,
}
})
}
1 change: 0 additions & 1 deletion plugins/inputs/net_response/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ verify text in the response.
- result
- fields:
- response_time (float, seconds)
- success (int) # success 0, failure 1
- result_code (int, success = 0, timeout = 1, connection_failed = 2, read_failed = 3, string_mismatch = 4)
- result_type (string) **DEPRECATED in 1.7; use result tag**
- string_found (boolean) **DEPRECATED in 1.4; use result tag**
Expand Down
31 changes: 30 additions & 1 deletion plugins/inputs/snmp_trap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ the SNMP [README.md](../snmp/README.md) for details.
## Transport, local address, and port to listen on. Transport must
## be "udp://". Omit local address to listen on all interfaces.
## example: "udp://127.0.0.1:1234"
# service_address = udp://:162
##
## Special permissions may be required to listen on a port less than
## 1024. See README.md for details
##
# service_address = "udp://:162"
## Timeout running snmptranslate command
# timeout = "5s"
```
Expand All @@ -41,3 +45,28 @@ the SNMP [README.md](../snmp/README.md) for details.
snmp_trap,mib=SNMPv2-MIB,name=coldStart,oid=.1.3.6.1.6.3.1.1.5.1,source=192.168.122.102,version=2c snmpTrapEnterprise.0="linux",sysUpTimeInstance=1i 1574109187723429814
snmp_trap,mib=NET-SNMP-AGENT-MIB,name=nsNotifyShutdown,oid=.1.3.6.1.4.1.8072.4.0.2,source=192.168.122.102,version=2c sysUpTimeInstance=5803i,snmpTrapEnterprise.0="netSnmpNotificationPrefix" 1574109186555115459
```

### Using a Privileged Port

On many operating systems, listening on a privileged port (a port
number less than 1024) requires extra permission. Since the default
SNMP trap port 162 is in this category, using telegraf to receive SNMP
traps may need extra permission.

Instructions for listening on a privileged port vary by operating
system. It is not recommended to run telegraf as superuser in order to
use a privileged port. Instead follow the principle of least privilege
and use a more specific operating system mechanism to allow telegraf to
use the port. You may also be able to have telegraf use an
unprivileged port and then configure a firewall port forward rule from
the privileged port.

To use a privileged port on Linux, you can use setcap to enable the
CAP_NET_BIND_SERVICE capability on the telegraf binary:

```
setcap cap_net_bind_service=+ep /usr/bin/telegraf
```

On Mac OS, listening on privileged ports is unrestricted on versions
10.14 and later.
Loading