2

I'm using elasticsearch, kibana on docker, and Go.

time="2019-09-17T09:52:02+08:00" level=panic msg="no active connection found: no Elasticsearch node available" panic: (*logrus.Entry) (0x736fe0,0xc000136150)

import (
"github.com/olivere/elastic/v7"
"github.com/sirupsen/logrus"
"gopkg.in/sohlich/elogrus.v7"
)

func main() {
 log := logrus.New()
 client, err := elastic.NewClient(elastic.SetURL("http://localhost:9200"))
if err != nil {
    log.Panic(err)
}
 hook, err := elogrus.NewAsyncElasticHook(client, "localhost", logrus.DebugLevel, "mylog")
 if err != nil {
    log.Panic(err)
}
 log.Hooks.Add(hook)

 log.WithFields(logrus.Fields{
    "name": "joe",
    "age":  42,
 }).Error("Hello world!")
}

This is the package I'm using https://github.com/sohlich/elogrus

enter image description here

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Elliot
  • 598
  • 6
  • 25

1 Answers1

2

You have to authenticate, if you didn't change default password you might use something like this: Also set off the sniff. More details about it: https://github.com/olivere/elastic/wiki/Sniffing

client, err := elastic.NewClient(
    elastic.SetBasicAuth("elastic", "changeme"),
    elastic.SetURL("http://localhost:9200"),
    elastic.SetSniff(false),
)
Aliaksandr
  • 129
  • 4