mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-16 16:51:49 +08:00
167 lines
5.0 KiB
Go
167 lines
5.0 KiB
Go
package inframetrics
|
|
|
|
import v3 "go.signoz.io/signoz/pkg/query-service/model/v3"
|
|
|
|
var (
|
|
metricNamesForWorkloads = map[string]string{
|
|
"cpu": "k8s_pod_cpu_utilization",
|
|
"cpu_req": "k8s_pod_cpu_request_utilization",
|
|
"cpu_limit": "k8s_pod_cpu_limit_utilization",
|
|
"memory": "k8s_pod_memory_usage",
|
|
"memory_req": "k8s_pod_memory_request_utilization",
|
|
"memory_limit": "k8s_pod_memory_limit_utilization",
|
|
"restarts": "k8s_container_restarts",
|
|
}
|
|
)
|
|
|
|
var WorkloadTableListQuery = v3.QueryRangeParamsV3{
|
|
CompositeQuery: &v3.CompositeQuery{
|
|
BuilderQueries: map[string]*v3.BuilderQuery{
|
|
// pod cpu utilization
|
|
"A": {
|
|
QueryName: "A",
|
|
DataSource: v3.DataSourceMetrics,
|
|
AggregateAttribute: v3.AttributeKey{
|
|
Key: metricNamesForWorkloads["cpu"],
|
|
DataType: v3.AttributeKeyDataTypeFloat64,
|
|
},
|
|
Temporality: v3.Unspecified,
|
|
Filters: &v3.FilterSet{
|
|
Operator: "AND",
|
|
Items: []v3.FilterItem{},
|
|
},
|
|
GroupBy: []v3.AttributeKey{},
|
|
Expression: "A",
|
|
ReduceTo: v3.ReduceToOperatorAvg,
|
|
TimeAggregation: v3.TimeAggregationAvg,
|
|
SpaceAggregation: v3.SpaceAggregationSum,
|
|
Disabled: false,
|
|
},
|
|
// pod cpu request utilization
|
|
"B": {
|
|
QueryName: "B",
|
|
DataSource: v3.DataSourceMetrics,
|
|
AggregateAttribute: v3.AttributeKey{
|
|
Key: metricNamesForWorkloads["cpu_request"],
|
|
DataType: v3.AttributeKeyDataTypeFloat64,
|
|
},
|
|
Temporality: v3.Unspecified,
|
|
Filters: &v3.FilterSet{
|
|
Operator: "AND",
|
|
Items: []v3.FilterItem{},
|
|
},
|
|
GroupBy: []v3.AttributeKey{},
|
|
Expression: "B",
|
|
ReduceTo: v3.ReduceToOperatorAvg,
|
|
TimeAggregation: v3.TimeAggregationAvg,
|
|
SpaceAggregation: v3.SpaceAggregationSum,
|
|
Disabled: false,
|
|
},
|
|
// pod cpu limit utilization
|
|
"C": {
|
|
QueryName: "C",
|
|
DataSource: v3.DataSourceMetrics,
|
|
AggregateAttribute: v3.AttributeKey{
|
|
Key: metricNamesForWorkloads["cpu_limit"],
|
|
DataType: v3.AttributeKeyDataTypeFloat64,
|
|
},
|
|
Temporality: v3.Unspecified,
|
|
Filters: &v3.FilterSet{
|
|
Operator: "AND",
|
|
Items: []v3.FilterItem{},
|
|
},
|
|
GroupBy: []v3.AttributeKey{},
|
|
Expression: "C",
|
|
ReduceTo: v3.ReduceToOperatorAvg,
|
|
TimeAggregation: v3.TimeAggregationAvg,
|
|
SpaceAggregation: v3.SpaceAggregationSum,
|
|
Disabled: false,
|
|
},
|
|
// pod memory utilization
|
|
"D": {
|
|
QueryName: "D",
|
|
DataSource: v3.DataSourceMetrics,
|
|
AggregateAttribute: v3.AttributeKey{
|
|
Key: metricNamesForWorkloads["memory"],
|
|
DataType: v3.AttributeKeyDataTypeFloat64,
|
|
},
|
|
Temporality: v3.Unspecified,
|
|
Filters: &v3.FilterSet{
|
|
Operator: "AND",
|
|
Items: []v3.FilterItem{},
|
|
},
|
|
GroupBy: []v3.AttributeKey{},
|
|
Expression: "D",
|
|
ReduceTo: v3.ReduceToOperatorAvg,
|
|
TimeAggregation: v3.TimeAggregationAvg,
|
|
SpaceAggregation: v3.SpaceAggregationSum,
|
|
Disabled: false,
|
|
},
|
|
// pod memory request utilization
|
|
"E": {
|
|
QueryName: "E",
|
|
DataSource: v3.DataSourceMetrics,
|
|
AggregateAttribute: v3.AttributeKey{
|
|
Key: metricNamesForWorkloads["memory_request"],
|
|
DataType: v3.AttributeKeyDataTypeFloat64,
|
|
},
|
|
Temporality: v3.Unspecified,
|
|
Filters: &v3.FilterSet{
|
|
Operator: "AND",
|
|
Items: []v3.FilterItem{},
|
|
},
|
|
GroupBy: []v3.AttributeKey{},
|
|
Expression: "E",
|
|
ReduceTo: v3.ReduceToOperatorAvg,
|
|
TimeAggregation: v3.TimeAggregationAvg,
|
|
SpaceAggregation: v3.SpaceAggregationSum,
|
|
Disabled: false,
|
|
},
|
|
// pod memory limit utilization
|
|
"F": {
|
|
QueryName: "F",
|
|
DataSource: v3.DataSourceMetrics,
|
|
AggregateAttribute: v3.AttributeKey{
|
|
Key: metricNamesForWorkloads["memory_limit"],
|
|
DataType: v3.AttributeKeyDataTypeFloat64,
|
|
},
|
|
Temporality: v3.Unspecified,
|
|
Filters: &v3.FilterSet{
|
|
Operator: "AND",
|
|
Items: []v3.FilterItem{},
|
|
},
|
|
GroupBy: []v3.AttributeKey{},
|
|
Expression: "F",
|
|
ReduceTo: v3.ReduceToOperatorAvg,
|
|
TimeAggregation: v3.TimeAggregationAvg,
|
|
SpaceAggregation: v3.SpaceAggregationSum,
|
|
Disabled: false,
|
|
},
|
|
"G": {
|
|
QueryName: "G",
|
|
DataSource: v3.DataSourceMetrics,
|
|
AggregateAttribute: v3.AttributeKey{
|
|
Key: metricNamesForWorkloads["restarts"],
|
|
DataType: v3.AttributeKeyDataTypeFloat64,
|
|
},
|
|
Temporality: v3.Unspecified,
|
|
Filters: &v3.FilterSet{
|
|
Operator: "AND",
|
|
Items: []v3.FilterItem{},
|
|
},
|
|
GroupBy: []v3.AttributeKey{},
|
|
Expression: "G",
|
|
ReduceTo: v3.ReduceToOperatorSum,
|
|
TimeAggregation: v3.TimeAggregationAnyLast,
|
|
SpaceAggregation: v3.SpaceAggregationMax,
|
|
Functions: []v3.Function{{Name: v3.FunctionNameRunningDiff}},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
PanelType: v3.PanelTypeTable,
|
|
QueryType: v3.QueryTypeBuilder,
|
|
},
|
|
Version: "v4",
|
|
FormatForWeb: true,
|
|
}
|