Best method to attach custom collector to Node-exporter

35 views
Skip to first unread message

Ankit Rohilla

unread,
Mar 12, 2020, 2:46:49 AM3/12/20
to Prometheus Users
Hi,
I've created a few of my own collectors for Node-exporter. To build it I have to run the dockerfile again and build my own custom node-exporter image. Is there any mechanism by which I don't have to build the node-exporter but instead I can provide my collectors in a specific extension to the official NE image and pass them as arguments, to avoid building the whole node-exporter again? I don't know if it is feasible or not.
Please help.

Thanks and Regards
Ankit Rohilla

Brian Candler

unread,
Mar 12, 2020, 4:47:27 AM3/12/20
to Prometheus Users
You can build your own docker image with a Dockerfile that uses the existing node_exporter image as a base, and just add the extra files you want.  That sounds like what you want.

You can also build an image from scratch which extracts specific files from another docker image (e.g. just the node_exporter binary).  This feature is called multi-stage build.

Ankit Rohilla

unread,
Mar 12, 2020, 6:11:54 AM3/12/20
to Prometheus Users
Hi,
Thanks for the reply.

I can use the existing node-exporter image as the base image for my dockerfile. But where will I copy my additional collectors code? Because only the NE binary will be there in the image and so I need to provide those collectors file to the NE source code.
Can you please elaborate a bit?

I can also use multi stage to just copy the binary and use it in my second layer, but how would I give the collectors file to the NE?

Thanks

Brian Candler

unread,
Mar 12, 2020, 8:54:03 AM3/12/20
to Prometheus Users
On Thursday, 12 March 2020 10:11:54 UTC, Ankit Rohilla wrote:
I can use the existing node-exporter image as the base image for my dockerfile. But where will I copy my additional collectors code?

You would copy it into the new docker image that you are building from the base image.  Look at the COPY statement in Dockerfile:

Christian Hoffmann

unread,
Mar 14, 2020, 7:03:27 AM3/14/20
to Ankit Rohilla, Prometheus Users
Hi Ankit,
I don't think there is another way to do that.

If your node_exporter extensions are useful to others and fit into the
scope of the node_exporter, I would suggest getting feedback from the
maintainers if Pull requests for these features would be accepted. That
way, at some point in the future, you could just run the vanilla
node_exporter and get all the features.

If your extensions are too specific or proprietary, the best way might
be to move them into a distinct exporter.

Kind regards,
Christian

Brian Candler

unread,
Mar 15, 2020, 4:41:34 AM3/15/20
to Prometheus Users
Ah sorry, I thought OP was using code which writes files for the textfile-collector.

Ankit Rohilla

unread,
Mar 16, 2020, 1:13:37 AM3/16/20
to Prometheus Users
Thanks for the reply. I also thought the same, it is not feasible as of now. Just wanted to confirm.

Regards,
Ankit Rohilla
Reply all
Reply to author
Forward
0 new messages