Documentation
¶
Overview ¶
allocationfilterutil provides functionality for parsing V2 of the Kubecost filter language for Allocation types.
e.g. "filter=namespace:kubecost+controllerkind:deployment"
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseAllocationFilter ¶
func ParseAllocationFilter(filter string) (kubecost.AllocationFilter, error)
ParseAllocationFilter converts a string of the V2 Allocation Filter language into a kubecost.AllocationFilter.
Example queries:
namespace:"kubecost" label[app]:"cost-analyzer" node!:"node1","node2" cluster:"cluster-one"+namespace!:"kube-system"
The grammar is approximately as follows:
Original design doc [1] contains first grammar. This is a slight modification of that grammar to help guide the implementation of the parser.
[1] https://docs.google.com/document/d/1HKkp2bv3mnvfQoBZlpHjfZwQ0FzDLOHKpnwV9gQ_KgU/edit?pli=1
<filter> ::= <comparison> ('+' <comparison>)*
NOTE: Language can be extended to support ORs between comparisons by adding a '|' operator in between comparisons, though precedence will have to be carefully defined and it may require adding support for ()-enclosed statements to deal with precedence. This would allow for queries like: namespace:"x"|label[app]="foo"
<comparison> ::= <filter-key> <filter-op> <filter-value>
<filter-key> ::= <filter-field-2> <keyed-access>
| <filter-field-1>
<filter-op> ::= ':' | '!:'
<filter-value> ::= '"' <identifier> '"' (',' <filter-value>)*
<filter-field-2> ::= 'label' | 'annotation'
<filter-field-1> ::= 'cluster' | 'node' | 'namespace'
| 'controllerName' | 'controllerKind' | 'container' | 'pod' | 'services'
<keyed-access> ::= '[' <identifier> ']'
<identifier> ::= --- valid K8s name or Prom-sanitized K8s name
Types ¶
This section is empty.