Skip to content

postgresql_extensible reports wrong database name #9735

@phemmer

Description

@phemmer

Relevant telegraf.conf:

[[inputs.postgresql_extensible]]
address = "database=foo"
databases = ["foo"]
[[inputs.postgresql_extensible.query]]
sqlquery = "select 1"

System info:

ba1484c

Docker

Steps to reproduce:

  1. Run the above configuration

Expected behavior:

A metric should be emitted with the tag db=foo

Actual behavior:

The metric is emitted with the tag db=postgres

Additional info:

Apparently postgres is a hard-coded value when the statement you are executing does not return a datname field.
This is wrong by all accounts as neither the db in the connection string, nor the db in the database list is postgres. In addition, this behavior (of relying on the datname column) is completely undocumented, and I had to go digging through the source to find out what was going on.

https://github.com/influxdata/telegraf/blob/ba1484c/plugins/inputs/postgresql_extensible/postgresql_extensible.go#L267-L283

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugunexpected problem or unintended behaviorhelp wantedRequest for community participation, code, contributionsize/m2-4 day effort

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions