PuppetDB Queries

17 views
Skip to first unread message

Paul Seymour

unread,
Nov 18, 2014, 5:57:47 AM11/18/14
to puppet...@googlegroups.com
Hello,

Would like to use PuppetDB to find out more about the estate inventory. Specifically at the moment I am trying to find out the amount of servers using "productname", and the "physicalprocessorcount" for each - both with totals.

Is this doable from the API at all, or easier from inside PSQL ?

Thanks
Paul

Ken Barber

unread,
Nov 18, 2014, 6:34:00 AM11/18/14
to Puppet Users
> Would like to use PuppetDB to find out more about the estate inventory. Specifically at the moment I am trying to find out the amount of servers using "productname", and the "physicalprocessorcount" for each - both with totals.
>
> Is this doable from the API at all, or easier from inside PSQL ?

Do-able, but there are no server side aggregate operators/handlers for
this case in particular, its on our radar however. You can fake it by
using the include-total pagination option, and making your query
specific:

https://gist.github.com/kbarber/8175145dcca982b5cd0c

Then pluck out the 'X-Records' field, but that would require two
queries, one for each fact, /v4/facts/fact1 & /v4/facts/fact2.

Otherwise perform a proper query for both fields, and count the
results yourself programmatically.

I can't recommend going to PostgreSQL directly, that isn't an API
contract we have commitments to - ie. we will change it underneath you
without warning or remorse today, even in a Z release :-).

ken.
Reply all
Reply to author
Forward
0 new messages