v1 Metrics Endpoint
The v1 metrics endpoint is introduced in puppet in the year 2016. Now it is deprecated but still accessible.
The different HTTP request methods for the above metrics are:-
GET /metrics/v1/mbeans
The endpoint will display the list of all the available MBeans.
Response Keys:
-
Key: Name of a valid MBean.
- Value: URI to use while requesting MBean's attributes.
POST /metrics/v1/mbeans
The POST endpoint will retrieve requested MBean metrics.
You need to send the JSON object in the request body.
Response Keys:
The response is always a JSON but also depends on the request format:-
-
Requests with a JSON object return a JSON object.
-
Requests with a JSON array return a JSON array.
-
Requests with a JSON string return a JSON object.
v2 (Jolokia) Metrics Endpoint
The v2 metrics endpoint uses the Jolokia library. Refer to this documentation if you want to learn about Jolokia.
The different HTTP request methods for the above metrics are:-
GET /metrics/v2/
The endpoint will return a JSON object upon successful request.
POST /metrics/v2/<OPERATION>
You can submit a POST request with the query as a JSON document in the POST body.
Services Endpoint
The services endpoint provides information about all the services running on the Puppet Server.
Note: Only the GET HTTP request method is supported in this endpoint.
GET /status/v1/services
For this endpoint, the only supported format is JSON.
Query Parameters
The Query parameter supported is:-
level: The response includes status information for all registered services at the required level of detail.
The valid values for the query are:-
-
critical: It will return the minimum amount of status information for each service.
-
info: It will return more info than the critical level for each service.
- debug: This level returns service status data that is sufficiently detailed to be useful for troubleshooting issues with the puppet server process.
Response
A response from the services endpoint represents each service that the Status service is aware of. The state value for each service is one of the following:-
-
running: Returns only if all services are running.
-
error: Returns if any service reports an error.
-
starting: Returns if any service reports that it is starting, and no service reports an error or stopping.
-
stopping: Returns if any service reports that it is stopping and no service reports an error.
- unknown: Returns if any service reports an unknown state and no services report an error.
Simple Endpoint
The simple endpoint is to give a simple indication of whether Puppet Server is running on a server.
Note: Only the GET HTTP request method is supported in this endpoint.
GET /status/v1/simple
For this endpoint, the only supported format is Plain Text, and there are no query parameters.
Response
The response of this endpoint consists of a single word describing Puppet Server's status:-
-
running: Returns only if all services are running.
-
error: Returns if any service reports an error.
- unknown: Returns if any service reports an unknown state and no services report an error.
Environment Cache Endpoint
Puppet Server caches the information it loads from the disc for each environment when using directory environments. It provides an endpoint for clearing this cache:-
DELETE /puppet-admin-api/v1/environment-cache
Make an HTTP request to this endpoint to trigger a complete invalidation of the data in this cache.
Query Parameters
This endpoint has an optional query parameter, environment, whose value may be set to the name of a specific Puppet environment.
Response
This endpoint will return an HTTP 204: No Content as a response upon successful request. The response body will be empty.
JRuby Pool Endpoint
A pool of JRuby instances is available on Puppet Server, which also has an API endpoint for flushing it:-
DELETE /puppet-admin-api/v1/jruby-pool
This Endpoint will remove all of the current JRuby interpreters from the pool, and the JVM's garbage collector will be able to free up the RAM that they were using.
Response
This endpoint will return an HTTP 204: No Content as a response upon successful request. The response body will be empty.
Environment Classes and Modules Endpoint
The environment classes API covers different things, returns new or different information, and deletes some information.
GET /puppet/v3/environment_classes?environment=:environment
For this endpoint, the only supported format is JSON.
Query Parameters
Provide one parameter to the GET request:-
- environment: Only the classes and parameter data relevant to the given environment will be returned for the call.
The environment modules API will return information about the modules installed for the requested environment.
GET /puppet/v3/environment_modules
For this endpoint, the only supported format is JSON.
Static File Content Endpoint
The static file content endpoint outputs the contents of a particular version of a file resource that has a source attribute with a puppet:/// URI value. It does this by returning the standard output of a code-content-command script.
GET /puppet/v3/static_file_content/<FILE-PATH>
Supported HTTP Method
GET
Query Parameters
There are two must-pass parameters in the GET request.
-
code_id: a special string the catalog provides to specify the file version to return.
- environment: The environment that contains the desired file.
Response
This endpoint returns an HTTP 200 response code and application/octet-stream Content-Type header and the contents of the specified file's requested version in the response body upon a successful request.
But if the request is unsuccessful, it returns an error response code with a text/plain Content-Type header:-
-
400: It will be returned when any of the parameters are not provided.
-
403: It will be returned when requesting a file that is not within a module's files or tasks directory.
- 500: It will be returned when a requested file or version is not present in a repository or when code-content-command is not configured on the server.
Frequently Asked Questions
What is DevOps?
DevOps is a set of cultural concepts, processes, and tools that improves an organization's capacity to provide applications and services at a high rate.
What is Puppet?
Puppet is a server configuration management program that may be used to configure, deploy, and manage servers.
Is Puppet a CI/CD tool?
Yes, Puppet is a true CI/CD solution for modern development.
What is API?
API stands for Application Programming Interface. It is a set of definitions and protocols for creating and integrating software applications.
What is API Endpoint?
An Endpoint is one end of a communication channel. Whenever an API interacts with another system/software, the touchpoint of this communication is the Endpoint.
Conclusion
In this article, we have extensively discussed different API Endpoints in Puppet. I hope you enjoyed reading this article on API Endpoints in Puppet.
If you want to learn more, check out our articles on Implementing DELETE Method to Delete a User Resource, Technological Services in Ready API, What Is Web2Py?, Why To Use Web2py?, Postbacks and Internationalization in web2py, Third Party Modules In Web2py, Tasks In Web2py, and XML in Web2py.
Also, check out these exciting courses from coding ninjas to expand your knowledge, Coding Course, Code Studio, Interview Experience, Guided Path, Interview Problems, Test Series, Library, and Resources.
Happy Coding!