diff options
Diffstat (limited to 'src/go/plugin/go.d/modules/elasticsearch/init.go')
-rw-r--r-- | src/go/plugin/go.d/modules/elasticsearch/init.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/go/plugin/go.d/modules/elasticsearch/init.go b/src/go/plugin/go.d/modules/elasticsearch/init.go new file mode 100644 index 000000000..f87b594f8 --- /dev/null +++ b/src/go/plugin/go.d/modules/elasticsearch/init.go @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +package elasticsearch + +import ( + "errors" + "net/http" + + "github.com/netdata/netdata/go/plugins/plugin/go.d/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) +} |