Skip to content

Latest commit

 

History

History
59 lines (48 loc) · 1.85 KB

metering-writing-reports.adoc

File metadata and controls

59 lines (48 loc) · 1.85 KB

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 by using oc.

Prerequisites
  • Metering is installed.

Procedure
  1. Change to the openshift-metering project:

    $ oc project openshift-metering
  2. Create a Report resource as a YAML file:

    1. Create a YAML file with the following content:

      apiVersion: metering.openshift.io/v1
      kind: Report
      metadata:
        name: namespace-cpu-request-2019 (2)
        namespace: openshift-metering
      spec:
        reportingStart: '2019-01-01T00:00:00Z'
        reportingEnd: '2019-12-30T23:59:59Z'
        query: namespace-cpu-request (1)
        runImmediately: true (3)
      1. The query specifies ReportQuery used to generate the Report. Change this based on what you want to report on. For a list of options, run oc get reportqueries | grep -v raw.

      2. Use a descriptive name about what the Report does for metadata.name. A good name is the query, and the schedule or period you used.

      3. Set runImmediately to true for it to run with whatever data is available, or set it to false if you want it to wait for reportingEnd to pass.

    2. Run the following command to create the Report:

      $ oc create -f <file-name>.yaml
      
      report.metering.openshift.io/namespace-cpu-request-2019 created
  3. You can list Reports and their Running status with the following command:

    $ oc get reports
    
    NAME                         QUERY                   SCHEDULE   RUNNING    FAILED   LAST REPORT TIME       AGE
    namespace-cpu-request-2019   namespace-cpu-request              Finished            2019-12-30T23:59:59Z   26s