fluent / fluent-plugin-prometheus

A fluent plugin that collects metrics and exposes for Prometheus.
Apache License 2.0
258 stars 79 forks source link

Compiling plugin #152

Closed jishminor closed 4 years ago

jishminor commented 4 years ago

I have been experimenting with adding functionality to take message streams in fluentd, and turn them directly into prometheus scrapable metrics. I have successfully compiled my modified gem based on this repository, but when I fluentd attempts to install it, it fails, the fluentd container does not have build tools installed.

The error logs I receive:

Building native extensions.  This could take a while...
ERROR:  Error installing fluent-plugin-prometheus-test:
    ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/msgpack-1.3.3/ext/msgpack
/usr/bin/ruby2.3 -r ./siteconf20200501-18-oz41u0.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/msgpack-1.3.3 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/msgpack-1.3.3/gem_make.out

When you package this plugin, do you compile it using the gem compiler before pushing it? If so how do you do this? When I try and compile I get the following:

➜ gem compile fluent-plugin-prometheus-1.7.3.gem
Unpacking gem: 'fluent-plugin-prometheus-1.7.3' in temporary directory...
There are no extensions to build on this gem file. Skipping.

Thanks

ganmacs commented 4 years ago

See your log. it has nothing to do with this plugin.

current directory: /var/lib/gems/2.3.0/gems/msgpack-1.3.3/ext/msgpack /usr/bin/ruby2.3 -r ./siteconf20200501-18-oz41u0.rb extconf.rb mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

jishminor commented 4 years ago

To clarify, I took this repo on the master branch, modified the gemspec to create a test gem name and version, built the gem with gem build then pushed and I still see the above problem, as it seems that the package requires native extensions to be compiled.

It seems that it is the msgpack gem which is requiring native extensions.

Is this the case in your experience?

Could you provide me with instruction on how you package and publish this gem?

repeatedly commented 4 years ago

Maybe, you need to install ruby-devel/ruby-dev and other development tools package on your machine.

jishminor commented 4 years ago

I just started using Ruby for the first time yesterday, so I apologize if these are novice questions, but when I attempt to use the gem compiler on this gem I get the following output:

➜ gem compile fluent-plugin-prometheus-1.7.3.gem
Unpacking gem: 'fluent-plugin-prometheus-1.7.3' in temporary directory...
There are no extensions to build on this gem file. Skipping.

So it doesn't seem like any native extensions are found, contradicting what I see when I pull down the gem into fluentd. As per the log in my original comment.