Hi Team, I am trying to use external metric report...
# troubleshooting
a
Hi Team, I am trying to use external metric reporter for flink, but I am getting the following error:
Copy code
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Has anyone faced the same issue, How to resolve it, do I need to add some new certificates to cacerts? Thanks
z
Hey @Amenreet Singh Sodhi This error typically occurs when the SSL/TLS certificate of the external metric reporter server is not trusted by the Java runtime that is running your Flink job. To resolve this issue, you can either import the certificate of the external metric reporter server into the JRE's truststore (cacerts) or disable certificate validation altogether.
To import the certificate into the truststore, you can use the keytool command that comes with the JDK. Example command to import a certificate from a file called external_metrics.crt:
Copy code
keytool -import -alias external_metrics -file external_metrics.crt -keystore $JAVA_HOME/jre/lib/security/cacerts
You will be prompted to enter the keystore password, which is typically "changeit" for the cacerts file by default. (But here is a link about it: https://backstage.forgerock.com/knowledge/kb/article/a40125620 )
Alternatively, you can disable certificate validation by configuring a custom SSLContext for the HttpClient used by Flink metric reporter. This can be done by adding the following code snippet to your Flink job configuration:
Copy code
import javax.net.ssl.SSLContext;
import org.apache.flink.shaded.okhttp3.OkHttpClient;

OkHttpClient client = new OkHttpClient.Builder()
    .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustAllCerts)
    .hostnameVerifier((hostname, session) -> true)
    .build();
(however, disabling certificate validation is not recommended for production use, as it can leave your application vulnerable to man-in-the-middle attacks)
a
Thanks for the help, Have added the requried certificates. Now able to see data in external metrics
✅ 1