Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit 32cadf8

Browse files
committed
Merge pull request #1558 from tureus/elasticsearch-url-path-support
Support for path in elasticsearch server config
2 parents 98e1573 + f0cf4a0 commit 32cadf8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

CHANGES.txt

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Bug Handling
8787

8888
* Added ability to reconnect after lost connection in `heka-flood` (#1536).
8989

90+
* Respect ElasticSearch URL path (#1558).
9091

9192
0.9.3 (2015-??-??)
9293
==================

plugins/elasticsearch/elasticsearch.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (o *ElasticSearchOutput) Init(config interface{}) (err error) {
143143
}
144144
}
145145

146-
o.bulkIndexer = NewHttpBulkIndexer(scheme, serverUrl.Host,
146+
o.bulkIndexer = NewHttpBulkIndexer(scheme, serverUrl.Host, serverUrl.Path,
147147
o.conf.FlushCount, o.conf.Username, o.conf.Password, o.conf.HTTPTimeout,
148148
o.conf.HTTPDisableKeepalives, o.conf.ConnectTimeout, tlsConf)
149149
case "udp":
@@ -403,6 +403,8 @@ type HttpBulkIndexer struct {
403403
Protocol string
404404
// Host name and port number (default to "localhost:9200").
405405
Domain string
406+
// Path (default to "")
407+
Path string
406408
// Maximum number of documents.
407409
MaxCount int
408410
// Internal HTTP Client.
@@ -413,7 +415,7 @@ type HttpBulkIndexer struct {
413415
password string
414416
}
415417

416-
func NewHttpBulkIndexer(protocol string, domain string, maxCount int,
418+
func NewHttpBulkIndexer(protocol string, domain string, path string, maxCount int,
417419
username string, password string, httpTimeout uint32, httpDisableKeepalives bool,
418420
connectTimeout uint32, tlsConf *tls.Config) *HttpBulkIndexer {
419421

@@ -432,6 +434,7 @@ func NewHttpBulkIndexer(protocol string, domain string, maxCount int,
432434
return &HttpBulkIndexer{
433435
Protocol: protocol,
434436
Domain: domain,
437+
Path: path,
435438
MaxCount: maxCount,
436439
client: client,
437440
username: username,
@@ -450,7 +453,7 @@ func (h *HttpBulkIndexer) Index(body []byte) (err error, retry bool) {
450453
var response_body []byte
451454
var response_body_json map[string]interface{}
452455

453-
url := fmt.Sprintf("%s://%s%s", h.Protocol, h.Domain, "/_bulk")
456+
url := fmt.Sprintf("%s://%s%s%s", h.Protocol, h.Domain, h.Path, "/_bulk")
454457

455458
// Creating ElasticSearch Bulk HTTP request
456459
request, err := http.NewRequest("POST", url, bytes.NewReader(body))

0 commit comments

Comments
 (0)