Package Request: collectd Write Prometheus plugin

Right now, it looks like the most common ways for people to get metrics from OpenWrt into Prometheus are to use the prometheus-node-exporter-* packages or by using collectd-mod-* and using collect-mod-network to send metrics to a collectd_exporter instance, and having Prometheus scrape the collectd_exporter instance.

A collectd Write Prometheus plugin exists which serves its own metrics page for Prometheus to scape, so collectd_exporter would not be required.

Could this plugin be created as a package for OpenWrt?

I can try enabling the plugin and see if it builds ok in OpenWrt context.

(Based on the plugin page, it depends on protobuf-c and libmicrohttpd, which both we do have. So there should be no blockers.)

3 Likes

Looks a bit more difficult.
The collectd configure.ac does not find the protoc-c compiler, athough the basic libprotobuf packages are found...

libprotobuf . . . . . yes
libprotobuf-c . . . . yes
...
protobuf-c  . . . . . no (protoc-c compiler not found)

I did not succeed in defining the plugin. It apparently fails in finding a protobuf-c compiler ("protoc-c" compiler?)

I am not sure if that protoc-c is even installed with our protobuf-c package.

The change I tried:

perus@ub2304:/Openwrt/e8450/feeds/packages$ git diff
diff --git a/utils/collectd/Makefile b/utils/collectd/Makefile
index 308a4dc22..70c7b0789 100644
--- a/utils/collectd/Makefile
+++ b/utils/collectd/Makefile
@@ -122,7 +122,6 @@ COLLECTD_PLUGINS_DISABLED:= \
        write_kafka \
        write_log \
        write_mongodb \
-       write_prometheus \
        write_redis \
        write_riemann \
        write_sensu \
@@ -209,7 +208,8 @@ COLLECTD_PLUGINS_SELECTED:= \
        vmem \
        wireless \
        write_graphite \
-       write_http
+       write_http \
+       write_prometheus
 
 PKG_CONFIG_DEPENDS:= \
        $(patsubst %,CONFIG_PACKAGE_collectd-mod-%,$(subst _,-,$(COLLECTD_PLUGINS_SELECTED))) \
@@ -365,6 +365,10 @@ else
   CONFIGURE_ARGS+= --without-libudev
 endif
 
+ifneq ($(CONFIG_PACKAGE_collectd-mod-write-prometheus),)
+  CONFIGURE_ARGS+= --with-protoc_c="$(STAGING_DIR)/usr/bin/protoc"
+endif
+
 define Package/collectd/conffiles
 /etc/collectd.conf
 /etc/config/collectd
@@ -548,6 +552,7 @@ $(eval $(call BuildPlugin,vmem,virtual memory usage input,vmem,))
 $(eval $(call BuildPlugin,wireless,wireless status input,wireless,))
 $(eval $(call BuildPlugin,write-graphite,Carbon/Graphite output,write_graphite,+PACKAGE_collectd-mod-write-graphite:libpthread))
 $(eval $(call BuildPlugin,write-http,HTTP POST output,write_http,+PACKAGE_collectd-mod-write-http:libcurl))
+$(eval $(call BuildPlugin,write-prometheus,Prometheus output,write_prometheus,+PACKAGE_collectd-mod-write-prometheus:libmicrohttpd +PACKAGE_collectd-mod-write-prometheus:libprotobuf-c))
 
 $(eval $(call BuildScriptPlugin,sqm,SQM/qdisc collection,sqm_collectd,+PACKAGE_collectd-mod-sqm:collectd-mod-exec))
 $(eval $(call BuildScriptLuaPlugin,ltq-dsl,Lantiq DSL collection,dsl,@ltq-dsl-app +PACKAGE_collectd-mod-ltq-dsl:collectd-mod-lua +libubus-lua))

If you want the plugin, please test compiling it yourself, and get the protoc-c compiler defined/built/included/found.