This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.6.2. Writing Reports
Writing a report is the way to process and analyze data using metering.
To write a report, you must define a Report resource in a YAML file, specify the required parameters, and create it in the openshift-metering namespace.
Prerequisites
- Metering is installed.
Procedure
Change to the
openshift-meteringproject:oc project openshift-metering
$ oc project openshift-meteringCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
Reportresource as a YAML file:Create a YAML file with the following content:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 2
- The
queryspecifies theReportQueryresources used to generate the report. Change this based on what you want to report on. For a list of options, runoc get reportqueries | grep -v raw. - 1
- Use a descriptive name about what the report does for
metadata.name. A good name describes the query, and the schedule or period you used. - 3
- Set
runImmediatelytotruefor it to run with whatever data is available, or set it tofalseif you want it to wait forreportingEndto pass.
Run the following command to create the
Reportresource:oc create -f <file-name>.yaml
$ oc create -f <file-name>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
report.metering.openshift.io/namespace-cpu-request-2019 created
report.metering.openshift.io/namespace-cpu-request-2019 createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
You can list reports and their
Runningstatus with the following command:oc get reports
$ oc get reportsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME QUERY SCHEDULE RUNNING FAILED LAST REPORT TIME AGE namespace-cpu-request-2019 namespace-cpu-request Finished 2019-12-30T23:59:59Z 26s
NAME QUERY SCHEDULE RUNNING FAILED LAST REPORT TIME AGE namespace-cpu-request-2019 namespace-cpu-request Finished 2019-12-30T23:59:59Z 26sCopy to Clipboard Copied! Toggle word wrap Toggle overflow