Skip to content
Snippets Groups Projects
Unverified Commit 5f3c1b2f authored by Mohamed S. Mahmoud's avatar Mohamed S. Mahmoud Committed by GitHub
Browse files

NETOBSERV-1532: add TLS support to ebpf agent metrics config (#305)

parent b63f1dd6
No related branches found
No related tags found
No related merge requests found
...@@ -156,6 +156,12 @@ func FlowsAgent(cfg *Config) (*Flows, error) { ...@@ -156,6 +156,12 @@ func FlowsAgent(cfg *Config) (*Flows, error) {
}, },
Prefix: cfg.MetricsPrefix, Prefix: cfg.MetricsPrefix,
} }
if cfg.MetricsTLSCertPath != "" && cfg.MetricsTLSKeyPath != "" {
metricsSettings.PromConnectionInfo.TLS = &metrics.PromTLS{
CertPath: cfg.MetricsTLSCertPath,
KeyPath: cfg.MetricsTLSKeyPath,
}
}
m := metrics.NewMetrics(metricsSettings) m := metrics.NewMetrics(metricsSettings)
// configure selected exporter // configure selected exporter
......
...@@ -175,6 +175,10 @@ type Config struct { ...@@ -175,6 +175,10 @@ type Config struct {
MetricsServerAddress string `env:"METRICS_SERVER_ADDRESS"` MetricsServerAddress string `env:"METRICS_SERVER_ADDRESS"`
// MetricsPort is the port of the server that collects ebpf agent metrics. // MetricsPort is the port of the server that collects ebpf agent metrics.
MetricsPort int `env:"METRICS_SERVER_PORT" envDefault:"9090"` MetricsPort int `env:"METRICS_SERVER_PORT" envDefault:"9090"`
// MetricsTLSCertPath is the path to the server certificate for TLS connections
MetricsTLSCertPath string `env:"METRICS_TLS_CERT_PATH"`
// MetricsTLSKeyPath is the path to the server private key for TLS connections
MetricsTLSKeyPath string `env:"METRICS_TLS_KEY_PATH"`
// MetricsPrefix is the prefix of the metrics that are sent to the server. // MetricsPrefix is the prefix of the metrics that are sent to the server.
MetricsPrefix string `env:"METRICS_PREFIX" envDefault:"ebpf_agent_"` MetricsPrefix string `env:"METRICS_PREFIX" envDefault:"ebpf_agent_"`
......
...@@ -14,9 +14,15 @@ type MetricDefinition struct { ...@@ -14,9 +14,15 @@ type MetricDefinition struct {
Labels []string Labels []string
} }
type PromTLS struct {
CertPath string
KeyPath string
}
type PromConnectionInfo struct { type PromConnectionInfo struct {
Address string Address string
Port int Port int
TLS *PromTLS
} }
type Settings struct { type Settings struct {
......
...@@ -53,7 +53,12 @@ func StartServerAsync(conn *metrics.Settings, registry *prom.Registry) *http.Ser ...@@ -53,7 +53,12 @@ func StartServerAsync(conn *metrics.Settings, registry *prom.Registry) *http.Ser
httpServer = defaultServer(httpServer) httpServer = defaultServer(httpServer)
go func() { go func() {
err := httpServer.ListenAndServe() var err error
if conn.TLS != nil {
err = httpServer.ListenAndServeTLS(conn.TLS.CertPath, conn.TLS.KeyPath)
} else {
err = httpServer.ListenAndServe()
}
if err != nil && err != http.ErrServerClosed { if err != nil && err != http.ErrServerClosed {
maybePanic("error in http.ListenAndServe: %v", err) maybePanic("error in http.ListenAndServe: %v", err)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment