grafana / alloy

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

prometheus.exporter.mssq NTLM Login Escape Backslash #231

Open jankbrommer opened 5 months ago

jankbrommer commented 5 months ago

What's wrong?

If you want to configure a connection string with NTLM for MSSQL exports as described in the documentation, the agent does not start and returns the following error: Error: C:\Program Files\Grafana Agent Flow\config.river:12:1: Failed to build component: building component: failed to parse connection string URL: parse "sqlserver://cmicloud.local\\scv_grafanaagent:n9a9QJaifqNhbUUzeeg3qXFhR2yKCr@localhost:1433?authenticator=ntlm": net/url: invalid userinfo

Error Configuration: sqlserver://<DOMAIN\USERNAME>:<PASSWORD>@<HOST>:<PORT>?authenticator=ntlm

As a workaround, the symbol URL can be encoded: sqlserver://<DOMAIN%5CUSERNAME>:<PASSWORD>@<HOST>:<PORT>?authenticator=ntlm

Expectation would be that the configuration can be used without extra encoding or at least according to the concept with "\\" as described here: https://grafana.com/docs/agent/latest/flow/concepts/config-language/expressions/types_and_values/#strings

Steps to reproduce

Konfigurieren des MSSQL Exporters wie in der Doku: https://grafana.com/docs/agent/latest/static/configuration/integrations/mssql-config/

System information

Windows Server 2022

Software version

Grafana Agent 0.40

Configuration

No response

Logs

No response

hainenber commented 4 months ago

Hi there 👋

Have you tried enclosing the connection string in backticks yet?

jankbrommer commented 4 months ago

@hainenber Yes this dont work for me if i Try backticks like connection_string = sqlserver://<Domain>\<User>:<Password>@localhost:1433?authenticator=ntlm I get this error:

`ts=2024-03-12T09:41:26.35656Z level=info msg="running usage stats reporter" ts=2024-03-12T09:41:26.35656Z level=info msg="starting complete graph evaluation" controller_id="" trace_id=e0e595f2fb840c759b630da60a137b30 ts=2024-03-12T09:41:26.35656Z level=info msg="finished node evaluation" controller_id="" trace_id=e0e595f2fb840c759b630da60a137b30 node_id=otel duration=0s ts=2024-03-12T09:41:26.35656Z level=info msg="enabled windows_exporter collectors" component=prometheus.exporter.windows.default collectors=cpu,cs,logical_disk,net,os,service,system ts=2024-03-12T09:41:26.35656Z level=info msg="finished node evaluation" controller_id="" trace_id=e0e595f2fb840c759b630da60a137b30 node_id=prometheus.exporter.windows.default duration=140.9415ms ts=2024-03-12T09:41:26.35656Z level=info msg="finished node evaluation" controller_id="" trace_id=e0e595f2fb840c759b630da60a137b30 node_id=remotecfg duration=0s ts=2024-03-12T09:41:26.35656Z level=info msg="finished node evaluation" controller_id="" trace_id=e0e595f2fb840c759b630da60a137b30 node_id=labelstore duration=0s ts=2024-03-12T09:41:26.35656Z level=info msg="applying non-TLS config to HTTP server" service=http ts=2024-03-12T09:41:26.35656Z level=info msg="finished node evaluation" controller_id="" trace_id=e0e595f2fb840c759b630da60a137b30 node_id=http duration=0s ts=2024-03-12T09:41:26.35656Z level=info msg="finished node evaluation" controller_id="" trace_id=e0e595f2fb840c759b630da60a137b30 node_id=ui duration=0s ts=2024-03-12T09:41:26.35656Z level=info msg="finished node evaluation" controller_id="" trace_id=e0e595f2fb840c759b630da60a137b30 node_id=cluster duration=0s ts=2024-03-12T09:41:26.35656Z level=error msg="failed to evaluate config" controller_id="" trace_id=e0e595f2fb840c759b630da60a137b30 node=prometheus.exporter.mssql.default err="building component: failed to parse connection string URL: parse \"sqlserver://\\:@localhost:1433?authenticator=ntlm\": net/url: invalid userinfo" ts=2024-03-12T09:41:26.35656Z level=info msg="finished node evaluation" controller_id="" trace_id=e0e595f2fb840c759b630da60a137b30 node_id=prometheus.exporter.mssql.default duration=529.1µs ts=2024-03-12T09:41:26.35656Z level=info msg="finished node evaluation" controller_id="" trace_id=e0e595f2fb840c759b630da60a137b30 node_id=tracing duration=0s ts=2024-03-12T09:41:26.35656Z level=info msg="finished node evaluation" controller_id="" trace_id=e0e595f2fb840c759b630da60a137b30 node_id=logging duration=0s ts=2024-03-12T09:41:26.35656Z level=info msg="finished complete graph evaluation" controller_id="" trace_id=e0e595f2fb840c759b630da60a137b30 duration=141.4706ms Error: C:\Program Files\Grafana Agent Flow\config.river:12:1: Failed to build component: building component: failed to parse connection string URL: parse "sqlserver://\:@localhost:1433?authenticator=ntlm": net/url: invalid userinfo

11 |
12 | prometheus.exporter.mssql "default" { | _^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 13 | | connectionstring = sqlserver://<Domain>\<User>:<Password>@localhost:1433?authenticator=ntlm 14 | | } | |^

interrupt received ts=2024-03-12T09:41:26.35656Z level=error msg="failed to start reporter" err="context canceled" Error: could not perform the initial load successfully ` Edit: The formatting doesn't fit completely attached as a raw text file EventLogError.txt

rfratto commented 3 months ago

Hi there :wave:

On April 9, 2024, Grafana Labs announced Grafana Alloy, the spirital successor to Grafana Agent and the final form of Grafana Agent flow mode. As a result, Grafana Agent has been deprecated and will only be receiving bug and security fixes until its end-of-life around November 1, 2025.

To make things easier for maintainers, we're in the process of migrating all issues tagged variant/flow to the Grafana Alloy repository to have a single home for tracking issues. This issue is likely something we'll want to address in both Grafana Alloy and Grafana Agent, so just because it's being moved doesn't mean we won't address the issue in Grafana Agent :)