Examples of using metering

Metering is a deprecated feature. Deprecated functionality is still included in OKD and continues to be supported; however, it will be removed in a future release of this product and is not recommended for new deployments.

For the most recent list of major functionality that has been deprecated or removed within OKD, refer to the Deprecated and removed features section of the OKD release notes.

Use the following example reports to get started measuring capacity, usage, and utilization in your cluster. These examples showcase the various types of reports metering offers, along with a selection of the predefined queries.

Prerequisites

Measure cluster capacity hourly and daily

The following report demonstrates how to measure cluster capacity both hourly and daily. The daily report works by aggregating the hourly report’s results.

The following report measures cluster CPU capacity every hour.

Hourly CPU capacity by cluster example

  1. apiVersion: metering.openshift.io/v1
  2. kind: Report
  3. metadata:
  4. name: cluster-cpu-capacity-hourly
  5. spec:
  6. query: "cluster-cpu-capacity"
  7. schedule:
  8. period: "hourly" (1)
1You could change this period to daily to get a daily report, but with larger data sets it is more efficient to use an hourly report, then aggregate your hourly data into a daily report.

The following report aggregates the hourly data into a daily report.

Daily CPU capacity by cluster example

  1. apiVersion: metering.openshift.io/v1
  2. kind: Report
  3. metadata:
  4. name: cluster-cpu-capacity-daily (1)
  5. spec:
  6. query: "cluster-cpu-capacity" (2)
  7. inputs: (3)
  8. - name: ClusterCpuCapacityReportName
  9. value: cluster-cpu-capacity-hourly
  10. schedule:
  11. period: "daily"
1To stay organized, remember to change the name of your report if you change any of the other values.
2You can also measure cluster-memory-capacity. Remember to update the query in the associated hourly report as well.
3The inputs section configures this report to aggregate the hourly report. Specifically, value: cluster-cpu-capacity-hourly is the name of the hourly report that gets aggregated.

Measure cluster usage with a one-time report

The following report measures cluster usage from a specific starting date forward. The report only runs once, after you save it and apply it.

CPU usage by cluster example

  1. apiVersion: metering.openshift.io/v1
  2. kind: Report
  3. metadata:
  4. name: cluster-cpu-usage-2019 (1)
  5. spec:
  6. reportingStart: '2019-01-01T00:00:00Z' (2)
  7. reportingEnd: '2019-12-30T23:59:59Z'
  8. query: cluster-cpu-usage (3)
  9. runImmediately: true (4)
1To stay organized, remember to change the name of your report if you change any of the other values.
2Configures the report to start using data from the reportingStart timestamp until the reportingEnd timestamp.
3Adjust your query here. You can also measure cluster usage with the cluster-memory-usage query.
4Configures the report to run immediately after saving it and applying it.

Measure cluster utilization using cron expressions

You can also use cron expressions when configuring the period of your reports. The following report measures cluster utilization by looking at CPU utilization from 9am-5pm every weekday.

Weekday CPU utilization by cluster example

  1. apiVersion: metering.openshift.io/v1
  2. kind: Report
  3. metadata:
  4. name: cluster-cpu-utilization-weekdays (1)
  5. spec:
  6. query: "cluster-cpu-utilization" (2)
  7. schedule:
  8. period: "cron"
  9. expression: 0 0 * * 1-5 (3)
1To say organized, remember to change the name of your report if you change any of the other values.
2Adjust your query here. You can also measure cluster utilization with the cluster-memory-utilization query.
3For cron periods, normal cron expressions are valid.