puppetexplorer icon indicating copy to clipboard operation
puppetexplorer copied to clipboard

Population metric names changed in PuppetDB 4.x

Open jasonhancock opened this issue 8 years ago • 14 comments

Population metric names changed in PuppetDB 4.x

https://docs.puppetlabs.com/puppetdb/4.0/api/metrics/v1/changes-from-puppetdb-v3.html#population-metrics

For example, the following metrics:

puppetlabs.puppetdb.query.population:type=default,name=num-nodes
puppetlabs.puppetdb.query.population:type=default,name=num-resources
puppetlabs.puppetdb.query.population:type=default,name=avg-resources-per-node
puppetlabs.puppetdb.query.population:type=default,name=pct-resource-dupes

are now, respectively:

puppetlabs.puppetdb.population:name=num-nodes
puppetlabs.puppetdb.population:name=num-resources
puppetlabs.puppetdb.population:name=avg-resources-per-node
puppetlabs.puppetdb.population:name=pct-resource-dupes

As I'm proxying puppetexplorer with Apache, the addition of a rewrite rule works around this for now:

RewriteEngine On
RewriteRule ^/api/metrics/v1/mbeans/puppetlabs.puppetdb.query.population:type=default,name=(.*)$  https://%{HTTP_HOST}/api/metrics/v1/mbeans/puppetlabs.puppetdb.population:name=$1 [R=301,L]

jasonhancock avatar Mar 22 '16 18:03 jasonhancock

I've been scratching my head since yesterday trying to fix this, works mint now, thanks heaps!

therin avatar Mar 22 '16 19:03 therin

"Perfect!"

If it were a real solution instead of a (rather nicely executed, I must admit) work-around, it'd be Perfect! ;-)

tun0 avatar Mar 23 '16 14:03 tun0

Any idea when this is going to be released? The RewriteRule workaround doesn't work for me.

dhs-rec avatar Apr 04 '16 07:04 dhs-rec

The rewrite rule works, but should be fixed in the application code to generate the proper http request in the first place. please fix it

gbolo avatar Apr 11 '16 18:04 gbolo

For anyone using the spotify-puppetexplorer module, @jasonhancock's temp fix can be added to the apache class pretty easily:

Edit: Fixed based on @dhs-rec's comment! 😄

class {'::puppetexplorer':
  vhost_options => {
    rewrites  => [ { rewrite_rule => ['^/api/metrics/v1/mbeans/puppetlabs.puppetdb.query.population:type=default,name=(.*)$  https://%{HTTP_HOST}/api/metrics/v1/mbeans/puppetlabs.puppetdb.population:name=$1 [R=301,L]'] } ] }
  }
}

petems avatar Apr 14 '16 23:04 petems

Final closing } is missing.

However, still doesn't work for me. I still get messages like this one when reloading the dashboard page:

Could not fetch metric pct-resource-dupes from PuppetDB

dhs-rec avatar Apr 15 '16 05:04 dhs-rec

I can confirm that the workaround does work, even in hiera:

puppetexplorer::vhost_options:
  rewrites:
    - rewrite_rule:
      - '^/api/metrics/v1/mbeans/puppetlabs.puppetdb.query.population:type=default,name=(.*)$  https://%%{}{HTTP_HOST}/api/metrics/v1/mbeans/puppetlabs.puppetdb.population:name=$1 [R=301,L]'

gbolo avatar Apr 15 '16 18:04 gbolo

Any news on the issue? Puppetexplorer is still unusable for me.

dhs-rec avatar Apr 20 '16 13:04 dhs-rec

Too sad this thing doesn't get officially released.

dhs-rec avatar May 31 '16 07:05 dhs-rec

Giving up...

dhs-rec avatar Jun 22 '16 11:06 dhs-rec

Thanks for sharing this fix jasonhancock. Worked like a charm for me.

edrude avatar Jun 30 '16 14:06 edrude

Thanks for the fix - after an additional sudo setsebool -P httpd_can_network_connect on it works like a charm for me.

Calixx avatar Oct 19 '16 15:10 Calixx

This had me puzzled for a while. The Rewrite rule was not working. I disabled SSL from my config, and the Rewrite has https.

NB: This is only if you are arent using SSL

Change

 https://%{HTTP_HOST}

To

 http://%{HTTP_HOST}

Works now!

shaunrampersad avatar Jan 24 '17 08:01 shaunrampersad

@shaunrampersad changing the rewrite rule to the following would work in both scenarios:

%{REQUEST_SCHEME}://%{HTTP_HOST}

irfanypatel avatar Oct 04 '17 10:10 irfanypatel