grafana / alloy

OpenTelemetry Collector distribution with programmable pipelines
https://grafana.com/oss/alloy
Apache License 2.0
1.45k stars 216 forks source link

prometheus.exporter.mssql: add support connect to MSSQL named instances #1374

Open Mykhailo-Roit opened 3 months ago

Mykhailo-Roit commented 3 months ago

Request

Microsoft allows connecting to Named instances using the syntax "Data Source=MySqlServer\\MSSQL1;" manual but Alloy does allow the using

prometheus.exporter.mssql "SQL2022_test" {
  connection_string = "sqlserver://@localhost\\SQL2022?authenticator=winsspi"  
  query_config = local.file.mssql_queries.content
}

and got error

Error: config.alloy:81:1: Failed to build component: building component: failed to parse connection string URL: parse "sqlserver://@localhost\\SQL2022?authenticator=winsspi": invalid character "\\" in host name

80 |
81 |   prometheus.exporter.mssql "SQL2022_test" {
   |  _^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
82 | |   connection_string = "sqlserver://@localhost\\SQL2022?authenticator=winsspi"
83 | |   query_config = local.file.mssql_queries.content
84 | | }
   | |_^
85 |

interrupt received

Use case

When several named instances are installed on one server, it will be very useful.

now I use workaround: allow TCP connection for each named instance and bind static TCP port

prometheus.exporter.mssql "SQL2022" {
  connection_string = "sqlserver://@localhost:1436?authenticator=winsspi"  
  query_config = local.file.mssql_queries.content
}
github-actions[bot] commented 2 months ago

This issue has not had any activity in the past 30 days, so the needs-attention label has been added to it. If the opened issue is a bug, check to see if a newer release fixed your issue. If it is no longer relevant, please feel free to close this issue. The needs-attention label signals to maintainers that something has fallen through the cracks. No action is needed by you; your issue will be kept open and you do not have to respond to this comment. The label will be removed the next time this job runs if there is new activity. Thank you for your contributions!