First, let's understand what is PuppetDB and Metrics API.
PuppetDB
It is an open-source storage solution for data generated by Puppet. The initial release offers a drop-in data storing service and also stores configs.
It is made with very advanced technology which uses all resources. Also, the master is free to create other collections because it consistently stores all of its data.
Credit: https://opengraph.githubassets.com
Metrics API
An additional, by default active web interface for Java Management Extension metrics, specifically managed beans, is included in Puppet Enterprise (MBeans).
Among these endpoints are.
POST /metrics/v1/mbeans.
GET /metrics/v1/mbeans.
GET /metrics/v1/mbeans/<name>.
Metrics endpoint
Querying PuppetDB metrics is done by sending an HTTP request to the /metrics/v1 REST endpoint. The metrics v1 API is deleted and disabled by default. Please use the /metrics/v2 endpoint instead.
🧠 Because of a CVE (Common Vulnerabilities and Exposures) described in CVE-2020-7943, the metrics/v1 endpoint has been disabled by default.
🧠If needed, you can re-enable this endpoint from config settings from the section Re-enable metrics v1 endpoints.
🧠Please remember that, in most cases, PuppetDB is simply a channel to MBeans has given access by its parts.
Re-enable metrics v1 endpoint
Create metrics.conf file in the /etc/puppetlabs/puppetdb/conf.d/ directory, or wherever your PuppetDB conf.d/ directory is located to re-enable this endpoint.The following file should include the information.
The result is a collection of JSON objects. The results are displayed in the order they were supplied in the POSTED array. The JSON objects are identical to those obtained individually via the MBean/name> endpoint.
Useful metrics
These are some useful metrics:
Population Metrics.
Database Metrics.
Message Queue Metrics.
⭐Global Metrics.
⭐Metrics for each Command Version.
HTTP Metrics.
Storage Metrics.
JVM Metrics.
Metrics API changes in PuppetDB 4
The names of most metrics were changed in PuppetDB 4 to be constant with other Puppet parts and to provide a more reflexive naming scheme. This document describes the relationship between the metric names before and after PuppetDB 4.
Population Metrics
Consider the following metrics:
Now respectively.
HTTP Metrics
Before PuppetDB 4, HTTP metrics were distributed across multiple namespaces. All HTTP metrics are now grouped in the same namespace.
Here are some specific examples:
Message Queue (MQ) Metrics
The puppetlabs.puppetdb.mq namespace now contains command processing metrics related to the message queue.
The following terms are now in use.
Consider the following message queue metrics:
Would now be as follows:
Dead Letter Office (DLO) Metrics
The DLO metrics now have the following structure:
Storage Metrics
The names of the storage metrics have been shortened using the following event:
Example:
Frequently Asked Questions
How do you measure API performance?
The most basic set of metrics for measuring API performance is operational metrics. The metrics include the number of API calls and CPU and memory usage.
What are the most common API metrics?
CPU and memory usage are the two most crucial API infra metrics that we monitor. A high CPU usage can indicate server overloading, resulting in severe obstacles. Memory usage provides insight into the amount of resource utilization.
What is the purpose of PuppetDB?
PuppetDB is a scalable and dependable Puppet data store. PuppetDB collects Puppet-generated data and also provides advanced functionality through a powerful API. Zabbix is a distributed monitoring solution that is open-source and enterprise-class.
What information is stored in PuppetDB?
PuppetDB is an open-source storage service for Puppet-generated data. This currently includes catalogues and facts but will be expanded shortly. The first release includes a drop-in replacement for store configs and the inventory service.
What is a Puppet?
Puppet offers the capability to specify the software and config that a system needs and then, after initial setup, to maintain a given state. To specify config options for a particular environment or infrastructure, you utilise a declarative Domain Specific Language (DSL).
Conclusion
In this article we learned about the Metrics API version 1 in PuppetDB. This topic contains metrics endpoint and Metrics API changes in PuppetDB4 You can refer to the articles below if you want to learn more about Puppet and Metrics API