Este contenido no está disponible en el idioma seleccionado.
Chapter 6. Using Metering
Metering is a deprecated feature. Deprecated functionality is still included in OpenShift Container Platform 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 OpenShift Container Platform, refer to the Deprecated and removed features section of the OpenShift Container Platform release notes.
6.1. Prerequisites Copiar enlaceEnlace copiado en el portapapeles!
- Install Metering
- Review the details about the available options that can be configured for a report and how they function.
6.2. Writing Reports Copiar enlaceEnlace copiado en el portapapeles!
Writing a report is the way to process and analyze data using metering.
To write a report, you must define a
Report
openshift-metering
Prerequisites
- Metering is installed.
Procedure
Change to the
project:openshift-metering$ oc project openshift-meteringCreate a
resource as a YAML file:ReportCreate a YAML file with the following content:
apiVersion: metering.openshift.io/v1 kind: Report metadata: name: namespace-cpu-request-20201 namespace: openshift-metering spec: reportingStart: '2020-01-01T00:00:00Z' reportingEnd: '2020-12-30T23:59:59Z' query: namespace-cpu-request2 runImmediately: true3 - 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
resource:Report$ oc create -f <file-name>.yamlExample output
report.metering.openshift.io/namespace-cpu-request-2020 created
You can list reports and their
status with the following command:Running$ oc get reportsExample output
NAME QUERY SCHEDULE RUNNING FAILED LAST REPORT TIME AGE namespace-cpu-request-2020 namespace-cpu-request Finished 2020-12-30T23:59:59Z 26s
6.3. Viewing report results Copiar enlaceEnlace copiado en el portapapeles!
Viewing a report’s results involves querying the reporting API route and authenticating to the API using your OpenShift Container Platform credentials. Reports can be retrieved as
JSON
CSV
Tabular
Prerequisites
- Metering is installed.
-
To access report results, you must either be a cluster administrator, or you need to be granted access using the role in the
report-exporternamespace.openshift-metering
Procedure
Change to the
project:openshift-metering$ oc project openshift-meteringQuery the reporting API for results:
Create a variable for the metering
route then get the route:reporting-api$ meteringRoute="$(oc get routes metering -o jsonpath='{.spec.host}')"$ echo "$meteringRoute"Get the token of your current user to be used in the request:
$ token="$(oc whoami -t)"Set
to the name of the report you created:reportName$ reportName=namespace-cpu-request-2020Set
to one ofreportFormat,csv, orjsonto specify the output format of the API response:tabular$ reportFormat=csvTo get the results, use
to make a request to the reporting API for your report:curl$ curl --insecure -H "Authorization: Bearer ${token}" "https://${meteringRoute}/api/v1/reports/get?name=${reportName}&namespace=openshift-metering&format=$reportFormat"Example output with
reportName=namespace-cpu-request-2020andreportFormat=csvperiod_start,period_end,namespace,pod_request_cpu_core_seconds 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-apiserver,11745.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-apiserver-operator,261.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-authentication,522.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-authentication-operator,261.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-cloud-credential-operator,261.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-cluster-machine-approver,261.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-cluster-node-tuning-operator,3385.800000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-cluster-samples-operator,261.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-cluster-version,522.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-console,522.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-console-operator,261.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-controller-manager,7830.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-controller-manager-operator,261.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-dns,34372.800000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-dns-operator,261.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-etcd,23490.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-image-registry,5993.400000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-ingress,5220.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-ingress-operator,261.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-kube-apiserver,12528.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-kube-apiserver-operator,261.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-kube-controller-manager,8613.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-kube-controller-manager-operator,261.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-machine-api,1305.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-machine-config-operator,9637.800000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-metering,19575.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-monitoring,6256.800000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-network-operator,261.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-sdn,94503.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-service-ca,783.000000 2020-01-01 00:00:00 +0000 UTC,2020-12-30 23:59:59 +0000 UTC,openshift-service-ca-operator,261.000000