> The main issue is that I am not able to see the metrics in Prometheus UI. I am unable to understand the root cause.
Almost certainly because they are not being collected. So you need to break this down further to find out why.
(1) Show the output of this command:
ls -l /var/lib/node_exporter
* If the filenames don't end with ".prom" then that is your root cause. node_exporter only picks up files whose names match the pattern *.prom
* If the files aren't readable by the user that node_exporter is running as, then that's the root cause.
* Are you running under RedHat/CentOS with SELinux? If so, try putting it into permissive mode. Maybe there's some SELinux policy which prevents access to files in /var/lib/node_exporter.
(2) Then show the contents of one of those files:
head /var/lib/node_exporter/foobar.prom
If the files are not in valid openmetrics format, then they won't be picked up either. You can test them with "promtool check metrics":
/path/to/promtool check metrics </var/lib/node_exporter/foobar.prom
(3) Show the command line that you're running node_exporter with:
ps auxwww | grep node_exporter
If the flag "--collector.textfile.directory=/var/lib/node_exporter" is not present, then that's your root cause.
(4) Show the output of this command:
curl localhost:9100/metrics | grep foobar
where "foobar" is one of the custom metrics you are generating. Does it appear here? If not, then you can rule out any issues with prometheus itself, it's definitely node_exporter not picking up your custom metrics. If it does, then you'll need to dig further onto prometheus side (e.g. your scrape job config)
> In /var/lib/node_exporter --> In this folder, the scripts(custom metrics script) will be available.
You don't want the scripts in that directory - only the *output* from those scripts. However, as long as the scripts themselves don't end with ".prom" then they will be ignored, so that won't be a problem.