Skip to main content

pods_query.go

Pods_query.go - Overview

  1. Overview

This file defines a PodsTableListQuery variable, which is a pre-configured query for retrieving and displaying Kubernetes pod metrics in a table format. It uses the v3.QueryRangeParamsV3 struct to define a composite query with multiple builder queries for different pod metrics like CPU, memory, restarts and phase.

  1. Detailed Documentation

PodsTableListQuery

  • Purpose: Defines a complex query to fetch various metrics related to Kubernetes pods and format them for display in a table. It includes queries for CPU utilization, memory utilization, restart counts, and pod phase.
  • Type: v3.QueryRangeParamsV3

v3.QueryRangeParamsV3 fields:

  • CompositeQuery:
    • Type: *v3.CompositeQuery
    • Description: Defines the structure of the composite query, including individual builder queries.
  • CompositeQuery.BuilderQueries:
    • Type: map[string]*v3.BuilderQuery
    • Description: A map of named builder queries. Each key represents a query name (e.g., "A", "B"), and each value is a pointer to a v3.BuilderQuery struct.
  • Version:
    • Type: string
    • Description: Specifies the version of the query format ("v4").
  • FormatForWeb:
    • Type: bool
    • Description: Indicates whether the data should be formatted for web display (true).

v3.BuilderQuery fields (for each query A-K):

  • QueryName:
    • Type: string
    • Description: A unique identifier for the query (e.g., "A", "B", "C").
  • DataSource:
    • Type: v3.DataSource
    • Description: Specifies the source of the data ( v3.DataSourceMetrics).
  • AggregateAttribute:
    • Type: v3.AttributeKey
    • Description: Defines the attribute to aggregate (e.g., CPU usage, memory usage).
  • AggregateAttribute.Key:
    • Type: string
    • Description: The name of the metric to aggregate (e.g., from metricNamesForPods).
  • AggregateAttribute.DataType:
    • Type: v3.AttributeKeyDataType
    • Description: The data type of the attribute (v3.AttributeKeyDataTypeFloat64 for numeric metrics, v3.AttributeKeyDataTypeString for string attributes).
  • Temporality:
    • Type: v3.Temporality
    • Description: Specifies the temporality of the metric (v3.Unspecified).
  • Filters:
    • Type: *v3.FilterSet
    • Description: Defines filters to apply to the data.
  • Filters.Operator:
    • Type: string
    • Description: The logical operator to combine filters ("AND").
  • Filters.Items:
    • Type: []v3.FilterItem
    • Description: A slice of filter items.
  • GroupBy:
    • Type: []v3.AttributeKey
    • Description: Defines how to group the data.
  • GroupBy[].Key:
    • Type: string
    • Description: The attribute key to group by (k8sPodUIDAttrKey).
  • GroupBy[].DataType:
    • Type: v3.AttributeKeyDataType
    • Description: The data type of the group by attribute (v3.AttributeKeyDataTypeString).
  • GroupBy[].Type:
    • Type: v3.AttributeKeyType
    • Description: The type of the group by attribute (v3.AttributeKeyTypeResource).
  • Expression:
    • Type: string
    • Description: An expression to use for calculations (same as QueryName in this case).
  • ReduceTo:
    • Type: v3.ReduceToOperator
    • Description: Specifies how to reduce the data (v3.ReduceToOperatorAvg, v3.ReduceToOperatorSum, or v3.ReduceToOperatorLast).
  • TimeAggregation:
    • Type: v3.TimeAggregation
    • Description: Specifies how to aggregate data over time (v3.TimeAggregationAvg or v3.TimeAggregationAnyLast).
  • SpaceAggregation:
    • Type: v3.SpaceAggregation
    • Description: Specifies how to aggregate data across space (v3.SpaceAggregationSum, v3.SpaceAggregationAvg, or v3.SpaceAggregationCount, v3.SpaceAggregationMax).
  • Functions:
    • Type: []v3.Function
    • Description: Specifies functions to apply to the data. Only applicable to query "G".
  • Disabled:
    • Type: bool
    • Description: Indicates whether the query is disabled (false).

v3.CompositeQuery fields:

  • PanelType:
    • Type: v3.PanelType
    • Description: Defines the panel type for display (v3.PanelTypeTable).
  • QueryType:
    • Type: v3.QueryType
    • Description: Specifies the type of query (v3.QueryTypeBuilder).
  1. Code Examples

None.

  1. Clarity and Accuracy

The documentation accurately reflects the code.

  1. Markdown & MDX Perfection

The markdown is properly formatted.

Include in Getting Started: NO