Setting up a vanilla prometheus-metrics-adapter
is a time-consuming process. Happily, we have somewhat simplified it by defining a set of CRDs with different Scopes.
You can globally define a metric using the Cluster resource, while the Namespaced resource allows you to redefine it locally. All CRs have the same format.
Namespaced Custom resources
ServiceMetric
.metadata.name
— the name of the metric (used in HPA)..spec.query
— a custom PromQL query that returns a unique value for your label set (you can usesum() by()
,max() by()
, etc., operators for grouping). The following keys must be used in the request:<<.LabelMatchers>>
— will be replaced with a set of{namespace="mynamespace",ingress="myingress"}
labels. You can add your own comma-separated labels list (as in the example below).<<.GroupBy>>
— will be replaced withnamespace,ingress
labels for grouping (max() by(...)
,sum() by (...)
, etc.).
IngressMetric
.metadata.name
— the name of the metric (used in HPA)..spec.query
— a custom PromQL query that returns a unique value for your label set (you can usesum() by()
,max() by()
, etc., operators for grouping). The following keys must be used in the request:<<.LabelMatchers>>
— will be replaced with a set of{namespace="mynamespace",ingress="myingress"}
labels. You can add your own comma-separated labels list (as in the example below).<<.GroupBy>>
— will be replaced withnamespace,ingress
labels for grouping (max() by(...)
,sum() by (...)
, etc.).
PodMetric
.metadata.name
— the name of the metric (used in HPA)..spec.query
— a custom PromQL query that returns a unique value for your label set (you can usesum() by()
,max() by()
, etc., operators for grouping). The following keys must be used in the request:<<.LabelMatchers>>
— will be replaced with a set of{namespace="mynamespace",ingress="myingress"}
labels. You can add your own comma-separated labels list (as in the example below).<<.GroupBy>>
— will be replaced withnamespace,ingress
labels for grouping (max() by(...)
,sum() by (...)
, etc.).
DeploymentMetric
.metadata.name
— the name of the metric (used in HPA)..spec.query
— a custom PromQL query that returns a unique value for your label set (you can usesum() by()
,max() by()
, etc., operators for grouping). The following keys must be used in the request:<<.LabelMatchers>>
— will be replaced with a set of{namespace="mynamespace",ingress="myingress"}
labels. You can add your own comma-separated labels list (as in the example below).<<.GroupBy>>
— will be replaced withnamespace,ingress
labels for grouping (max() by(...)
,sum() by (...)
, etc.).
StatefulSetMetric
.metadata.name
— the name of the metric (used in HPA)..spec.query
— a custom PromQL query that returns a unique value for your label set (you can usesum() by()
,max() by()
, etc., operators for grouping). The following keys must be used in the request:<<.LabelMatchers>>
— will be replaced with a set of{namespace="mynamespace",ingress="myingress"}
labels. You can add your own comma-separated labels list (as in the example below).<<.GroupBy>>
— will be replaced withnamespace,ingress
labels for grouping (max() by(...)
,sum() by (...)
, etc.).
NamespaceMetric
.metadata.name
— the name of the metric (used in HPA)..spec.query
— a custom PromQL query that returns a unique value for your label set (you can usesum() by()
,max() by()
, etc., operators for grouping). The following keys must be used in the request:<<.LabelMatchers>>
— will be replaced with a set of{namespace="mynamespace",ingress="myingress"}
labels. You can add your own comma-separated labels list (as in the example below).<<.GroupBy>>
— will be replaced withnamespace,ingress
labels for grouping (max() by(...)
,sum() by (...)
, etc.).
DaemonSetMetric
(not available to users)
.metadata.name
— the name of the metric (used in HPA)..spec.query
— a custom PromQL query that returns a unique value for your label set (you can usesum() by()
,max() by()
, etc., operators for grouping). The following keys must be used in the request:<<.LabelMatchers>>
— will be replaced with a set of{namespace="mynamespace",ingress="myingress"}
labels. You can add your own comma-separated labels list (as in the example below).<<.GroupBy>>
— will be replaced withnamespace,ingress
labels for grouping (max() by(...)
,sum() by (...)
, etc.).
Cluster Custom resources
ClusterServiceMetric
(not available to users)
.metadata.name
— the name of the metric (used in HPA)..spec.query
— a custom PromQL query that returns a unique value for your label set (you can usesum() by()
,max() by()
, etc., operators for grouping). The following keys must be used in the request:<<.LabelMatchers>>
— will be replaced with a set of{namespace="mynamespace",ingress="myingress"}
labels. You can add your own comma-separated labels list (as in the example below).<<.GroupBy>>
— will be replaced withnamespace,ingress
labels for grouping (max() by(...)
,sum() by (...)
, etc.).
ClusterIngressMetric
(not available to users)
.metadata.name
— the name of the metric (used in HPA)..spec.query
— a custom PromQL query that returns a unique value for your label set (you can usesum() by()
,max() by()
, etc., operators for grouping). The following keys must be used in the request:<<.LabelMatchers>>
— will be replaced with a set of{namespace="mynamespace",ingress="myingress"}
labels. You can add your own comma-separated labels list (as in the example below).<<.GroupBy>>
— will be replaced withnamespace,ingress
labels for grouping (max() by(...)
,sum() by (...)
, etc.).
ClusterPodMetric
(not available to users)
.metadata.name
— the name of the metric (used in HPA)..spec.query
— a custom PromQL query that returns a unique value for your label set (you can usesum() by()
,max() by()
, etc., operators for grouping). The following keys must be used in the request:<<.LabelMatchers>>
— will be replaced with a set of{namespace="mynamespace",ingress="myingress"}
labels. You can add your own comma-separated labels list (as in the example below).<<.GroupBy>>
— will be replaced withnamespace,ingress
labels for grouping (max() by(...)
,sum() by (...)
, etc.).
ClusterDeploymentMetric
(not available to users)
.metadata.name
— the name of the metric (used in HPA)..spec.query
— a custom PromQL query that returns a unique value for your label set (you can usesum() by()
,max() by()
, etc., operators for grouping). The following keys must be used in the request:<<.LabelMatchers>>
— will be replaced with a set of{namespace="mynamespace",ingress="myingress"}
labels. You can add your own comma-separated labels list (as in the example below).<<.GroupBy>>
— will be replaced withnamespace,ingress
labels for grouping (max() by(...)
,sum() by (...)
, etc.).
Example
ClusterStatefulSetMetric
(not available to users)
.metadata.name
— the name of the metric (used in HPA)..spec.query
— a custom PromQL query that returns a unique value for your label set (you can usesum() by()
,max() by()
, etc., operators for grouping). The following keys must be used in the request:<<.LabelMatchers>>
— will be replaced with a set of{namespace="mynamespace",ingress="myingress"}
labels. You can add your own comma-separated labels list (as in the example below).<<.GroupBy>>
— will be replaced withnamespace,ingress
labels for grouping (max() by(...)
,sum() by (...)
, etc.).
Example
ClusterDaemonSetMetric
(not available to users)
.metadata.name
— the name of the metric (used in HPA)..spec.query
— a custom PromQL query that returns a unique value for your label set (you can usesum() by()
,max() by()
, etc., operators for grouping). The following keys must be used in the request:<<.LabelMatchers>>
— will be replaced with a set of{namespace="mynamespace",ingress="myingress"}
labels. You can add your own comma-separated labels list (as in the example below).<<.GroupBy>>
— will be replaced withnamespace,ingress
labels for grouping (max() by(...)
,sum() by (...)
, etc.).