summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/modules/traefik/init.go
blob: df4765c9144b483cf671b2fecb210d49fff403ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: GPL-3.0-or-later

package traefik

import (
	"errors"

	"github.com/netdata/netdata/go/go.d.plugin/pkg/prometheus"
	"github.com/netdata/netdata/go/go.d.plugin/pkg/prometheus/selector"
	"github.com/netdata/netdata/go/go.d.plugin/pkg/web"
)

func (t Traefik) validateConfig() error {
	if t.URL == "" {
		return errors.New("'url' is not set")
	}
	return nil
}

func (t Traefik) initPrometheusClient() (prometheus.Prometheus, error) {
	httpClient, err := web.NewHTTPClient(t.Client)
	if err != nil {
		return nil, err
	}

	prom := prometheus.NewWithSelector(httpClient, t.Request, sr)
	return prom, nil
}

var sr, _ = selector.Expr{
	Allow: []string{
		metricEntrypointRequestDurationSecondsSum,
		metricEntrypointRequestDurationSecondsCount,
		metricEntrypointRequestsTotal,
		metricEntrypointOpenConnections,
	},
}.Parse()