Skip to content

MetricPredictor API reference

MetricPredictor configures metric history, training and forecast models. Use the predictive trigger reference to connect its predictions to a ScaledObject.

Applies to Predictor v0.1.6.

Group: keda.kedify.io. Kind: MetricPredictor. Scope: Namespaced. The older standalone controller used kedify.io; do not mix those API groups.

Defaults below are schema defaults. Required fields are required within their containing object. Controller behavior can impose additional conditions.

Served: true; storage: true.

FieldTypeRequiredSchema defaultMeaning and validation
specobjectYesNot specifiedspec defines the desired state of MetricPredictor .spec.model is optional, however .spec.source is always required
spec.modelobjectNoNot specifiedModel further specifies the model itself.
spec.model.changepointPriorScalestringNoNot specifiedBy default, this parameter is set to 0.1. Increasing it will make the trend more flexible. Large values will allow many changepoints, small values will allow few changepoints. https://facebook.github.io/prophet/docs/trend_changepoints.html#automatic-changepoint-detection-in-prophet
spec.model.defaultHorizonstringNo"1m"When asking the trained model for predictions, what interval, to the future, should be used from now. default: “1m”
spec.model.holidaysobjectNoNot specified
spec.model.holidays.countryCodestringNo"US"Country code for holidays (ISO 3166-1 alpha-2), if left empty, no holidays will be used. Example: “US”,“CZ”,“CA”,“CN”,“DE”,“JP”, etc. default: US
spec.model.holidays.strengthstringNo"10"Parameter (float) modulating the strength of the holiday components model corresponds to holidays_prior_scale parameter in Prophet Reducing this parameter dampens holiday effects default: 10
spec.model.lookBackPeriodstringNo"2y"When retraining the model to fit the data. What portion of the data should be used. If not specified or set to 0, all the available measurements will be used, otherwise only those from interval [now-lookBackPeriod, now] default: “2y” minLength: 1; pattern: ”^(\d+y)?(\d+mo)?(\d+d)?(\d+h)?(\d+m)?(\d+s)?$”
spec.model.namestringNoNot specifiedExplicit name for the model, if not provided it will be inferred from this MetricPredictor CR instance metadata default: “{namespace}*{name}”
spec.model.retentionstringNo"2y"How long the metric data should be stored in the internal database. When calling retrain, we will delete the older metric data than this period default: 2y minLength: 1; pattern: ”^(\d+y)?(\d+mo)?(\d+d)?(\d+h)?(\d+m)?(\d+s)?$”
spec.model.retrainIntervalstringNo"1h"How often the model should be automatically retrained to fit the new data. minLength: 1; pattern: ”^(\d+y)?(\d+mo)?(\d+d)?(\d+h)?(\d+m)?(\d+s)?$”
spec.model.seasonalityobjectNoNot specifiedFurther specifies the seasonality patterns that model should be looking for.
spec.model.seasonality.customobjectNoNot specifiedAllows specifying custom length and resolution of the seasonality pattern to look for. By default, we create for each model also 6-hr custom seasonality called ‘six’ with fourierOrder=10.
spec.model.seasonality.custom.fourierOrderintegerNo16Number of components of Fourier series approximation https://en.wikipedia.org/wiki/Fourier_series higher numbers can capture more sophisticated seasonal patterns, but can also lead to model overfitting. In a broader sense this can be thought of as ‘resolution’. default: 16
spec.model.seasonality.custom.namestringYesNot specifiedName of the custom seasonality, it will be displayed on the component graph minLength: 1
spec.model.seasonality.custom.periodstringYesNot specifiedCustom length of the expected seasonal pattern. For example if we expect our data to exhibit an 8-hour repeating pattern, put 8h here. minLength: 1; pattern: ”^(\d+y)?(\d+mo)?(\d+d)?(\d+h)?(\d+m)?(\d+s)?$”
spec.model.seasonality.dailystringNo"auto"Can be ‘auto’ (default), ‘true’, ‘false’, or a number of Fourier terms to generate (all passed as string). pattern: ”^([Aa]uto)|([Tt]rue)|([Ff]alse)|(\d+)$”
spec.model.seasonality.modestringNo"additive"‘additive’ (default) or ‘multiplicative’. https://facebook.github.io/prophet/docs/multiplicative_seasonality.html enum: [“additive”,“multiplicative”]
spec.model.seasonality.weeklystringNo"auto"Can be ‘auto’ (default), ‘true’, ‘false’, or a number of Fourier terms to generate (all passed as string). pattern: ”^([Aa]uto)|([Tt]rue)|([Ff]alse)|(\d+)$”
spec.model.seasonality.yearlystringNo"false"Can be ‘auto’, ‘true’, ‘false’ (default), or a number of Fourier terms to generate (all passed as string). pattern: ”^([Aa]uto)|([Tt]rue)|([Ff]alse)|(\d+)$”
spec.model.typestringNo"Prophet"What type of model predictor should be used, allowed values: prophet default: prophet
spec.sourceobjectYesNot specifiedSource describes the metric source for the predictive model. x-kubernetes-validations: [{“message”:“At least one of the fields: ‘keda’, ‘oneShotCsv’, ‘oneShotPrometheus’ or ‘otel’ must be specified”,“rule”:“has(self.keda) || has(self.oneShotCsv) || has(self.oneShotPrometheus) || has(self.otel)”}]
spec.source.collectionIntervalstringNo"1m"How often we should be ingesting the metric data for model KEDA typically send the metric each 15s, this way we can downsample the metrics and save space. default: 1m todo: this
spec.source.kedaobjectNoNot specifiedWhat KEDA Resource (ScaledObject, ScaledJob) should be used as metric source for this model. It is assumed that the KEDA resource is located in the same namespace as MP resource. x-kubernetes-validations: [{“message”:“When Scaled{Object,Job} is used as metric source, trigger name and name must be both specified”,“rule”:“has(self.name) == has(self.triggerName)”}]
spec.source.keda.activebooleanNotrueMarks the metric subscription as ON or OFF. false -> ignore default: true
spec.source.keda.kindstringNoNot specifiedKind can be either ‘scaledjob’ or ‘scaledobject’ default: scaledobject enum: [“scaledjob”,“scaledobject”]
spec.source.keda.namestringYesNot specifiedName of the ScaledObject or ScaledJob located in the same namespace as this MetricPredictor resource minLength: 1
spec.source.keda.triggerNamestringYesNot specifiedWhat trigger name in the referenced Scaled{Object,Job} should be used as metric source for the model. The controller will subscribe to KEDA metrics and based on the trigger name and scaled object name, it will only those metrics that it is interested to minLength: 1
spec.source.oneShotCsvobjectNoNot specifiedUse this field for bootstraping the model with initial data.
spec.source.oneShotCsv.activebooleanNotrueMarks the CSV source as ON or OFF. false -> ignore When the CSV is imported, it will update the .status sub-resource and subsequent ingestion will not be made. default: true
spec.source.oneShotCsv.addTimestampsbooleanNofalseWhen enabled, the timestamp column will be added to the CSV data even if not present. Use this option together with timestampPeriod to set up the correct timing. default: false
spec.source.oneShotCsv.timestampColumnNamestringNo"ds"Name of column that contains timestamps in the referenced CSV file default: ‘ds’
spec.source.oneShotCsv.timestampPeriodstringNo"30s"If addTimestamps is true, what should be the time delta between the two samples The timestamp will be calculated so that last data sample in the CSV file represents the time.now() and the very first one will have timestamp time.now() - number_of_samples*timestampPeriod default: ’30s’
spec.source.oneShotCsv.timezonestringNo"UTC"Timezone used when parsing CSV timestamps or when generating them with addTimestamps=true. All timestamps are converted to UTC before they are stored. Example: Europe/Prague default: ‘UTC’
spec.source.oneShotCsv.urlstringYesNot specifiedUrl that points to a CSV file that should be used to bootstrap the model with initial metric data example: https://raw.githubusercontent.com/facebook/prophet/main/examples/example_wp_log_peyton_manning.csv it is assumed that first line of the file contains header with column names and CSV contains columns called ‘ds’ and ‘y’. if not, use TimestampColumnName and ValueColumnName to select some other columns
spec.source.oneShotCsv.valueColumnNamestringNo"y"Name of column that contains the measured values in the referenced CSV file default: ‘y’
spec.source.oneShotPrometheusobjectNoNot specifiedUse this field for bootstrapping the model with initial data from a Prometheus HTTP API. x-kubernetes-validations: [{“message”:“start, end and step must be specified together”,“rule”:”!(has(self.start) || has(self.end) || has(self.step)) || (has(self.start) && has(self.end) && has(self.step))”}]
spec.source.oneShotPrometheus.activebooleanNotrueMarks the Prometheus one-shot source as ON or OFF. false -> ignore. When the Prometheus data is imported, it will update the .status sub-resource and subsequent ingestion will not be made. default: true
spec.source.oneShotPrometheus.customHeadersstringNoNot specifiedOptional comma-separated HTTP headers passed to Prometheus requests. Example: X-Client-Id=cid,X-Tenant-Id=tid
spec.source.oneShotPrometheus.endstringNoNot specifiedInclusive end time for an explicit range query, as RFC3339 or a Unix timestamp. Must be specified together with Start and Step. Example: 2026-07-08T00:00:00Z minLength: 1
spec.source.oneShotPrometheus.querystringYesNot specifiedPromQL expression used to load samples. When Start, End and Step are omitted, the expression is evaluated as an instant query and may use a range-producing PromQL subquery such as avg(metric)[1w:30s]. When Start, End and Step are set, the expression is evaluated with /api/v1/query_range and must return a scalar or instant vector. minLength: 1
spec.source.oneShotPrometheus.startstringNoNot specifiedInclusive start time for an explicit range query, as RFC3339 or a Unix timestamp. Must be specified together with End and Step. Omit all three fields to use the instant-query/subquery mode. Example: 2026-07-01T00:00:00Z minLength: 1
spec.source.oneShotPrometheus.stepstringNoNot specifiedQuery resolution for an explicit range query, as a Prometheus duration or a number of seconds. Must be greater than zero and specified together with Start and End. Example: 30s minLength: 1
spec.source.oneShotPrometheus.timeoutstringNo"30s"Timeout used both for the Prometheus HTTP request and as the query timeout parameter. default: ’30s’
spec.source.oneShotPrometheus.urlstringYesNot specifiedUrl that points to a Prometheus server. The controller checks /version, uses /api/v1/parse_query to validate Query on Prometheus 3.4 and newer, and uses /api/v1/query or /api/v1/query_range to fetch the data. Example: http://prometheus-server.observability.svc.cluster.local minLength: 1
spec.source.otelobjectNoNot specifiedMetric data will be obtained by OTLP receiver. For this metric source, make sure another OTel exporter is configured to feed this receiver.
spec.source.otel.activebooleanNotrueMarks the metric subscription as ON or OFF. false -> ignore default: true
spec.source.otel.metricNamestringYesNot specifiedName of the metric whose values should be recorded for the model Example: http_requests_total
spec.source.otel.metricTypestringNoNot specifieddefault: gauge enum: [“gauge”,“sum”,“histogram”,“exponentialhistogram”,“summary”]
spec.source.otel.requiredLabelsobjectNoNot specifiedOnly metric having all these labels is recorded this way you can further restrict the values pertaining to the model all the unspecified labels are then considered as matching Example: handler: /api app: myserver
spec.source.otel.requiredLabels.*stringNoNot specified
FieldTypeRequiredSchema defaultMeaning and validation
statusobjectNoNot specifiedstatus defines the observed state of MetricPredictor
status.conditionsarrayNoNot specifiedThe status of each condition is one of True, False, or Unknown.
status.conditions[]objectNoNot specified
status.conditions[].lastTransitionTimestringNoNot specified
status.conditions[].messagestringNoNot specifiedA human-readable message indicating details about the transition.
status.conditions[].reasonstringNoNot specifiedThe reason for the condition’s last transition.
status.conditions[].statusstringYesNot specifiedStatus of the condition, one of True, False, Unknown.
status.conditions[].typestringYesNot specifiedType of condition
status.modelNamestringNoNot specifiedName of the ML model that is used for forecasting.
status.sourceobjectNoNot specifiedDetails about the metric source
status.source.activeintegerNoNot specified
status.source.detailstringNoNot specified
status.source.kindstringNoNot specified
status.source.namestringNoNot specifiedpattern: ”^(KEDA|OTel|CSV|Prometheus|no sources)(,(KEDA|OTel|CSV|Prometheus))*$”
Terminal window
kubectl get crd metricpredictors.keda.kedify.io -o yaml
kubectl explain metricpredictor.spec --api-version=keda.kedify.io/v1alpha1 --recursive

This resource trains from a named trigger on an existing ScaledObject in the same namespace. Use strings for decimal model parameters and 7d for a week; the duration schema does not accept 1w.

apiVersion: keda.kedify.io/v1alpha1
kind: MetricPredictor
metadata:
name: e-shop
namespace: app
spec:
model:
type: Prophet
defaultHorizon: 2m
lookBackPeriod: 1y
retention: 1y
retrainInterval: 7d
changepointPriorScale: "0.1"
seasonality:
weekly: "auto"
source:
keda:
kind: scaledobject
name: e-shop-nginx
triggerName: http-requests
active: true

Installtrain and scale a sample workloadinspect and tune the model. Check resource status and events after changes. Use predictive troubleshooting for missing history or inaccurate forecasts.