Please don't paste graphical screenshots: they are hard to read, and it's impossible to copy-paste them to make corrections.
First thing is, you're scraping port 9090 but you haven't told it to use HTTPS. You need setting "
scheme: https" in the scrape job.
Secondly, you've set up TLS wrongly, although it may work given that you have "insecure_skip_verify: true".
- At the *server* side you need tls_server_config with cert_file and key_file, which is as you have it.
- At the *client* side (which in this case is prometheus making an outbound scrape connection to itself), you don't want cert_file or key_file; you need ca_file. This points to the certificate file of the certificate authority which signed the example.com.crt certificate. If this is a self-signed certificate, then this is the same certificate, i.e. "ca_file: example.com.crt"
Thirdly, you're connecting to the host using name "localhost", but this will only verify successfully if the certificate contains "localhost" as one of its SubjectAltNames. You should connect using whatever name you signed for the certificate. Or, you can use the "server_name: ..." setting in tls_config to say what name to expect in the certificate presented by the server. Again, "insecure_skip_verify" will probably skip this check.
(But of course, really you don't want to use "insecure_skip_verify". Why are you deploying TLS at all, if you're doing it in an insecure way?)
Fourthly, you didn't show how you generated the certificates. With modern versions of Go (and hence recent versions of Prometheus), the certificate CommonName is ignored. The server *must* have a certificate with at least one SubjectAltName. So if you followed an out-of-date how-to for signing certificates, you probably made a bad certificate.
This is what I use:
mkdir /etc/prometheus/ssl
cd /etc/prometheus/ssl
openssl genpkey -genparam -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out p-256.param
openssl req -x509 -newkey ec:p-256.param -keyout prometheus_key.pem -out prometheus_cert.pem -days 29220 -nodes -subj /commonName=prometheus/ -addext "subjectAltName=DNS:prometheus"
In "/commonName=prometheus/" and "DNS:prometheus", replace "prometheus" with the hostname you want in the certificate. "localhost" would work, but apart from self-scraping, normally your clients are connecting to the prometheus server using some real fully-qualified domain name not "localhost", so you should use that FQDN.