Showing with 121 additions and 31 deletions.
  1. +1 −1 .github/workflows/pe_latest_testing.yml
  2. +9 −0 CHANGELOG.md
  3. +102 −25 README.md
  4. +8 −4 files/pe_metrics.rb
  5. +1 −1 metadata.json
2 changes: 1 addition & 1 deletion .github/workflows/pe_latest_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Set latest release
id: latest_release
run: |
out=$(jq -c '[.[] | select(.lts == false)][0].latest | {"collection": [.]}' <<<'${{ steps.curl_forge.outputs.forge_response }}')
out=$(jq -c '[.[] | select(.release == "2019.8.x")][0].latest | {"collection": [.]}' <<<'${{ steps.curl_forge.outputs.forge_response }}')
echo "::set-output name=latest::$out"
- name: Setup Acceptance Test Matrix
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [v7.1.1](https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/tree/v7.1.1) (2022-09-29)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/compare/v7.1.0...v7.1.1)

### Fixed

- \(SUP-3681\) Check for valid status key in metrics [\#166](https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/pull/166) ([m0dular](https://github.com/m0dular))
- \(SUP-2734\) Collection to use FQDN to connect to the PuppetDB instance when runni… [\#163](https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/pull/163) ([elainemccloskey](https://github.com/elainemccloskey))

## [v7.1.0](https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/tree/v7.1.0) (2022-07-19)

[Full Changelog](https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/compare/v7.0.5...v7.1.0)
Expand Down
127 changes: 102 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
Table of Contents
=================

* [Overview](#overview)
* [Setup](#setup)
* [Installation](#installation)
* [Configuration](#configuration)
* [Usage](#usage)
* [Grepping Metrics](#grepping-metrics)
* [Sharing Metrics Data](#sharing-metrics-data)
* [Reference](#reference)
* [Directory Layout](#directory-layout)
* [Systemd Timers](#systemd-timers)
* [Alternate Setup](#alternate-setup)
* [Temporary Installation](#temporary-installation)
* [Manual Configuration of Hosts](#manual-configuration-of-hosts)
* [Configuration for Distributed Metrics Collection](#Configuration-for-distributed-metrics-collection)
* [How to Report an issue or contribute to the module](#How-to-Report-an-issue-or-contribute-to-the-module)
- [Table of Contents](#table-of-contents)
- [Overview](#overview)
- [Setup](#setup)
- [Installation](#installation)
- [Configuration](#configuration)
- [Parameters](#parameters)
- [output_dir](#output_dir)
- [collection_frequency](#collection_frequency)
- [retention_days](#retention_days)
- [Metrics Server Parameters](#metrics-server-parameters)
- [metrics_server_type](#metrics_server_type)
- [metrics_server_hostname](#metrics_server_hostname)
- [metrics_server_port](#metrics_server_port)
- [metrics_server_db_name](#metrics_server_db_name)
- [override_metrics_command](#override_metrics_command)
- [Usage](#usage)
- [Searching Metrics](#searching-metrics)
- [Searching Puppetserver Metrics](#searching-puppetserver-metrics)
- [Searching PuppetDB Metrics](#searching-puppetdb-metrics)
- [Sharing Metrics Data](#sharing-metrics-data)
- [Reference](#reference)
- [Directory Layout](#directory-layout)
- [Systemd Timers](#systemd-timers)
- [Alternate Setup](#alternate-setup)
- [Temporary Installation](#temporary-installation)
- [Manual Configuration of Hosts](#manual-configuration-of-hosts)
- [Monolithic Infrastructure with Compilers](#monolithic-infrastructure-with-compilers)
- [Hiera Data Example](#hiera-data-example)
- [Class Declaration Example](#class-declaration-example)
- [Configuration for Distributed Metrics Collection](#configuration-for-distributed-metrics-collection)
- [How to Report an issue or contribute to the module](#how-to-report-an-issue-or-contribute-to-the-module)
- [Supporting Content](#supporting-content)
- [Articles](#articles)
- [Videos](#videos)

## Overview

Expand Down Expand Up @@ -133,7 +152,7 @@ Defaults to `undef`.
## Usage


### Grepping Metrics
### Searching Metrics

Metrics are formatted as a JSON hash on one line.
In order to convert the metric files into a multi-line format, they can be processed with `python -m json.tool` as per below.
Expand All @@ -143,40 +162,68 @@ cd /opt/puppetlabs/puppet-metrics-collector
for i in <service_name>/primary.example.com/*.json; do echo "$(python -m json.tool < $i)" > $i; done
```

You can search for useful information by performing a `grep`, run from inside the directory containing the metrics.
You can search for useful information by performing a `grep`, run from inside the directory containing the metrics

```bash
cd /opt/puppetlabs/puppet-metrics-collector
grep <metric_name> <service_name>/primary.example.com/*.json
grep -oP '"<metric_name>,*?,' <service_name>/primary.example.com/*.json
```

or JQ if available
```bash
cd /opt/puppetlabs/puppet-metrics-collector
jq '.. |."<metric_name>"? | select(. != null)| input_filename , .' -- <service_name>/primary.example.com/*.json
```

Since the metrics are archived once per day, you can only search metrics for the current day.
To search older metrics, decompress the archived files into a subdirectory of `/tmp` and run your search from inside that directory.

#### Grepping Puppetserver Metrics
#### Searching Puppetserver Metrics

Example:

```bash
grep average-free-jrubies puppetserver/primary.example.com/*.json
grep -oP '"average-free-jrubies.*?,' puppetserver/primary.example.com/*.json

puppetserver/primary.example.com/20190404T170501Z.json:"average-free-jrubies":0.9950009285369501,
puppetserver/primary.example.com/20190404T171001Z.json:"average-free-jrubies":0.9999444653324225,
puppetserver/primary.example.com/20190404T171502Z.json:"average-free-jrubies":0.9999993830655706,
```

puppetserver/primary.example.com/20190404T170501Z.json: "average-free-jrubies": 0.9950009285369501,
puppetserver/primary.example.com/20190404T171001Z.json: "average-free-jrubies": 0.9999444653324225,
puppetserver/primary.example.com/20190404T171502Z.json: "average-free-jrubies": 0.9999993830655706,
```bash
jq '.. |."average-free-jrubies"? | select(. != null)| input_filename , .' -- puppetserver/primary.example.com/*.json

"puppetserver/primary.example.com/20190404T170501Z.json"
0.9950009285369501
"puppetserver/primary.example.com/20190404T171001Z.json"
0.9999444653324225,
"puppetserver/primary.example.com/20190404T171502Z.json"
0.9999993830655706,
```

#### Grepping PuppetDB Metrics
#### Searching PuppetDB Metrics

Example:

```bash
grep queue_depth puppetdb/primary.example.com/*.json
grep -oP '"queue_depth.*?,' puppetdb/primary.example.com/*.json

puppetdb/primary.example.com/20190404T170501Z.json: "queue_depth": 0,
puppetdb/primary.example.com/20190404T171001Z.json: "queue_depth": 0,
puppetdb/primary.example.com/20190404T171502Z.json: "queue_depth": 0,
```

```bash
jq '.. |."queue_depth "? | select(. != null)| input_filename , .' -- puppetdb/primary.example.com/*.json

"puppetdb/primary.example.com/20190404T170501Z.json"
0
"puppetdb/primary.example.com/20190404T171001Z.json"
0
"puppetdb/primary.example.com/20190404T171502Z.json"
0
```

### Sharing Metrics Data

When working with Support, you may be asked for an archive of collected metrics data.
Expand Down Expand Up @@ -318,3 +365,33 @@ class { 'puppet_metrics_collector':

If you are a PE user and need support using this module or are encountering issues, our Support team would be happy to help you resolve your issue and help reproduce any bugs. Just raise a ticket on the [support portal](https://support.puppet.com/hc/en-us/requests/new).
If you have a reproducible bug or are a community user you can raise it directly on the Github issues page of the module [here](https://github.com/puppetlabs/puppetlabs-puppet_metrics_collector/issues). We also welcome PR contributions to improve the module. Please see further details about contributing [here](https://puppet.com/docs/puppet/7.5/contributing.html#contributing_changes_to_module_repositories).


---

# Supporting Content

### Articles

The [Support Knowledge base](https://support.puppet.com/hc/en-us) is a searchable repository for technical information and how-to guides for all Puppet products.

This Module has the following specific Article(s) available:

1. [Troubleshoot and fix performance issues with the puppetlabs-puppet_metrics_collector module in Puppet Enterprise ](https://support.puppet.com/hc/en-us/articles/231751308)
2. [Manage the installation and configuration of metrics dashboards using the puppetlabs-puppet_metrics_dashboard module for Puppet Enterprise 2016.4 to 2019.1](https://support.puppet.com/hc/en-us/articles/360006641414)
3. [Troubleshooting potential issues in Puppet Enterprise: How to learn more](https://support.puppet.com/hc/en-us/articles/360004106074)

### Videos

The [Support Video Playlist](https://youtube.com/playlist?list=PLV86BgbREluWKzzvVulR74HZzMl6SCh3S) is a resource of content generated by the support team

This Module has the following specific video content available:


1. [Puppet Metrics Overview ](https://youtu.be/LiCDoOUS4hg)
2. [Collecting and Displaying Puppet Metrics](https://youtu.be/13sBMQGDqsA)
3. [Interpreting Puppet Metrics](https://youtu.be/09iDO3DlKMQ)


---

12 changes: 8 additions & 4 deletions files/pe_metrics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def post_endpoint(url, use_ssl, post_data)

def retrieve_additional_metrics(host, port, use_ssl, metrics_type, metrics)
if metrics_type == 'puppetdb'
host = '127.0.0.1' if host == CERTNAME
host = '127.0.0.1' if host == CERTNAME && !REMOTE_METRICS_ENABLED
unless REMOTE_METRICS_ENABLED || ['127.0.0.1', 'localhost'].include?(host)
# Puppet services released between May, 2020 and Feb 2021 had
# the /metrics API disabled due to:
Expand All @@ -134,13 +134,17 @@ def retrieve_additional_metrics(host, port, use_ssl, metrics_type, metrics)
metrics.each_index do |index|
metric_name = metrics[index]['name']
metric_data = metrics_output[index]
if metric_data['status'] == 200

metric_status = metric_data ? metric_data.dig('status') : nil
next unless metric_status

if metric_status == 200
metrics_array << { 'name' => metric_name, 'data' => metric_data['value'] }
elsif metric_data['status'] == 404
elsif metric_status == 404
metrics_array << { 'name' => metric_name, 'data' => nil }
else
metric_mbean = metrics[index]['mbean']
$error_array << "HTTP Error #{metric_data['status']} for #{metric_mbean}"
$error_array << "HTTP Error #{metric_status} for #{metric_mbean}"
end
end

Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-puppet_metrics_collector",
"version": "7.1.0",
"version": "7.1.1",
"author": "puppetlabs",
"summary": "A Puppet module for gathering metrics from PE components",
"license": "Apache-2.0",
Expand Down