master
go 37 lines 855 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package traefik
4
5 import (
6 "errors"
7
8 "github.com/netdata/netdata/go/plugins/pkg/prometheus"
9 "github.com/netdata/netdata/go/plugins/pkg/prometheus/selector"
10 "github.com/netdata/netdata/go/plugins/pkg/web"
11 )
12
13 func (c *Collector) validateConfig() error {
14 if c.URL == "" {
15 return errors.New("'url' is not set")
16 }
17 return nil
18 }
19
20 func (c *Collector) initPrometheusClient() (prometheus.Prometheus, error) {
21 httpClient, err := web.NewHTTPClient(c.ClientConfig)
22 if err != nil {
23 return nil, err
24 }
25
26 prom := prometheus.NewWithSelector(httpClient, c.RequestConfig, 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()