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

  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 1
        namespace: openshift-metering
      spec:
        reportingStart: '2019-01-01T00:00:00Z'
        reportingEnd: '2019-12-30T23:59:59Z'
        query: namespace-cpu-request 2
        runImmediately: true 3
      2
      The query specifies the ReportQuery resources 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.
      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 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 resource:

      $ oc create -f <file-name>.yaml

      Example output

      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

    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

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.