Questo contenuto non è disponibile nella lingua selezionata.
Chapter 14. Usage reporting with metrics-utility
The Ansible Automation Platform metrics utility tool (metrics-utility
) is a command-line utility that is installed on a system containing an instance of automation controller.
When installed and configured, metrics-utility
gathers billing-related metrics from your system and creates a consumption-based billing report. metrics-utility
is especially suited for users who have multiple managed hosts and want to use consumption-based billing. Once a report is generated, it is deposited in a target location that you specify in the configuration file.
metrics-utility
collects two types of data from your system: configuration data and reporting data.
The configuration data includes the following information:
- Version information for automation controller and for the operating system
- Subscription information
- The base URL
The reporting data includes the following information:
- Job name and ID
- Host name
- Inventory name
- Organization name
- Project name
- Success or failure information
- Report date and time
To ensure that metrics-utility
continues to work as configured, clear your report directories of outdated reports regularly.
14.1. Configuring metrics-utility Copia collegamentoCollegamento copiato negli appunti!
Configure the metrics-utility
to gather and report usage data for your Ansible Automation Platform, both on Red Hat Enterprise Linux and OpenShift Container Platform.
14.1.1. Configuring metrics-utility on Red Hat Enterprise Linux Copia collegamentoCollegamento copiato negli appunti!
Prerequisites:
- An active Ansible Automation Platform subscription
metrics-utility
is included with Ansible Automation Platform, so you do not need a separate installation. The following commands gather the relevant data and generate a CCSP report containing your usage metrics. You can configure these commands as cronjobs to ensure they run at the beginning of every month. See How to schedule jobs using the Linux 'cron' utility for more on configuring using the cron syntax.
Procedure
Create two scripts in your user’s home directory in order to set correct variables to ensure that
metrics-utility
gathers all relevant data:In
/home/my-user/cron-gather
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow In
/home/my-user/cron-report
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
To ensure that these files are executable, run:
chmod a+x /home/my-user/cron-gather /home/my-user/cron-report
chmod a+x /home/my-user/cron-gather /home/my-user/cron-report
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To open the cron file for editing, run:
crontab -e
crontab -e
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To configure the run schedule, add the following parameters to the end of the file and specify how often you want
metrics-utility
to gather information and build a report using the cron syntax. In the following example, thegather
command is configured to run every hour at 00 minutes. Thebuild_report
command is configured to run on the second day of each month at 4:00 AM.0 */1 * * * /home/my-user/cron-gather 0 4 2 * * /home/my-user/cron-report
0 */1 * * * /home/my-user/cron-gather 0 4 2 * * /home/my-user/cron-report
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save and close the file.
To verify that you saved your changes, run:
crontab -l
crontab -l
Copy to Clipboard Copied! Toggle word wrap Toggle overflow To ensure that data is being collected, run:
cat /var/log/cron
cat /var/log/cron
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The following is an example of the output. Note that time and date might vary depending on how your configure the run schedule:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The generated report will have the default name CCSP-<YEAR>-<MONTH>.xlsx and will be deposited in the ship path that you specified in step 1a.
14.1.2. Configuring metrics-utility on OpenShift Container Platform from the Ansible Automation Platform operator Copia collegamentoCollegamento copiato negli appunti!
metrics-utility
is included in the OpenShift Container Platform automation controller image for versions 4.12, 4.5.12, and 4.6. If your system does not have metrics-utility
installed, update your OpenShift image to the latest version.
Create a ConfigMap in the OpenShift UI YAML view and deploy automation controller to configure the run schedule for metrics-utility
on OpenShift Container Platform using the Ansible Automation Platform operator.
Prerequisites:
- A running OpenShift cluster
- An operator-based installation of Ansible Automation Platform on OpenShift Container Platform.
metrics-utility
will run as indicated by the parameters you set in the configuration file.
14.1.2.1. Create a ConfigMap in the OpenShift UI YAML view Copia collegamentoCollegamento copiato negli appunti!
To inject the metrics-utility
cronjobs with configuration data, use the following procedure to create a ConfigMap in the OpenShift UI YAML view:
- From the navigation panel on the left side, select ConfigMaps, and then click the Create ConfigMap button.
- On the next screen, select the YAML view tab.
In the
YAML
field, enter the following parameters with the appropriate variables set:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click .
- To verify that the ConfigMap was created and the metric utility is installed, select ConfigMap from the navigation panel and look for your ConfigMap in the list.
14.1.2.2. Deploy automation controller Copia collegamentoCollegamento copiato negli appunti!
To deploy automation controller and specify variables for how often metrics-utility
gathers usage information and generates a report, use the following procedure:
Procedure
- From the navigation panel, select Installed Operators.
- Select Ansible Automation Platform.
- In the Operator details, select the automation controller tab.
- Click *.
Select the YAML view option. The
YAML
now shows the default parameters for automation controller. The relevant parameters formetrics-utility
are the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Find the
metrics_utility_enabled
parameter and change the variable totrue
. -
Find the
metrics_utility_cronjob_gather_schedule
parameter and enter a variable for how often the utility should gather usage information (for example, @hourly or @daily). -
Find the
metrics_utility_cronjob_report_schedule
parameter and enter a variable for how often the utility generates a report (for example, @daily or @monthly). - Click .
14.2. Fetching a monthly report Copia collegamentoCollegamento copiato negli appunti!
Fetch a monthly report from Ansible Automation Platform to gather usage metrics and create a consumption-based billing report. To fetch a monthly report on Red Hat Enterprise Linux or on OpenShift Container Platform, use the following procedures:
14.2.1. Fetching a monthly report on Red Hat Enterprise Linux Copia collegamentoCollegamento copiato negli appunti!
Use the following procedure to fetch a monthly report on Red Hat Enterprise Linux:
Procedure
- Run:
scp -r username@controller_host:$METRICS_UTILITY_SHIP_PATH/data/<YYYY>/<MM>/ /local/directory/
scp -r username@controller_host:$METRICS_UTILITY_SHIP_PATH/data/<YYYY>/<MM>/ /local/directory/
The generated report will have the default name CCSP-<YEAR>-<MONTH>.xlsx and will be deposited in the ship path that you specified.
14.2.2. Fetching a monthly report on OpenShift Container Platform from the Ansible Automation Platform Operator Copia collegamentoCollegamento copiato negli appunti!
Use the following playbook to fetch a monthly consumption report for Ansible Automation Platform on OpenShift Container Platform:
14.3. Modifying the run schedule Copia collegamentoCollegamento copiato negli appunti!
You can configure metrics-utility
to run at specified times and intervals. Run frequency is expressed in cronjobs. For more information on the cron utility, see How to schedule jobs using the Linux ‘Cron’ utility.
To modify the run schedule on Red Hat Enterprise Linux and on OpenShift Container Platform, use one of the following procedures:
14.3.1. Modifying the run schedule on Red Hat Enterprise Linux Copia collegamentoCollegamento copiato negli appunti!
Use the folowing procedure to modify the run schedule on Red Hat Enterprise Linux.
Procedure
From the command line, run:
crontab -e
crontab -e
Copy to Clipboard Copied! Toggle word wrap Toggle overflow After the code editor has opened, update the
gather
andbuild
parameters using cron syntax as shown below:0 */1 * * * /home/my-user/cron-gather 0 4 2 * * /home/my-user/cron-report
0 */1 * * * /home/my-user/cron-gather 0 4 2 * * /home/my-user/cron-report
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save and close the file.
14.3.2. Modifying the run schedule on OpenShift Container Platform from the Ansible Automation Platform operator Copia collegamentoCollegamento copiato negli appunti!
Use the following procedure to adjust the execution schedule of the metrics-utility
within your Ansible Automation Platform deployment running on OpenShift Container Platform:
Procedure
-
From the navigation panel, select
. - On the next screen, select automation-controller-operator-controller-manager.
- Beneath the heading Deployment Details, click the down arrow button to change the number of pods to zero. This will pause the deployment so you can update the running schedule.
- From the navigation panel, select Installed Operators.
- From the list of installed operators, select Ansible Automation Platform.
- On the next screen, select the automation controller tab.
- From the list that appears, select your automation controller instance.
-
On the next screen, select the
YAML
tab. In the
YAML
file, find the following parameters and enter a variable representing how oftenmetrics-utility
should gather data and how often it should produce a report:metrics_utility_cronjob_gather_schedule: metrics_utility_cronjob_report_schedule:
metrics_utility_cronjob_gather_schedule: metrics_utility_cronjob_report_schedule:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Click .
- From the navigation menu, select automation-controller-operator-controller-manager. and then select
- Increase the number of pods to 1.
To verify that you have changed the
metrics-utility
running schedule successfully, you can take one or both of the following steps:-
return to the
YAML
file and ensure that the parameters described above reflect the correct variables. -
From the navigation menu, select
and ensure that your cronjobs show the updated schedule.
-
return to the