mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
Added Metering docs for OpenShift Serverless
This commit is contained in:
committed by
openshift-cherrypick-robot
parent
728d0f6ff2
commit
2e1470fd54
@@ -1244,6 +1244,9 @@ Topics:
|
||||
### Monitoring
|
||||
- Name: Monitoring OpenShift Serverless components
|
||||
File: monitoring-serverless
|
||||
### Metering
|
||||
- Name: Using metering with OpenShift Serverless
|
||||
File: serverless-metering
|
||||
### Cluster Logging
|
||||
- Name: Cluster logging with OpenShift Serverless
|
||||
File: cluster-logging-serverless
|
||||
|
||||
71
modules/serverless-metering-datasources.adoc
Normal file
71
modules/serverless-metering-datasources.adoc
Normal file
@@ -0,0 +1,71 @@
|
||||
// Module included in the following assemblies:
|
||||
// serverless-metering.adoc
|
||||
|
||||
[id="datasources-metering-serverless_{context}"]
|
||||
= Datasources for Knative Serving metering
|
||||
The following `ReportDataSources` are examples of how Knative Serving can be used with {product-title} metering.
|
||||
|
||||
[id="knative-service-cpu-usage-ds_{context}"]
|
||||
== Datasource for CPU usage in Knative Serving
|
||||
This datasource provides the accumulated CPU seconds used per Knative service over the report time period.
|
||||
|
||||
.YAML file
|
||||
[source, yaml]
|
||||
----
|
||||
apiVersion: metering.openshift.io/v1alpha1
|
||||
kind: ReportDataSource
|
||||
metadata:
|
||||
name: knative-service-cpu-usage
|
||||
spec:
|
||||
prometheusMetricsImporter:
|
||||
query: >
|
||||
sum
|
||||
by(namespace,
|
||||
label_serving_knative_dev_service,
|
||||
label_serving_knative_dev_revision)
|
||||
(
|
||||
label_replace(rate(container_cpu_usage_seconds_total{container_name!="POD",container_name!="",pod_name!=""}[1m]), "pod", "$1", "pod_name", "(.*)")
|
||||
*
|
||||
on(pod, namespace)
|
||||
group_left(label_serving_knative_dev_service, label_serving_knative_dev_revision)
|
||||
kube_pod_labels{label_serving_knative_dev_service!=""}
|
||||
)
|
||||
----
|
||||
|
||||
[id="knative-service-memory-usage-ds_{context}"]
|
||||
== Datasource for memory usage in Knative Serving
|
||||
This datasource provides the average memory consumption per Knative service over the report time period.
|
||||
|
||||
.YAML file
|
||||
[source, yaml]
|
||||
----
|
||||
apiVersion: metering.openshift.io/v1alpha1
|
||||
kind: ReportDataSource
|
||||
metadata:
|
||||
name: knative-service-memory-usage
|
||||
spec:
|
||||
prometheusMetricsImporter:
|
||||
query: >
|
||||
sum
|
||||
by(namespace,
|
||||
label_serving_knative_dev_service,
|
||||
label_serving_knative_dev_revision)
|
||||
(
|
||||
label_replace(container_memory_usage_bytes{container_name!="POD", container_name!="",pod_name!=""}, "pod", "$1", "pod_name", "(.*)")
|
||||
*
|
||||
on(pod, namespace)
|
||||
group_left(label_serving_knative_dev_service, label_serving_knative_dev_revision)
|
||||
kube_pod_labels{label_serving_knative_dev_service!=""}
|
||||
)
|
||||
----
|
||||
|
||||
[id="applying-datasources-knative_{context}"]
|
||||
== Applying Datasources for Knative Serving metering
|
||||
You can apply the `ReportDataSources` by using the following command:
|
||||
----
|
||||
$ oc apply -f <datasource-name>.yaml
|
||||
----
|
||||
.Example
|
||||
----
|
||||
$ oc apply -f knative-service-memory-usage.yaml
|
||||
----
|
||||
127
modules/serverless-metering-queries.adoc
Normal file
127
modules/serverless-metering-queries.adoc
Normal file
@@ -0,0 +1,127 @@
|
||||
// Module included in the following assemblies:
|
||||
// serverless-metering.adoc
|
||||
|
||||
[id="queries-metering-serverless_{context}"]
|
||||
= Queries for Knative Serving metering
|
||||
The following `ReportQuery` resources reference the example `DataSources` provided.
|
||||
|
||||
[id="knative-service-cpu-usage-query_{context}"]
|
||||
== Query for CPU usage in Knative Serving
|
||||
|
||||
.YAML file
|
||||
[source, yaml]
|
||||
----
|
||||
apiVersion: metering.openshift.io/v1alpha1
|
||||
kind: ReportQuery
|
||||
metadata:
|
||||
name: knative-service-cpu-usage
|
||||
spec:
|
||||
inputs:
|
||||
- name: ReportingStart
|
||||
type: time
|
||||
- name: ReportingEnd
|
||||
type: timeq
|
||||
- default: knative-service-cpu-usage
|
||||
name: KnativeServiceCpuUsageDataSource
|
||||
type: ReportDataSource
|
||||
columns:
|
||||
- name: period_start
|
||||
type: timestamp
|
||||
unit: date
|
||||
- name: period_end
|
||||
type: timestamp
|
||||
unit: date
|
||||
- name: namespace
|
||||
type: varchar
|
||||
unit: kubernetes_namespace
|
||||
- name: service
|
||||
type: varchar
|
||||
- name: data_start
|
||||
type: timestamp
|
||||
unit: date
|
||||
- name: data_end
|
||||
type: timestamp
|
||||
unit: date
|
||||
- name: service_cpu_seconds
|
||||
type: double
|
||||
unit: cpu_core_seconds
|
||||
query: |
|
||||
SELECT
|
||||
timestamp '{| default .Report.ReportingStart .Report.Inputs.ReportingStart| prestoTimestamp |}' AS period_start,
|
||||
timestamp '{| default .Report.ReportingEnd .Report.Inputs.ReportingEnd | prestoTimestamp |}' AS period_end,
|
||||
labels['namespace'] as project,
|
||||
labels['label_serving_knative_dev_service'] as service,
|
||||
min("timestamp") as data_start,
|
||||
max("timestamp") as data_end,
|
||||
sum(amount * "timeprecision") AS service_cpu_seconds
|
||||
FROM {| dataSourceTableName .Report.Inputs.KnativeServiceCpuUsageDataSource |}
|
||||
WHERE "timestamp" >= timestamp '{| default .Report.ReportingStart .Report.Inputs.ReportingStart | prestoTimestamp |}'
|
||||
AND "timestamp" < timestamp '{| default .Report.ReportingEnd .Report.Inputs.ReportingEnd | prestoTimestamp |}'
|
||||
GROUP BY labels['namespace'],labels['label_serving_knative_dev_service']
|
||||
----
|
||||
|
||||
[id="knative-service-memory-usage-query_{context}"]
|
||||
== Query for memory usage in Knative Serving
|
||||
|
||||
.YAML file
|
||||
[source, yaml]
|
||||
----
|
||||
apiVersion: metering.openshift.io/v1alpha1
|
||||
kind: ReportQuery
|
||||
metadata:
|
||||
name: knative-service-memory-usage
|
||||
spec:
|
||||
inputs:
|
||||
- name: ReportingStart
|
||||
type: time
|
||||
- name: ReportingEnd
|
||||
type: timeq
|
||||
- default: knative-service-memory-usage
|
||||
name: KnativeServiceMemoryUsageDataSource
|
||||
type: ReportDataSource
|
||||
columns:
|
||||
- name: period_start
|
||||
type: timestamp
|
||||
unit: date
|
||||
- name: period_end
|
||||
type: timestamp
|
||||
unit: date
|
||||
- name: namespace
|
||||
type: varchar
|
||||
unit: kubernetes_namespace
|
||||
- name: service
|
||||
type: varchar
|
||||
- name: data_start
|
||||
type: timestamp
|
||||
unit: date
|
||||
- name: data_end
|
||||
type: timestamp
|
||||
unit: date
|
||||
- name: service_usage_memory_byte_seconds
|
||||
type: double
|
||||
unit: bytes_seconds
|
||||
query: |
|
||||
SELECT
|
||||
timestamp '{| default .Report.ReportingStart .Report.Inputs.ReportingStart| prestoTimestamp |}' AS period_start,
|
||||
timestamp '{| default .Report.ReportingEnd .Report.Inputs.ReportingEnd | prestoTimestamp |}' AS period_end,
|
||||
labels['namespace'] as project,
|
||||
labels['label_serving_knative_dev_service'] as service,
|
||||
min("timestamp") as data_start,
|
||||
max("timestamp") as data_end,
|
||||
sum(amount * "timeprecision") AS service_usage_memory_byte_seconds
|
||||
FROM {| dataSourceTableName .Report.Inputs.KnativeServiceMemoryUsageDataSource |}
|
||||
WHERE "timestamp" >= timestamp '{| default .Report.ReportingStart .Report.Inputs.ReportingStart | prestoTimestamp |}'
|
||||
AND "timestamp" < timestamp '{| default .Report.ReportingEnd .Report.Inputs.ReportingEnd | prestoTimestamp |}'
|
||||
GROUP BY labels['namespace'],labels['label_serving_knative_dev_service']
|
||||
----
|
||||
|
||||
[id="applying-queries-knative_{context}"]
|
||||
== Applying Queries for Knative Serving metering
|
||||
You can apply the `ReportQuery` by using the following command:
|
||||
----
|
||||
$ oc apply -f <query-name>.yaml
|
||||
----
|
||||
.Example
|
||||
----
|
||||
$ oc apply -f knative-service-memory-usage.yaml
|
||||
----
|
||||
40
modules/serverless-metering-reports.adoc
Normal file
40
modules/serverless-metering-reports.adoc
Normal file
@@ -0,0 +1,40 @@
|
||||
// Module included in the following assemblies:
|
||||
// serverless-metering.adoc
|
||||
|
||||
[id="reports-metering-serverless_{context}"]
|
||||
= Metering reports for Knative Serving
|
||||
|
||||
You can run metering reports against Knative Serving by creating `Report` resources.
|
||||
Before you run a report, you must modify the input parameter within the `Report` resource to specify the start and end dates of the reporting period.
|
||||
|
||||
.YAML file
|
||||
[source, yaml]
|
||||
----
|
||||
apiVersion: metering.openshift.io/v1alpha1
|
||||
kind: Report
|
||||
metadata:
|
||||
name: knative-service-cpu-usage
|
||||
spec:
|
||||
reportingStart: '2019-06-01T00:00:00Z' <1>
|
||||
reportingEnd: '2019-06-30T23:59:59Z' <2>
|
||||
query: knative-service-cpu-usage <3>
|
||||
runImmediately: true
|
||||
----
|
||||
|
||||
<1> Start date of the report, in ISO 8601 format.
|
||||
<2> End date of the report, in ISO 8601 format.
|
||||
<3> Either `knative-service-cpu-usage` for CPU usage report or `knative-service-memory-usage` for a memory usage report.
|
||||
|
||||
[id="reports-metering-serverless-run_{context}"]
|
||||
== Running a metering report
|
||||
Once you have provided the input parameters, you can run the report using the command:
|
||||
----
|
||||
$ oc apply -f <report-name>.yml
|
||||
----
|
||||
You can then check the report as shown in the following example:
|
||||
----
|
||||
$ kubectl get report
|
||||
|
||||
NAME QUERY SCHEDULE RUNNING FAILED LAST REPORT TIME AGE
|
||||
knative-service-cpu-usage knative-service-cpu-usage Finished 2019-06-30T23:59:59Z 10h
|
||||
----
|
||||
17
serverless/serverless-metering.adoc
Normal file
17
serverless/serverless-metering.adoc
Normal file
@@ -0,0 +1,17 @@
|
||||
[id="metering-serverless"]
|
||||
= Using metering with {ServerlessProductName}
|
||||
include::modules/common-attributes.adoc[]
|
||||
include::modules/serverless-document-attributes.adoc[]
|
||||
:context: metering-serverless
|
||||
|
||||
As an {product-title} cluster administrator, you can use metering to analyze what is happening in your {ServerlessProductName} cluster.
|
||||
|
||||
For more information about metering on {product-title}, see xref:../metering/metering-about-metering.adoc[About metering].
|
||||
|
||||
[id="installing-metering-serverless_{context}"]
|
||||
== Installing metering
|
||||
For information about installing metering on {product-title}, see xref:../metering/metering-installing-metering.adoc[Installing Metering].
|
||||
|
||||
include::modules/serverless-metering-datasources.adoc[leveloffset=+1]
|
||||
include::modules/serverless-metering-queries.adoc[leveloffset=+1]
|
||||
include::modules/serverless-metering-reports.adoc[leveloffset=+1]
|
||||
Reference in New Issue
Block a user