Created on 12-10-2019 03:49 AM - edited on 01-04-2021 04:50 AM by K23
This articles describe the steps required to complete the setup for accessing Grafana using HTTPS with CA Signed Certificates.
Ambari Metrics System includes Grafana, which is a daemon that runs on a specific host in the cluster and serves pre-built dashboards for visualising metrics collected in the Metrics Collector.
For this article the following servers is used:
By default, Grafana listen on port TCP/3000:
# for i in $(netstat -utnlp | awk '/grafana/ {print substr($7, 1, length($7)-13)}' | sort -u) ; do echo ; ps -eo pid,user,command --cols 128 | grep $i | grep -v grep ; netstat -utnlp | grep $i ; echo ; done 270925 ams /usr/lib/ambari-metrics-grafana/bin/grafana-server --pidfile=/var/run/ambari-metrics-grafana/grafana-server.pid tcp6 0 0 :::3000 :::* LISTEN 270925/grafana-serv
Here, the process running is grafana-server, the owner is ams, and is listening on port TCP/3000. All the configurations for Grafana are handled by Ambari, and are reflected in the ams-grafana.ini file located at /etc/ambari-metrics-grafana/conf/ directory. Grafana needs to be restarted for any configuration changes to take effect.
In enterprises where security is required, limit the Grafana access to only HTTPS connections. To enable https for Grafana, update the following properties:
AmbariUI / Services / Ambari Metrics / Configs -> Advanced ams-grafana-ini
For this article, the CA will provide us with a certificate bundle located at:
/var/tmp/certificates/GRAFANA
Since the certificate information provided by the CA is a PKCS#12 certificate bundle, complete the following steps:
openssl pkcs12 -in c3132-node2.user.local.p12 -out ams-ca.crt -cacerts -nokeys -passin pass:hadoop1234
openssl pkcs12 -in c3132-node2.user.local.p12 -out ams-grafana.crt -clcerts -nokeys -passin pass:hadoop1234
openssl pkcs12 -in c3132-node2.user.local.p12 -nocerts -nodes -out ams-grafana.key -passin pass:hadoop1234
cp ams-*.* /etc/ambari-metrics-grafana/conf/ chown ams:hadoop /etc/ambari-metrics-grafana/conf/ams-*.*
AmbariUI / Services / Ambari Metrics / Configs -> Advanced ams-grafana-ini protocol = https ca_cert = /etc/ambari-metrics-grafana/conf/ams-ca.crt cert_file = /etc/ambari-metrics-grafana/conf/ams-grafana.crt cert_key = /etc/ambari-metrics-grafana/conf/ams-grafana.key
tail -f /var/log/ambari-metrics-grafana/grafana.log
2018/12/12 03:42:41 [I] Listen: https://0.0.0.0:3000
openssl s_client -connect c3132-node2.user.local:3000 </dev/null
AmbariUI / Services / Ambari Metrics / Summary -> Quick Link GrafanaNote: Ignore the warning and proceed.
With all these steps, Grafana is configured to be used with CA Signed certificates and the communication will be is over HTTPS.