dqwmhrxt68679 2019-09-17 01:55
浏览 116

elogrus找不到活动的连接

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
    • ¥15 gradio的web端页面格式不对的问题
    • ¥15 求大家看看Nonce如何配置
    • ¥15 Matlab怎么求解含参的二重积分?
    • ¥15 苹果手机突然连不上wifi了?
    • ¥15 cgictest.cgi文件无法访问
    • ¥20 删除和修改功能无法调用
    • ¥15 kafka topic 所有分副本数修改
    • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
    • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?