Skip to content

Commit

Permalink
fix[elasticsearch output]: add scheme to fix error in sniffing option (
Browse files Browse the repository at this point in the history
…#10513)

(cherry picked from commit 5c8751f)
  • Loading branch information
zpriddy authored and powersj committed Feb 16, 2022
1 parent eaa5e11 commit c949d7d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/LICENSE_OF_DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ following works:
- github.com/nats-io/nuid [Apache License 2.0](https://github.com/nats-io/nuid/blob/master/LICENSE)
- github.com/newrelic/newrelic-telemetry-sdk-go [Apache License 2.0](https://github.com/newrelic/newrelic-telemetry-sdk-go/blob/master/LICENSE.md)
- github.com/nsqio/go-nsq [MIT License](https://github.com/nsqio/go-nsq/blob/master/LICENSE)
- github.com/olivere/elastic [MIT License](https://github.com/olivere/elastic/blob/release-branch.v7/LICENSE)
- github.com/openconfig/gnmi [Apache License 2.0](https://github.com/openconfig/gnmi/blob/master/LICENSE)
- github.com/opencontainers/go-digest [Apache License 2.0](https://github.com/opencontainers/go-digest/blob/master/LICENSE)
- github.com/opencontainers/image-spec [Apache License 2.0](https://github.com/opencontainers/image-spec/blob/master/LICENSE)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ require (
github.com/nats-io/nats.go v1.13.1-0.20211018182449-f2416a8b1483
github.com/newrelic/newrelic-telemetry-sdk-go v0.5.1
github.com/nsqio/go-nsq v1.1.0
github.com/olivere/elastic v6.2.37+incompatible
github.com/openconfig/gnmi v0.0.0-20180912164834-33a1865c3029
github.com/opentracing/opentracing-go v1.2.0
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,7 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
github.com/olivere/elastic v6.2.35+incompatible/go.mod h1:J+q1zQJTgAz9woqsbVRqGeB5G1iqDKVBWLNSYW8yfJ8=
github.com/olivere/elastic v6.2.37+incompatible h1:UfSGJem5czY+x/LqxgeCBgjDn6St+z8OnsCuxwD3L0U=
github.com/olivere/elastic v6.2.37+incompatible/go.mod h1:J+q1zQJTgAz9woqsbVRqGeB5G1iqDKVBWLNSYW8yfJ8=
github.com/onsi/ginkgo v0.0.0-20151202141238-7f8ab55aaf3b/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
10 changes: 9 additions & 1 deletion plugins/outputs/elasticsearch/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import (
"fmt"
"math"
"net/http"
"net/url"
"strconv"
"strings"
"text/template"
"time"

"crypto/sha256"
"gopkg.in/olivere/elastic.v5"

"github.com/olivere/elastic"

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/config"
Expand Down Expand Up @@ -216,9 +218,15 @@ func (a *Elasticsearch) Connect() error {
Timeout: time.Duration(a.Timeout),
}

elasticURL, err := url.Parse(a.URLs[0])
if err != nil {
return fmt.Errorf("parsing URL failed: %v", err)
}

clientOptions = append(clientOptions,
elastic.SetHttpClient(httpclient),
elastic.SetSniff(a.EnableSniffer),
elastic.SetScheme(elasticURL.Scheme),
elastic.SetURL(a.URLs...),
elastic.SetHealthcheckInterval(time.Duration(a.HealthCheckInterval)),
elastic.SetGzip(a.EnableGzip),
Expand Down

0 comments on commit c949d7d

Please sign in to comment.