summaryrefslogtreecommitdiffstats
path: root/src/go/collectors/go.d.plugin/modules/elasticsearch/init.go
blob: 955d9c3a20dd54ffffbebe3486ca56b5a5b02197 (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
// SPDX-License-Identifier: GPL-3.0-or-later

package elasticsearch

import (
	"errors"
	"net/http"

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

func (es *Elasticsearch) validateConfig() error {
	if es.URL == "" {
		return errors.New("URL not set")
	}
	if !(es.DoNodeStats || es.DoClusterHealth || es.DoClusterStats || es.DoIndicesStats) {
		return errors.New("all API calls are disabled")
	}
	if _, err := web.NewHTTPRequest(es.Request); err != nil {
		return err
	}
	return nil
}

func (es *Elasticsearch) initHTTPClient() (*http.Client, error) {
	return web.NewHTTPClient(es.Client)
}