Skip to content

Commit 4f4b42b

Browse files
author
Mohamed-Amine Bouqsimi
authored
Add TLS config to query frontend (grafana#6444)
* added tls config to query frontend * changelog * remove commented code * lint
1 parent 5636380 commit 4f4b42b

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Main
22

3+
* [6444](https://github.com/grafana/loki/pull/6444) **aminesnow** Add TLS config to query frontend.
34
* [6415](https://github.com/grafana/loki/pull/6415) **salvacorts** Evenly spread queriers across kubernetes nodes.
45
* [6410](https://github.com/grafana/loki/pull/6410) **MichelHollands**: Add support for per tenant delete API access enabling.
56
* [6372](https://github.com/grafana/loki/pull/6372) **splitice**: Add support for numbers in JSON fields.

docs/sources/configuration/_index.md

+21
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,27 @@ The `frontend` block configures the Loki query-frontend.
399399
# CLI flag: -frontend.tail-proxy-url
400400
[tail_proxy_url: <string> | default = ""]
401401
402+
tail_tls_config:
403+
# Path to the client certificate file, which will be used for authenticating
404+
# with the server. Also requires the key path to be configured.
405+
# CLI flag: -frontend.tail-tls-config.tls-cert-path
406+
[tls_cert_path: <string> | default = ""]
407+
408+
# Path to the key file for the client certificate. Also requires the client
409+
# certificate to be configured.
410+
# CLI flag: -frontend.tail-tls-config.tls-key-path
411+
[tls_key_path: <string> | default = ""]
412+
413+
# Path to the CA certificates file to validate server certificate against. If
414+
# not set, the host's root CA certificates are used.
415+
# CLI flag: -frontend.tail-tls-config.tls-ca-path
416+
[tls_ca_path: <string> | default = ""]
417+
418+
# Skip validating server certificate.
419+
# CLI flag: -frontend.tail-tls-config.tls-insecure-skip-verify
420+
[tls_insecure_skip_verify: <boolean> | default = false]
421+
422+
402423
# DNS hostname used for finding query-schedulers.
403424
# CLI flag: -frontend.scheduler-address
404425
[scheduler_address: <string> | default = ""]

pkg/loki/modules.go

+9
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,15 @@ func (t *Loki) initQueryFrontend() (_ services.Service, err error) {
666666
}
667667
tp := httputil.NewSingleHostReverseProxy(tailURL)
668668

669+
cfg, err := t.Cfg.Frontend.TLS.GetTLSConfig()
670+
if err != nil {
671+
return nil, err
672+
}
673+
674+
tp.Transport = &http.Transport{
675+
TLSClientConfig: cfg,
676+
}
677+
669678
director := tp.Director
670679
tp.Director = func(req *http.Request) {
671680
director(req)

pkg/lokifrontend/config.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package lokifrontend
33
import (
44
"flag"
55

6+
"github.com/grafana/dskit/crypto/tls"
7+
68
"github.com/grafana/loki/pkg/lokifrontend/frontend/transport"
79
v1 "github.com/grafana/loki/pkg/lokifrontend/frontend/v1"
810
v2 "github.com/grafana/loki/pkg/lokifrontend/frontend/v2"
@@ -16,14 +18,16 @@ type Config struct {
1618
CompressResponses bool `yaml:"compress_responses"`
1719
DownstreamURL string `yaml:"downstream_url"`
1820

19-
TailProxyURL string `yaml:"tail_proxy_url"`
21+
TailProxyURL string `yaml:"tail_proxy_url"`
22+
TLS tls.ClientConfig `yaml:"tail_tls_config"`
2023
}
2124

2225
// RegisterFlags adds the flags required to config this to the given FlagSet.
2326
func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
2427
cfg.Handler.RegisterFlags(f)
2528
cfg.FrontendV1.RegisterFlags(f)
2629
cfg.FrontendV2.RegisterFlags(f)
30+
cfg.TLS.RegisterFlagsWithPrefix("frontend.tail-tls-config", f)
2731

2832
f.BoolVar(&cfg.CompressResponses, "querier.compress-http-responses", false, "Compress HTTP responses.")
2933
f.StringVar(&cfg.DownstreamURL, "frontend.downstream-url", "", "URL of downstream Prometheus.")

0 commit comments

Comments
 (0)