Skip to content
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

monstache can not connect to elasticsearch v8 docker compose #623

Closed
AsedMorteza opened this issue Jul 14, 2022 · 6 comments
Closed

monstache can not connect to elasticsearch v8 docker compose #623

AsedMorteza opened this issue Jul 14, 2022 · 6 comments

Comments

@AsedMorteza
Copy link

AsedMorteza commented Jul 14, 2022

hi @rwynn
When I use version 7 of Elastic and Kibana in Docker Compose, everything is fine, but when I change the version of the image file to 8, this error is displayed:

c-monstache | ERROR 2022/07/14 11:05:55 Unable to create Elasticsearch client: health check timeout: Head "http://es7:9200": dial tcp 172.20.0.2:9200: connect: connection refused: no Elasticsearch node available

@rwynn
Copy link
Owner

rwynn commented Jul 14, 2022

It may be because in Elasticsearch 8 security is enabled by default.
https://www.elastic.co/guide/en/elasticsearch/reference/current/manually-configure-security.html

You can configure monstache using config options elasticsearch-user / elasticsearch-password OR elasticsearch-pki-auth and transport level security with elasticsearch-pem-file and elasticsearch-validate-pem-file.

https://rwynn.github.io/monstache-site/config/

@AsedMorteza
Copy link
Author

thanks for the reply
According to the content in the file elasticsearch.yml :

Enable security features

xpack.security.enabled: true
xpack.security.enrollment.enabled: true

Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents

xpack.security.http.ssl:
enabled: true
keystore.path: certs/http.p12

Enable encryption and mutual authentication between cluster nodes

xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12

What should my config be like?
Thanks

@AsedMorteza
Copy link
Author

AsedMorteza commented Jul 17, 2022

It may be because in Elasticsearch 8 security is enabled by default. https://www.elastic.co/guide/en/elasticsearch/reference/current/manually-configure-security.html

You can configure monstache using config options elasticsearch-user / elasticsearch-password OR elasticsearch-pki-auth and transport level security with elasticsearch-pem-file and elasticsearch-validate-pem-file.

https://rwynn.github.io/monstache-site/config/

hi @rwynn
when (elasticsearch-pem-file = "/etc/elasticsearch/certs/transport.p12")
print this message:
Unable to create Elasticsearch client: open /etc/elasticsearch/certs/transport.p12: permission denied

and when ( [elasticsearch-pki-auth]
cert-file = "/etc/elasticsearch/certs/http_ca.crt")
print :
ERROR 2022/07/17 16:59:21 Unable to create Elasticsearch client: Elasticsearch client auth key file is empty

can you please help me ...

@rwynn
Copy link
Owner

rwynn commented Jul 17, 2022

Monstache only connects via the http/https endpoint. So you can generate a pem file and then reference that in your monstache config.

This configuration worked for me on a new Elasticsearch 8 install:

elasticsearch-urls = [ "https://localhost:9200" ]

elasticsearch-user="elastic"
elasticsearch-password="paste here"

elasticsearch-pem-file = "/home/ubuntu/http.pem"
elasticsearch-validate-pem-file = false
  • regenerate a password as root for the elastic user if you don't already know it. Copy the output to your monstache config file replacing "paste here".
cd /usr/share/elasticsearch
bin/elasticsearch-reset-password -u elastic
  • generate the pem file from the elasticsearch files as root (in 3rd command use output from 2nd command):
cd /usr/share/elasticsearch
bin/elasticsearch-keystore show xpack.security.http.ssl.keystore.secure_password
openssl pkcs12 -in /etc/elasticsearch/certs/http.p12 -out /home/ubuntu/http.pem -nodes
chmod 644 /home/ubuntu/http.pem

@rwynn
Copy link
Owner

rwynn commented Jul 17, 2022

In your case the url to connect in docker compose would be https://es7:9200. Notice that is https not http.
You can mount the pem file as a volume into the monstache docker container.

@AsedMorteza
Copy link
Author

@rwynn Thank you for your wonderful help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants