elogrus 未找到活动连接
时间:2024-04-06
浏览:496
作者:佚名
大家好,今天本人给大家带来文章《elogrus 未找到活动连接》,文中内容主要涉及到,如果你对Golang方面的知识点感兴趣,那就请各位朋友继续看下去吧~希望能真正帮到你们,谢谢!
问题内容
我正在使用 elasticsearch、docker 上的 kibana 和 go。
time="2019-09-17t09:52:02+08:00" level=panic msg="未找到活动连接:没有可用的 elasticsearch 节点" 恐慌:(*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!")
}
这是我正在使用的包 https://github.com/sohlich/elogrus
解决方案
您必须进行身份验证,如果您没有更改默认密码,您可能会使用如下内容: 还引爆了嗅觉。更多详情:https://github.com/olivere/elastic/wiki/Sniffing
client, err := elastic.NewClient(
elastic.SetBasicAuth("elastic", "changeme"),
elastic.SetURL("http://localhost:9200"),
elastic.SetSniff(false),
)好了,本文到此结束,带大家了解了《elogrus 未找到活动连接》,希望本文对你有所帮助!关注golang学习网公众号,给大家分享更多Golang知识!
本文内容来源于互联网,如有侵权请联系删除。
近期热门
11.18
11.15
站内热门
最新文章
热门专题
