elogrus | Logrus Hook for ElasticSearch
kandi X-RAY | elogrus Summary
kandi X-RAY | elogrus Summary
Logrus Hook for ElasticSearch
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of elogrus
elogrus Key Features
elogrus Examples and Code Snippets
Community Discussions
Trending Discussions on elogrus
QUESTION
I just cannot understand what is happening. My go application is unable to connect to elastic search. The node is available, is up and running. What am I doing wrong here?
...ANSWER
Answered 2020-Apr-27 at 14:23Error no active connection found: no Elasticsearch node available
usually happens when you keep sniffing in client enabled but your cluster doesn't have any nodes available. You can check status of your cluster by hitting: http://host:port/_nodes/http?pretty=true
.
If you don't disable sniffing elastic
Golang client will run process in background that polls /_nodes
API (URL above) every 15 minutes and maintains list of healthy nodes. If there are no healthy nodes it ends with this error.
This can happen (NOTE: we had chat with OP where we debugged issue) also when your cluster is configured with private IPs (so in /_nodes
API output you see private and not public IPs). Client with sniffing starts polling, gets the list of nodes and tries to connect to private IP but gets HTTP error because such node doesn't respond (or can't be even resolved in network where client is). So it marks it dead and progresses to other one. When there are no further nodes in cluster it reports no active connection found: no Elasticsearch node available
.
To disable sniffing on client side (and to connect directly to specified node - but without any resiliency) you need to add &sniff=false
to Elastic URL.
Connection can without sniffing can be done like this:
QUESTION
I am using logrus
to do all the logging my golang application. However, I also want to integrate this with Elastic Search such that all the logs are also flushed to elastic search when I create a logrus log entry. Currently all logs are created in a file as shown in the snippet below. How could I integrate with elastic search?
ANSWER
Answered 2020-Apr-27 at 11:33With elogrus
you first create Elastic client and pass it to elogrus
hook when creating it with elogrus.NewAsyncElasticHook()
. Hook just wraps sending message to Elastic. Then you add this hook to logrus
log
. Every time you log message using log
it will fire your hook and send message (if log level filter passes) to Elastic.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install elogrus
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page