github.com/netdata/go.d.plugin@v0.58.1/modules/traefik/init.go (about)

     1  // SPDX-License-Identifier: GPL-3.0-or-later
     2  
     3  package traefik
     4  
     5  import (
     6  	"errors"
     7  
     8  	"github.com/netdata/go.d.plugin/pkg/prometheus"
     9  	"github.com/netdata/go.d.plugin/pkg/prometheus/selector"
    10  	"github.com/netdata/go.d.plugin/pkg/web"
    11  )
    12  
    13  func (t Traefik) validateConfig() error {
    14  	if t.URL == "" {
    15  		return errors.New("'url' is not set")
    16  	}
    17  	return nil
    18  }
    19  
    20  func (t Traefik) initPrometheusClient() (prometheus.Prometheus, error) {
    21  	httpClient, err := web.NewHTTPClient(t.Client)
    22  	if err != nil {
    23  		return nil, err
    24  	}
    25  
    26  	prom := prometheus.NewWithSelector(httpClient, t.Request, sr)
    27  	return prom, nil
    28  }
    29  
    30  var sr, _ = selector.Expr{
    31  	Allow: []string{
    32  		metricEntrypointRequestDurationSecondsSum,
    33  		metricEntrypointRequestDurationSecondsCount,
    34  		metricEntrypointRequestsTotal,
    35  		metricEntrypointOpenConnections,
    36  	},
    37  }.Parse()