New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't connect to elasticsearch #170
Comments
@kagashe Have you followed the recommended config settings on Elasticsearch? Can you please describe enough info to replicate this behavior:
|
Using the latest version of dejavu that comes with docker. Added the following lines to my elasticsearch.yml http.cors.allow-origin: "http://localhost:1358" where can I check for errors? |
@kagashe Thanks, that is helpful. Your config is good, what exact URL are you running dejavu on? You would check errors from the browser console (like Google Chrome) where you are running dejavu on http://localhost:1358. |
This seems to be the error? Failed to load http://elk/printlogs/_mapping?: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://elk:1358' is therefore not allowed access. The response had HTTP status code 401. |
@kagashe Change your config to allow access to where you are using dejavu. It would be:
Enjoy! |
Seem to be getting the same error? |
Did you change your Elasticsearch config file and redeploy the cluster? |
Yes, changed the config and restarted the elasticsearch service. |
@kagashe can you tell me what the browser error looks like now? |
vendor.min.js:11 OPTIONS http://elk/printlogs/_mapping 401 (Unauthorized) |
Any Ideas? |
@kagashe The logs still point to Dejavu hosted domain not being whitelisted in the Elasticsearch's config. There are some things to check on:
|
My ELK stack isn't running in docker it's installed direct into ubuntu |
Can you try with
|
if I add http.cors.allow-origin="/./" the service doesn't start. |
Can you try with * included?
* is the important character here, which allows wildcard domains to connect to your ES cluster. Reference: elastic/elasticsearch#9031 (comment). |
vendor.min.js:7 OPTIONS http://elk/printlogs/_mapping? 401 (Unauthorized) |
curl -H "User-Agent: Mozilla" -H "Origin: 192.168.1.53" -i localhost:9200 { |
@kagashe I tried by downloading the latest Elasticsearch 6.2.2 and these are the settings that work:
GETing / returns
And a screenshot from dejavu on how I am connecting it: Note: Here, |
vendor.min.js:7 OPTIONS http://elk:9200/printlogs//_search?from=0&size=0 net::ERR_CONNECTION_REFUSED |
What does your entire elasticsearch.yml config file look like? Have you made any changes from the default configs? |
`# ======================== Elasticsearch Configuration ========================= NOTE: Elasticsearch comes with reasonable defaults for most settings.Before you set out to tweak and tune the configuration, make sure youunderstand what are you trying to accomplish and the consequences.The primary way of configuring a node is via this file. This template liststhe most important settings you may want to configure for a production cluster.Please consult the documentation for further information on configuration options:https://www.elastic.co/guide/en/elasticsearch/reference/index.html---------------------------------- Cluster -----------------------------------Use a descriptive name for your cluster:#cluster.name: my-application ------------------------------------ Node ------------------------------------Use a descriptive name for the node:#node.name: node-1 Add custom attributes to the node:#node.attr.rack: r1 ----------------------------------- Paths ------------------------------------Path to directory where to store the data (separate multiple locations by comma):path.data: /var/lib/elasticsearch Path to log files:path.logs: /var/log/elasticsearch ----------------------------------- Memory -----------------------------------Lock the memory on startup:bootstrap.memory_lock: true Make sure that the heap size is set to about half the memory availableon the system and that the owner of the process is allowed to use thislimit.Elasticsearch performs poorly when the system is swapping the memory.---------------------------------- Network -----------------------------------Set the bind address to a specific IP (IPv4 or IPv6):network.host: localhost Set a custom port for HTTP:http.port: 9200 For more information, consult the network module documentation.--------------------------------- Discovery ----------------------------------Pass an initial list of hosts to perform discovery when new node is started:The default list of hosts is ["127.0.0.1", "[::1]"]#discovery.zen.ping.unicast.hosts: ["host1", "host2"] Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):#discovery.zen.minimum_master_nodes: For more information, consult the zen discovery module documentation.---------------------------------- Gateway -----------------------------------Block initial recovery after a full cluster restart until N nodes are started:#gateway.recover_after_nodes: 3 For more information, consult the gateway module documentation.---------------------------------- Various -----------------------------------Require explicit names when deleting indices:#action.destructive_requires_name: true ` |
@kagashe This looks fine. Your Elasticsearch should let Dejavu connect with it. Another thing I am wondering is if you have any other IP Tables / Network config that might be blocking CORS by default? |
There isn't as far as I can see, have disabled firewall on my laptop and the elastic-search server just to test and still can't connect... |
my elk stack is running behind an nginx setup, would that affect anything? |
That may, if your nginx config doesn't support CORS. One easy way to debug this is going in steps: If you run a raw ES cluster and connect it with dejavu, can you do that? If yes, then the problem simplifies to figuring out the right nginx settings. If no, we can help you with that and that would also be easier for us to replicate. |
@kagashe did the above help? Any other updates? |
Hey @siddharthlatest
|
I figured it out, now it works:
|
@al-serebrov Awesome! I was just going to link to a similar doc - https://enable-cors.org/server_nginx.html. @kagashe I believe the above should work. |
I hope you can help me: I get the same error, and since I use a docker i have have no nginx/apache? |
Stupid! turning off the toggle: record analytics did the job: it works now :-) |
Cors BYpassIn case you do not have access to update the remote Elastic Cluster repo,
|
Have installed via Docker
Can't connect to elasticsearch instance
My elasticsearch installation is on a separate machine. when logging in, loading screen just loops.
The text was updated successfully, but these errors were encountered: