Filter Parameters (v2)
This document outlines the filtering language added to the Allocation API in v1.96 of Kubecost, superseding the original filtering parameters (e.g.
filterNamespaces=). One of the primary goals of the new filter language was to introduce support for "not equals" (e.g.
namespace != kubecost) queries while maintaining extensibility.
Note: V1 filters will continue to be supported in all relevant APIs. APIs will first check for the
filter=parameter. If it is present, V2 filters will be used. If it is not present, APIs will attempt to use V1 filters.
The supported filter fields as of v1.96 are:
annotation(same syntax as label, see examples)
The supported filter ops as of v1.96 are:
:(equality, or "contains" if an array type)
!:(inequality, or "not contains" if an array type)
Filter values are strings surrounded by
". Multiple values can be separated by commas
,, representing logical OR.
Each individual filter is separated by a
+, representing logical AND.
Filters exist under the
filter=parameter in supported APIs. Supported APIs are currently:
Here are some example filters to see how the filtering language works:
namespace:"kubecost"+container:"cost-model"Return only results that are in the
kubecostnamespace and are for the
cluster:"cluster-one"+label[app]="cost-analyzer"Return only results in cluster
cluster-onethat are labeled with
cluster!:"cluster-one"Ignore results from cluster
namespace:"kubecost","kube-system"Return only results from namespaces
namespace!:"kubecost","kube-system"Return results for all namespaces except
For example, in an Allocation query:
The format is essentially:
<filter field> <filter op> <filter value>