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

make persistent connection to postgresql #1977

Closed
wei-hai opened this issue Oct 31, 2016 · 4 comments
Closed

make persistent connection to postgresql #1977

wei-hai opened this issue Oct 31, 2016 · 4 comments
Labels
area/postgresql feature request Requests for new plugin and for new features to existing plugins
Milestone

Comments

@wei-hai
Copy link

wei-hai commented Oct 31, 2016

Feature Request

Let Telegraf make persistent connection to postgresql database

Proposal:

We are using telegraf to collect metric data from postgresql and it works well, however, we found that it doesn’t keep persistent connection postgresql, which causes unnecessary growth and noises in postgresql log file

Current behavior:

Telegraf makes connection to postgresql every INTERVAL seconds and then disconnects.

Desired behavior:

Telegraf shall make persistent connection to postgresql

Use case: [Why is this important (helps with prioritizing requests)]

Too many connections and disconnections cause growth and noises in postgresql log files which is unnecessary at all.

Log output:

< 2016-10-31 10:48:14.863 PDT >LOG: disconnection: session time: 0:00:00.014 user=telegraf database=postgres host=127.0.0.1 port=36218
< 2016-10-31 10:48:15.849 PDT >LOG: connection received: host=127.0.0.1 port=36220
< 2016-10-31 10:48:15.850 PDT >LOG: connection authorized: user=telegraf database=postgres
< 2016-10-31 10:48:15.863 PDT >LOG: disconnection: session time: 0:00:00.014 user=telegraf database=postgres host=127.0.0.1 port=36220

@jackzampolin jackzampolin added the feature request Requests for new plugin and for new features to existing plugins label Oct 31, 2016
@sparrc sparrc added this to the Future Milestone milestone Nov 3, 2016
@mnietz
Copy link

mnietz commented Nov 23, 2016

👍

@phemmer
Copy link
Contributor

phemmer commented Feb 8, 2017

I'll probably tackle this soon (within the next couple weeks).
The way I think i'm going to do it is to add a pool_size_max = X parameter. If X is 0, the current behavior will be used (disconnect once done). Otherwise it'll connect up to X times, running the queries in parallel. To just have 1 long lived connection, it'd just be pool_size_max = 1.

@james-lawrence
Copy link
Contributor

@phemmer may I suggest we just specify the 3 values for a standard db connection?

  • IdleConns (default 1, can be set to 0 for disconnect after use) I think 1 is the more sensible default though it will change current default behaviour.
  • MaxOpenConns - (default 1)
  • ConnMaxLifetime - (default 0, keep the same connection forever do not cycle)

@danielnelson danielnelson removed this from the Future Milestone milestone Jun 14, 2017
@danielnelson
Copy link
Contributor

Closing, was fixed back in 1.6

@danielnelson danielnelson added this to the 1.6.0 milestone Sep 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/postgresql feature request Requests for new plugin and for new features to existing plugins
Projects
None yet
Development

No branches or pull requests

7 participants