ribbybibby / ssl_exporter

Exports Prometheus metrics for TLS certificates
Apache License 2.0
507 stars 95 forks source link

Prometheus not scraping a file job #67

Closed zakiharis closed 3 years ago

zakiharis commented 3 years ago

I'm using a file probe.

After adding the job and reload the Prometheus config, Prometheus didn't scrape the job. No errors are thrown by Prometheus.

is my config correct?

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['prometheus:9090']

  - job_name: 'certificates exporter'
    metrics_path: /probe
    params:
      module: [ "file" ]
      target: [ "/root/certificates/*.pem" ]
    relabel_configs:
      - target_label: __address__
        replacement: 127.0.0.1:9219  # ssl-exporter

up{} only show Prometheus job, no certificates exporter job

Also no errors if curl the ssl-exporter

$ curl "localhost:9219/probe?module=file&target=/root/certificates/*.pem"

# HELP ssl_file_cert_not_after NotAfter expressed as a Unix Epoch Time for a certificate found in a file
# TYPE ssl_file_cert_not_after gauge
ssl_file_cert_not_after{} 2.06835186e+09
ssl_file_cert_not_after{} 1.92588785e+09
# HELP ssl_file_cert_not_before NotBefore expressed as a Unix Epoch Time for a certificate found in a file
# TYPE ssl_file_cert_not_before gauge
ssl_file_cert_not_before{} 1.59531186e+09
ssl_file_cert_not_before{} 1.61052785e+09
# HELP ssl_probe_success If the probe was a success
# TYPE ssl_probe_success gauge
ssl_probe_success 1
# HELP ssl_prober The prober used by the exporter to connect to the target
# TYPE ssl_prober gauge
ssl_prober{prober="file"} 1
ribbybibby commented 3 years ago

You aren't defining any targets with your certificates exporter config. This should work:

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['prometheus:9090']

  - job_name: 'certificates exporter'
    metrics_path: /probe
    params:
      module: [ "file" ]
      target: [ "/root/certificates/*.pem" ]
    static_configs:
      - targets: ['127.0.0.1:9219']
zakiharis commented 3 years ago

ah, silly mistake.

its works now

thank you sir