Skip to content

Commit 2e05371

Browse files
reuse prom clientconfig tls field in grpc
1 parent 2095d80 commit 2e05371

File tree

7 files changed

+29
-84
lines changed

7 files changed

+29
-84
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,5 @@ require (
175175
)
176176

177177
replace github.com/vmware/go-ipfix => github.com/jotak/go-ipfix v0.0.0-20250708115123-407c539ea101
178+
179+
replace github.com/netobserv/loki-client-go => ../loki-client-go

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J
255255
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
256256
github.com/netobserv/gopipes v0.3.0 h1:IYmPnnAVCdSK7VmHmpFhrVBOEm45qpgbZmJz1sSW+60=
257257
github.com/netobserv/gopipes v0.3.0/go.mod h1:N7/Gz05EOF0CQQSKWsv3eof22Cj2PB08Pbttw98YFYU=
258-
github.com/netobserv/loki-client-go v0.0.0-20250929121122-f26971f6d948 h1:UqGWIz4zzJl/XKGpM44HIDuhRDBE1e4x4wbKO/WVb7g=
259-
github.com/netobserv/loki-client-go v0.0.0-20250929121122-f26971f6d948/go.mod h1:Zb/jtD3Lnu88Poo+jnhTASzxYnvncmHOoZaT93xQjJ8=
260258
github.com/netobserv/netobserv-ebpf-agent v1.9.2-community h1:ghW16OO4QRWj0Uh1gMYX+NjAlgx2sZmCsO3Tkwoj4Do=
261259
github.com/netobserv/netobserv-ebpf-agent v1.9.2-community/go.mod h1:17OaUNAwx0LxoeV/SaHlJIJP6bpN7zSvUP3GtZelESQ=
262260
github.com/netsampler/goflow2 v1.3.7 h1:XZaTy8kkMnGXpJ9hS3KbO1McyrFTpVNhVFEx9rNhMmc=

pkg/api/write_loki.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,8 @@ type WriteLoki struct {
5454
}
5555

5656
type GRPCLokiConfig struct {
57-
KeepAlive string `yaml:"keepAlive,omitempty" json:"keepAlive,omitempty" doc:"keep alive interval"`
58-
KeepAliveTimeout string `yaml:"keepAliveTimeout,omitempty" json:"keepAliveTimeout,omitempty" doc:"keep alive timeout"`
59-
TLS *GRPCTLSConfig `yaml:"tls,omitempty" json:"tls,omitempty" doc:"TLS configuration"`
60-
}
61-
62-
type GRPCTLSConfig struct {
63-
Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty" doc:"enable TLS"`
64-
CertFile string `yaml:"certFile,omitempty" json:"certFile,omitempty" doc:"path to client certificate file"`
65-
KeyFile string `yaml:"keyFile,omitempty" json:"keyFile,omitempty" doc:"path to client key file"`
66-
CAFile string `yaml:"caFile,omitempty" json:"caFile,omitempty" doc:"path to CA certificate file"`
67-
ServerName string `yaml:"serverName,omitempty" json:"serverName,omitempty" doc:"server name for certificate verification"`
68-
InsecureSkipVerify bool `yaml:"insecureSkipVerify,omitempty" json:"insecureSkipVerify,omitempty" doc:"skip certificate verification (insecure)"`
57+
KeepAlive string `yaml:"keepAlive,omitempty" json:"keepAlive,omitempty" doc:"keep alive interval"`
58+
KeepAliveTimeout string `yaml:"keepAliveTimeout,omitempty" json:"keepAliveTimeout,omitempty" doc:"keep alive timeout"`
6959
}
7060

7161
func (w *WriteLoki) SetDefaults() {

pkg/pipeline/write/write_loki.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,9 @@ func buildGRPCLokiConfig(c *api.WriteLoki) (grpc.Config, error) {
199199
cfg.ExternalLabels.LabelSet = c.StaticLabels
200200
}
201201

202-
// Configure TLS if provided
203-
if c.GRPCConfig.TLS != nil {
204-
cfg.TLS = grpc.TLSConfig{
205-
Enabled: c.GRPCConfig.TLS.Enabled,
206-
CertFile: c.GRPCConfig.TLS.CertFile,
207-
KeyFile: c.GRPCConfig.TLS.KeyFile,
208-
CAFile: c.GRPCConfig.TLS.CAFile,
209-
ServerName: c.GRPCConfig.TLS.ServerName,
210-
InsecureSkipVerify: c.GRPCConfig.TLS.InsecureSkipVerify,
211-
}
202+
// Configure TLS from shared ClientConfig (same as HTTP client)
203+
if c.ClientConfig != nil {
204+
cfg.TLS = c.ClientConfig.TLSConfig
212205
}
213206

214207
return cfg, nil

pkg/pipeline/write/write_loki_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/netobserv/flowlogs-pipeline/pkg/config"
3131
"github.com/netobserv/flowlogs-pipeline/pkg/operational"
3232
"github.com/netobserv/flowlogs-pipeline/pkg/test"
33+
promConfig "github.com/prometheus/common/config"
3334
"github.com/prometheus/common/model"
3435
"github.com/sirupsen/logrus"
3536
"github.com/stretchr/testify/assert"
@@ -391,18 +392,19 @@ func TestGRPCClientCreationWithTLS(t *testing.T) {
391392
URL: "loki.example.com:9095",
392393
ClientProtocol: "grpc",
393394
TenantID: "test-tenant",
394-
GRPCConfig: &api.GRPCLokiConfig{
395-
KeepAlive: "30s",
396-
KeepAliveTimeout: "5s",
397-
TLS: &api.GRPCTLSConfig{
398-
Enabled: true,
395+
ClientConfig: &promConfig.HTTPClientConfig{
396+
TLSConfig: promConfig.TLSConfig{
399397
CertFile: "/path/to/cert.pem",
400398
KeyFile: "/path/to/key.pem",
401399
CAFile: "/path/to/ca.pem",
402400
ServerName: "loki.example.com",
403401
InsecureSkipVerify: false,
404402
},
405403
},
404+
GRPCConfig: &api.GRPCLokiConfig{
405+
KeepAlive: "30s",
406+
KeepAliveTimeout: "5s",
407+
},
406408
}
407409

408410
// This test expects to fail due to missing certificate files

vendor/github.com/netobserv/loki-client-go/grpc/config.go

Lines changed: 13 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ github.com/mxk/go-flowrate/flowrate
305305
## explicit; go 1.18
306306
github.com/netobserv/gopipes/pkg/node
307307
github.com/netobserv/gopipes/pkg/node/internal/connect
308-
# github.com/netobserv/loki-client-go v0.0.0-20250929121122-f26971f6d948
308+
# github.com/netobserv/loki-client-go v0.0.0-20250929121122-f26971f6d948 => ../loki-client-go
309309
## explicit; go 1.23.0
310310
github.com/netobserv/loki-client-go/grpc
311311
github.com/netobserv/loki-client-go/loki
@@ -1404,3 +1404,4 @@ sigs.k8s.io/structured-merge-diff/v6/value
14041404
sigs.k8s.io/yaml
14051405
sigs.k8s.io/yaml/goyaml.v2
14061406
# github.com/vmware/go-ipfix => github.com/jotak/go-ipfix v0.0.0-20250708115123-407c539ea101
1407+
# github.com/netobserv/loki-client-go => ../loki-client-go

0 commit comments

Comments
 (0)