Search code examples
prometheusprometheus-node-exporter

metrics from prom files are not showing on the metrics list on Node Exporter


I followed this article to setup node exporter and node_exporter.service looks like below

[Unit]
Description=Node Exporter
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/node_exporter --collector.textfile=/home/rafa/prom_files/result.prom --collector.textfile.directory=/home/rafa/prom_files

[Install]
WantedBy=multi-user.target

I can access the metrics, using IP:9100/metrics but I don't see the metrics as part of the result.prom available along with the rest.

result.prom looks like below and there is an empty line at the last of the file.

frontend_image_processing_status 1
frontend_Negative_publication_status 1
frontend_Sabre_publication_status 0
frontend_Negative_scan_time 0:00:07

What am I missing here ? Thank you !


Solution

  • Problem lies in the last line of your result.prom:

    frontend_Negative_scan_time 0:00:07
    

    Exposed Prometheus' metrics have to be of the format:

    metric_name [
      "{" label_name "=" `"` label_value `"` { "," label_name "=" `"` label_value `"` } [ "," ] "}"
    ] value
    

    Where value of the type float (or any of NaN, +Inf, -Inf)

    More on metrics format in documentation.

    Best solution for this situation: change you metric to store scan duration in second.

    Also, consider renaming your metric to frontend_negative_scan_duration_seconds per best naming practices recommended by Prometheus. Or even frontend_scan_duration_seconds{result="negative"} depending on meaning of negative in your context.