Skip to content

Commit

Permalink
Merge pull request #230 from rfratto/use-exporter-toolkit
Browse files Browse the repository at this point in the history
Replace node_exporter https package with exporter-toolkit
  • Loading branch information
bboreham authored Dec 22, 2021
2 parents a3bc5dd + d35bdeb commit 55ea099
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
node_https "github.com/prometheus/node_exporter/https"
"github.com/prometheus/exporter-toolkit/web"
"golang.org/x/net/context"
"golang.org/x/net/netutil"
"google.golang.org/grpc"
Expand Down Expand Up @@ -62,8 +62,8 @@ type Config struct {
GRPCListenPort int `yaml:"grpc_listen_port"`
GRPCConnLimit int `yaml:"grpc_listen_conn_limit"`

HTTPTLSConfig node_https.TLSStruct `yaml:"http_tls_config"`
GRPCTLSConfig node_https.TLSStruct `yaml:"grpc_tls_config"`
HTTPTLSConfig web.TLSStruct `yaml:"http_tls_config"`
GRPCTLSConfig web.TLSStruct `yaml:"grpc_tls_config"`

RegisterInstrumentation bool `yaml:"register_instrumentation"`
ExcludeRequestInLog bool `yaml:"-"`
Expand Down Expand Up @@ -235,16 +235,16 @@ func New(cfg Config) (*Server, error) {
// Setup TLS
var httpTLSConfig *tls.Config
if len(cfg.HTTPTLSConfig.TLSCertPath) > 0 && len(cfg.HTTPTLSConfig.TLSKeyPath) > 0 {
// Note: ConfigToTLSConfig from prometheus/node_exporter is awaiting security review.
httpTLSConfig, err = node_https.ConfigToTLSConfig(&cfg.HTTPTLSConfig)
// Note: ConfigToTLSConfig from prometheus/exporter-toolkit is awaiting security review.
httpTLSConfig, err = web.ConfigToTLSConfig(&cfg.HTTPTLSConfig)
if err != nil {
return nil, fmt.Errorf("error generating http tls config: %v", err)
}
}
var grpcTLSConfig *tls.Config
if len(cfg.GRPCTLSConfig.TLSCertPath) > 0 && len(cfg.GRPCTLSConfig.TLSKeyPath) > 0 {
// Note: ConfigToTLSConfig from prometheus/node_exporter is awaiting security review.
grpcTLSConfig, err = node_https.ConfigToTLSConfig(&cfg.GRPCTLSConfig)
// Note: ConfigToTLSConfig from prometheus/exporter-toolkit is awaiting security review.
grpcTLSConfig, err = web.ConfigToTLSConfig(&cfg.GRPCTLSConfig)
if err != nil {
return nil, fmt.Errorf("error generating grpc tls config: %v", err)
}
Expand Down
6 changes: 3 additions & 3 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
google_protobuf "github.com/golang/protobuf/ptypes/empty"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus"
node_https "github.com/prometheus/node_exporter/https"
"github.com/prometheus/exporter-toolkit/web"
"github.com/stretchr/testify/require"
"github.com/weaveworks/common/httpgrpc"
"github.com/weaveworks/common/logging"
Expand Down Expand Up @@ -522,13 +522,13 @@ func TestTLSServer(t *testing.T) {
HTTPListenNetwork: DefaultNetwork,
HTTPListenAddress: "localhost",
HTTPListenPort: 9193,
HTTPTLSConfig: node_https.TLSStruct{
HTTPTLSConfig: web.TLSStruct{
TLSCertPath: "certs/server.crt",
TLSKeyPath: "certs/server.key",
ClientAuth: "RequireAndVerifyClientCert",
ClientCAs: "certs/root.crt",
},
GRPCTLSConfig: node_https.TLSStruct{
GRPCTLSConfig: web.TLSStruct{
TLSCertPath: "certs/server.crt",
TLSKeyPath: "certs/server.key",
ClientAuth: "VerifyClientCertIfGiven",
Expand Down

0 comments on commit 55ea099

Please sign in to comment.