hosts_query.go
hosts_query.go - Overview
This file defines a HostsTableListQuery
variable, which is a pre-configured query for retrieving and displaying host-related metrics in a table format. It uses the v3
package's data structures to define the query parameters, including data sources, aggregations, filters, and grouping. The query is designed to fetch CPU usage, memory usage, CPU wait time, and CPU load average for hosts, excluding data from a specified agent.
Detailed Documentation
HostsTableListQuery
- Purpose: Defines a composite query to retrieve host metrics for display in a table. It specifies data sources, aggregations (average, sum), filters (excluding idle CPU states, filtering out a specific agent name), and grouping (by host name). It also defines expressions to calculate CPU usage (%), memory usage (%), and CPU wait time (%).
- Type:
v3.QueryRangeParamsV3
- Fields:
CompositeQuery
:*v3.CompositeQuery
- A composite query consisting of multiple builder queries.BuilderQueries
:map[string]*v3.BuilderQuery
- A map of named builder queries that define individual data retrieval and processing steps. The keys are "A", "B", "F1", "C", "D", "F2", "E", "F", "F3", and "G". Each builder query specifies:QueryName
:string
- A unique name for the query (e.g., "A", "B", "C", "D", "E", "F", "F1", "F2", "F3", "G").DataSource
:v3.DataSource
- The source of the data, which isv3.DataSourceMetrics
for all queries except composite queries.AggregateAttribute
:v3.AttributeKey
- The attribute to aggregate (e.g., CPU, memory, wait, load15). Contains the key, data type, etc.Key
:string
- The name of the metric (e.g., metricNamesForHosts["cpu"], metricNamesForHosts["memory"], metricNamesForHosts["wait"], metricNamesForHosts["load15"]).DataType
:v3.AttributeKeyDataType
- The data type of the metric (e.g.,v3.AttributeKeyDataTypeFloat64
).
Temporality
:v3.Temporality
- Specifies if the metric is cumulative or not.Filters
:*v3.FilterSet
- Filters to apply to the data.Operator
:string
- The logical operator for the filter set (e.g., "AND").Items
:[]v3.FilterItem
- A slice of filter items, each specifying a key, operator, and value.
GroupBy
:[]v3.AttributeKey
- The attributes to group the data by (e.g., host name).Expression
:string
- An expression to calculate a value (e.g., "A", "B", "C", "D", "E", "F", "A/B", "C/D", "E/F", "G").ReduceTo
:v3.ReduceToOperator
- The operator to reduce the data to (e.g.,v3.ReduceToOperatorAvg
).TimeAggregation
:v3.TimeAggregation
- The time aggregation function (e.g.,v3.TimeAggregationRate
,v3.TimeAggregationAvg
).SpaceAggregation
:v3.SpaceAggregation
- The space aggregation function (e.g.,v3.SpaceAggregationSum
).Disabled
:bool
- Whether the query is disabled. Some queries are disabled, and some are not.Legend
:string
- The legend for the query (e.g., "CPU Usage (%)", "Memory Usage (%)", "CPU Wait Time (%)", "CPU Load Average (15m)").
PanelType
:v3.PanelType
- The type of panel to display the data in, which isv3.PanelTypeTable
.QueryType
:v3.QueryType
- The type of query, which isv3.QueryTypeBuilder
.
Version
:string
- The version of the query, which is "v4".FormatForWeb
:bool
- Whether the data should be formatted for the web, which istrue
.
Code Examples
None
Getting Started Relevance
Include in Getting Started: NO