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

Prometheus client transport has no TLS options #540

Closed
coderigo opened this issue Feb 26, 2023 · 0 comments · Fixed by #599
Closed

Prometheus client transport has no TLS options #540

coderigo opened this issue Feb 26, 2023 · 0 comments · Fixed by #599
Assignees

Comments

@coderigo
Copy link

Specifying a prometheus server in the config as described in the docs does not allow setting any TLS configs and hitting prometheus servers with self-signed certificates or that require client auth fails.

The suggestion would be to update a given server block's config settngs to accept a tls config block like this:

prometheus "$name" {
  uri         = "https://..."
  failover    = ["https://...",...]
  tags        = ["...",...]
  headers     = { "..." : "..." }
  timeout     = "2m"
  concurrency = 16
  rateLimit   = 100
  required    = true | false
  include     = ["...",...]
  exclude     = ["...",...]
  # add TLS settings, leave block empty if no TLS
  tls {
    enabled       = true # default to false
    skipVerify    = true # default to false
    caCert        = "/some/path/to/my/ca.crt"
    clientCert    = "/some/path/to/my/client.crt"
    clientCertKey = "/some/path/to/my/client.key"
  }
}

These settings would just need to be used when constructing the transport fed to gzhttp here to do something like this:

func NewPrometheus(name, uri string, headers map[string]string, timeout time.Duration, concurrency, rl int, tlsConfig tls.Config) *Prometheus {
	transport := &http.Transport{TLSClientConfig: tlsConfig }
	prom := Prometheus{
		name:        name,
		unsafeURI:   uri,
		safeURI:     sanitizeURI(uri),
		headers:     headers,
		timeout:     timeout,
		client:      http.Client{Transport: gzhttp.Transport(transport)},
		locker:      newPartitionLocker((&sync.Mutex{})),
		rateLimiter: ratelimit.New(rl),
		concurrency: concurrency,
	}
	return &prom
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants