mirror of
https://github.com/hanzoai/o11y.git
synced 2026-10-15 12:58:33 +00:00
* fork: own SigNoz platform deps under hanzoai, repath imports off upstream brand
Phase 1 of the full-fork mandate: eliminate upstream-branded SigNoz modules,
own them as public hanzoai forks, and repath all imports to hanzoai paths.
Owned deps (new public hanzoai forks, module renamed to hanzoai path):
github.com/SigNoz/signoz-otel-collector v0.144.3
-> github.com/hanzoai/signoz-otel-collector v0.144.6 (module renamed)
github.com/SigNoz/clickhouse-go-mock v0.14.0
-> github.com/hanzoai/clickhouse-go-mock v0.14.1 (module renamed)
github.com/SigNoz/govaluate v0.0.0-20240203125216-988004ccc7fd
-> github.com/hanzoai/govaluate v0.1.0 (module renamed)
github.com/SigNoz/expr (replace target for github.com/expr-lang/expr)
-> github.com/hanzoai/expr v1.17.8 (upstream module path preserved,
consumed via replace exactly like the prior SigNoz/expr fork)
In-repo repath: the vendored SigNoz source tree in pkg/, ee/, cmd/ is now
self-referenced as github.com/hanzoai/o11y/... instead of
github.com/SigNoz/signoz/... (1300+ import lines across 377 files), matching
the 750 files already on the hanzoai path. Zero SigNoz-branded module
references remain in go.mod or any .go import.
Generic ecosystem libraries (golang.org/x, google.golang.org, prometheus,
opentelemetry, gin, cobra, luxfi/*, etc.) are left untouched — only the
SigNoz platform fork is owned.
Pre-existing (NOT introduced here): origin/main does not `go build ./...`
because 22 packages are imported but absent from the vendored tree; 14 of
them (roletypes, grammar, cloudintegrations, resourcefilter, integrationtypes,
metricsexplorer, metrics_explorer, times, agg_rewrite, bucket_cache,
sqlitesqlstore, sqlschema/postgressqlschema, sqlstore/postgressqlstore,
cloudintegrations/services) exist in no upstream SigNoz version and must be
vendored into hanzoai/o11y from hanzoai/signoz@770f464f to finish. This
repath is orthogonal to that gap.
* docs(LLM.md): fork boundary map + pre-existing compile-gap inventory
---------
Co-authored-by: Hanzo Dev <[email protected]>
235 lines
8.9 KiB
Go
235 lines
8.9 KiB
Go
package implinframonitoring
|
|
|
|
import (
|
|
"github.com/hanzoai/o11y/pkg/types/inframonitoringtypes"
|
|
"github.com/hanzoai/o11y/pkg/types/metrictypes"
|
|
qbtypes "github.com/hanzoai/o11y/pkg/types/querybuildertypes/querybuildertypesv5"
|
|
"github.com/hanzoai/o11y/pkg/types/telemetrytypes"
|
|
)
|
|
|
|
const daemonSetsBaseFilterExpr = "k8s.daemonset.name != ''"
|
|
|
|
var daemonSetNameGroupByKey = qbtypes.GroupByKey{
|
|
TelemetryFieldKey: telemetrytypes.TelemetryFieldKey{
|
|
Name: inframonitoringtypes.DaemonSetNameAttrKey,
|
|
FieldContext: telemetrytypes.FieldContextResource,
|
|
FieldDataType: telemetrytypes.FieldDataTypeString,
|
|
},
|
|
}
|
|
|
|
// daemonSetsTableMetricNamesList drives the existence/retention check.
|
|
// Includes k8s.pod.phase even though phase isn't part of the QB composite query —
|
|
// it is queried separately via getPerGroupPodPhaseCounts, and we want the
|
|
// response to short-circuit cleanly when the phase metric is absent.
|
|
var daemonSetsTableMetricNamesList = []string{
|
|
"k8s.pod.phase",
|
|
"k8s.pod.cpu.usage",
|
|
"k8s.pod.cpu_request_utilization",
|
|
"k8s.pod.cpu_limit_utilization",
|
|
"k8s.pod.memory.working_set",
|
|
"k8s.pod.memory_request_utilization",
|
|
"k8s.pod.memory_limit_utilization",
|
|
"k8s.daemonset.desired_scheduled_nodes",
|
|
"k8s.daemonset.current_scheduled_nodes",
|
|
}
|
|
|
|
// Carried forward from v1 daemonSetAttrsToEnrich
|
|
// (pkg/query-service/app/inframetrics/daemonsets.go:29-33).
|
|
var daemonSetAttrKeysForMetadata = []string{
|
|
"k8s.daemonset.name",
|
|
"k8s.namespace.name",
|
|
"k8s.cluster.name",
|
|
}
|
|
|
|
// orderByToDaemonSetsQueryNames maps the orderBy column to the query name
|
|
// used for ranking daemonset groups. v2 B/C/E/F are direct metrics, no
|
|
// formula deps — so unlike v1 we don't carry A/D.
|
|
var orderByToDaemonSetsQueryNames = map[string][]string{
|
|
inframonitoringtypes.DaemonSetsOrderByCPU: {"A"},
|
|
inframonitoringtypes.DaemonSetsOrderByCPURequest: {"B"},
|
|
inframonitoringtypes.DaemonSetsOrderByCPULimit: {"C"},
|
|
inframonitoringtypes.DaemonSetsOrderByMemory: {"D"},
|
|
inframonitoringtypes.DaemonSetsOrderByMemoryRequest: {"E"},
|
|
inframonitoringtypes.DaemonSetsOrderByMemoryLimit: {"F"},
|
|
inframonitoringtypes.DaemonSetsOrderByDesiredNodes: {"H"},
|
|
inframonitoringtypes.DaemonSetsOrderByCurrentNodes: {"I"},
|
|
}
|
|
|
|
// newDaemonSetsTableListQuery builds the composite QB v5 request for the daemonsets list.
|
|
// Eight builder queries: A..F roll up pod-level metrics by daemonset, H/I take the
|
|
// latest daemonset-level desired/current scheduled-node counts. Restarts (v1 query G)
|
|
// is intentionally omitted to match the v2 pods/deployments/statefulsets/jobs pattern.
|
|
//
|
|
// Every builder query carries the base filter `daemonSetsBaseFilterExpr`. Reason:
|
|
// pod-level metrics (A..F) are emitted for every pod regardless of whether the
|
|
// pod belongs to a DaemonSet; only DaemonSet-owned pods carry the
|
|
// `k8s.daemonset.name` resource attribute. Without this filter, standalone pods
|
|
// and pods owned by other workloads (Deployment/StatefulSet/Job/...) collapse into
|
|
// a single empty-string group under the default groupBy. v1's GetDaemonSetList
|
|
// applied the same filter via FilterOperatorExists.
|
|
func (m *module) newDaemonSetsTableListQuery() *qbtypes.QueryRangeRequest {
|
|
queries := []qbtypes.QueryEnvelope{
|
|
// Query A: k8s.pod.cpu.usage — sum of pod CPU within the group.
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "A",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "k8s.pod.cpu.usage",
|
|
TimeAggregation: metrictypes.TimeAggregationAvg,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
Filter: &qbtypes.Filter{Expression: daemonSetsBaseFilterExpr},
|
|
GroupBy: []qbtypes.GroupByKey{daemonSetNameGroupByKey},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query B: k8s.pod.cpu_request_utilization — avg across pods in the group.
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "B",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "k8s.pod.cpu_request_utilization",
|
|
TimeAggregation: metrictypes.TimeAggregationAvg,
|
|
SpaceAggregation: metrictypes.SpaceAggregationAvg,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
Filter: &qbtypes.Filter{Expression: daemonSetsBaseFilterExpr},
|
|
GroupBy: []qbtypes.GroupByKey{daemonSetNameGroupByKey},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query C: k8s.pod.cpu_limit_utilization — avg across pods in the group.
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "C",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "k8s.pod.cpu_limit_utilization",
|
|
TimeAggregation: metrictypes.TimeAggregationAvg,
|
|
SpaceAggregation: metrictypes.SpaceAggregationAvg,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
Filter: &qbtypes.Filter{Expression: daemonSetsBaseFilterExpr},
|
|
GroupBy: []qbtypes.GroupByKey{daemonSetNameGroupByKey},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query D: k8s.pod.memory.working_set — sum of pod memory within the group.
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "D",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "k8s.pod.memory.working_set",
|
|
TimeAggregation: metrictypes.TimeAggregationAvg,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
Filter: &qbtypes.Filter{Expression: daemonSetsBaseFilterExpr},
|
|
GroupBy: []qbtypes.GroupByKey{daemonSetNameGroupByKey},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query E: k8s.pod.memory_request_utilization — avg across pods in the group.
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "E",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "k8s.pod.memory_request_utilization",
|
|
TimeAggregation: metrictypes.TimeAggregationAvg,
|
|
SpaceAggregation: metrictypes.SpaceAggregationAvg,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
Filter: &qbtypes.Filter{Expression: daemonSetsBaseFilterExpr},
|
|
GroupBy: []qbtypes.GroupByKey{daemonSetNameGroupByKey},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query F: k8s.pod.memory_limit_utilization — avg across pods in the group.
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "F",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "k8s.pod.memory_limit_utilization",
|
|
TimeAggregation: metrictypes.TimeAggregationAvg,
|
|
SpaceAggregation: metrictypes.SpaceAggregationAvg,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
Filter: &qbtypes.Filter{Expression: daemonSetsBaseFilterExpr},
|
|
GroupBy: []qbtypes.GroupByKey{daemonSetNameGroupByKey},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query H: k8s.daemonset.desired_scheduled_nodes — latest known desired node count per group.
|
|
// v1 used TimeAggregationAnyLast (v3) → mapped to TimeAggregationLatest in v5;
|
|
// SpaceAggregationSum + ReduceToLast preserve v1's "latest, summed across the group".
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "H",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "k8s.daemonset.desired_scheduled_nodes",
|
|
TimeAggregation: metrictypes.TimeAggregationLatest,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToLast,
|
|
},
|
|
},
|
|
Filter: &qbtypes.Filter{Expression: daemonSetsBaseFilterExpr},
|
|
GroupBy: []qbtypes.GroupByKey{daemonSetNameGroupByKey},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query I: k8s.daemonset.current_scheduled_nodes — latest known currently scheduled node count per group.
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "I",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "k8s.daemonset.current_scheduled_nodes",
|
|
TimeAggregation: metrictypes.TimeAggregationLatest,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToLast,
|
|
},
|
|
},
|
|
Filter: &qbtypes.Filter{Expression: daemonSetsBaseFilterExpr},
|
|
GroupBy: []qbtypes.GroupByKey{daemonSetNameGroupByKey},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
}
|
|
|
|
return &qbtypes.QueryRangeRequest{
|
|
RequestType: qbtypes.RequestTypeScalar,
|
|
CompositeQuery: qbtypes.CompositeQuery{
|
|
Queries: queries,
|
|
},
|
|
}
|
|
}
|