influxdata / influxdata/telegraf

inputs.sql - allow list of connection strings

Open
#12,882 6 comments 2 reactions 0 assignees View on GitHub
area/sql feature request
Dominant language
Go
Stars
17.8k
Forks
5.8k
Avg merge
1d 20h
Merged PRs (30d)
161

Description

### Use Case

The [input.sql](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/sql) `dns` parameter accepts only one value, therefore to run queries on multiple servers you need to duplicate the whole input.sql "instance".

I'd like to see it turned into a list (like [inputs.sqlserver](https://github.com/quantumdatis/telegraf/tree/master/plugins/inputs/sqlserver)), of course it will work only as long as the driver is the same (and possibly even authentication... but that depends on the used method, for SQL/basic auth it can be set in each string so I don't really see an issue)

The aim is to have a more compact and manageable config file

### Expected behavior

Having a _server list_
```toml
[[inputs.sql]]
driver = "mssql"
dsn = [
"sqlserver://SQLCSRV04/SQL2017"
,"sqlserver://SQLCSRV04/ITEC"
]
[[inputs.sql.query]]
query="SELECT @@SERVERNAME as srv, 1 as value"
```

### Actual behavior

only one server is allowed per plugin instance
```toml
[[inputs.sql]]
driver = "mssql"
dsn = "sqlserver://SQLCSRV04/SQL2017"
[[inputs.sql.query]]
query="SELECT @@SERVERNAME as srv, 1 as value"

[[inputs.sql]]
driver = "mssql"
dsn = "sqlserver://SQLCSRV04/ITEC"
[[inputs.sql.query]]
query="SELECT @@SERVERNAME as srv, 1 as value"
```

### Additional info

_No response_

Contributor guide

Open the contributing guide

Research direction

Start in plugins/inputs/sql and compare its connection-string handling with the referenced plugins/inputs/sqlserver implementation. Verify how the dsn value is parsed and how queries are executed, then confirm that a list of same-driver connection strings runs the query for each server while retaining the existing single-string configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.