2024-11-12 20:53:40 +05:30
|
|
|
package inframetrics
|
|
|
|
|
|
2025-03-20 21:01:41 +05:30
|
|
|
import v3 "github.com/SigNoz/signoz/pkg/query-service/model/v3"
|
2024-11-12 20:53:40 +05:30
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
metricNamesForWorkloads = map[string]string{
|
2025-07-07 16:55:20 +05:30
|
|
|
"cpu": GetDotMetrics("k8s_pod_cpu_usage"),
|
2025-05-30 15:57:29 +05:30
|
|
|
"cpu_request": GetDotMetrics("k8s_pod_cpu_request_utilization"),
|
|
|
|
|
"cpu_limit": GetDotMetrics("k8s_pod_cpu_limit_utilization"),
|
|
|
|
|
"memory": GetDotMetrics("k8s_pod_memory_usage"),
|
|
|
|
|
"memory_request": GetDotMetrics("k8s_pod_memory_request_utilization"),
|
|
|
|
|
"memory_limit": GetDotMetrics("k8s_pod_memory_limit_utilization"),
|
|
|
|
|
"restarts": GetDotMetrics("k8s_container_restarts"),
|
2024-11-12 20:53:40 +05:30
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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,
|
2024-12-19 17:22:39 +05:30
|
|
|
SpaceAggregation: v3.SpaceAggregationAvg,
|
2024-11-12 20:53:40 +05:30
|
|
|
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,
|
2024-12-19 17:22:39 +05:30
|
|
|
SpaceAggregation: v3.SpaceAggregationAvg,
|
2024-11-12 20:53:40 +05:30
|
|
|
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,
|
2024-12-19 17:22:39 +05:30
|
|
|
SpaceAggregation: v3.SpaceAggregationAvg,
|
2024-11-12 20:53:40 +05:30
|
|
|
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,
|
2024-12-19 17:22:39 +05:30
|
|
|
SpaceAggregation: v3.SpaceAggregationAvg,
|
2024-11-12 20:53:40 +05:30
|
|
|
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,
|
|
|
|
|
}
|