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]>
136 lines
4.9 KiB
Go
136 lines
4.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"
|
|
)
|
|
|
|
var clusterNameGroupByKey = qbtypes.GroupByKey{
|
|
TelemetryFieldKey: telemetrytypes.TelemetryFieldKey{
|
|
Name: inframonitoringtypes.ClusterNameAttrKey,
|
|
FieldContext: telemetrytypes.FieldContextResource,
|
|
FieldDataType: telemetrytypes.FieldDataTypeString,
|
|
},
|
|
}
|
|
|
|
// clustersTableMetricNamesList drives the existence/retention check.
|
|
// Includes k8s.node.condition_ready and k8s.pod.phase so the response
|
|
// short-circuits cleanly when a cluster doesn't ship those metrics — even
|
|
// though they aren't part of the QB composite query (they're queried separately
|
|
// via getPerGroupNodeConditionCounts and getPerGroupPodPhaseCounts).
|
|
var clustersTableMetricNamesList = []string{
|
|
"k8s.node.cpu.usage",
|
|
"k8s.node.allocatable_cpu",
|
|
"k8s.node.memory.working_set",
|
|
"k8s.node.allocatable_memory",
|
|
"k8s.node.condition_ready", //TODO(nikhilmantri0902): should these metrics be used to count groups k8s.node.condition_ready and k8s.pod.phase
|
|
"k8s.pod.phase",
|
|
}
|
|
|
|
var clusterAttrKeysForMetadata = []string{
|
|
"k8s.cluster.name",
|
|
}
|
|
|
|
var orderByToClustersQueryNames = map[string][]string{
|
|
inframonitoringtypes.ClustersOrderByCPU: {"A"},
|
|
inframonitoringtypes.ClustersOrderByCPUAllocatable: {"B"},
|
|
inframonitoringtypes.ClustersOrderByMemory: {"C"},
|
|
inframonitoringtypes.ClustersOrderByMemoryAllocatable: {"D"},
|
|
}
|
|
|
|
// newClustersTableListQuery builds the composite QB v5 request for the clusters list.
|
|
// Cluster-scope metrics are derived by summing per-node metrics within the
|
|
// group (default group: k8s.cluster.name). Node condition counts and pod phase
|
|
// counts are derived separately via getPerGroupNodeConditionCounts and
|
|
// getPerGroupPodPhaseCounts respectively (works for both list and grouped_list
|
|
// modes), so neither is included here. Query letters A/B/C/D mirror the v1
|
|
// implementation and the v2 nodes list.
|
|
func (m *module) newClustersTableListQuery() *qbtypes.QueryRangeRequest {
|
|
queries := []qbtypes.QueryEnvelope{
|
|
// Query A: CPU usage — sum of node CPU within the group.
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "A",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "k8s.node.cpu.usage",
|
|
TimeAggregation: metrictypes.TimeAggregationAvg,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
GroupBy: []qbtypes.GroupByKey{clusterNameGroupByKey},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query B: CPU allocatable — sum of node allocatable CPU within the group.
|
|
// TimeAggregationLatest is the closest v5 equivalent of v1's AnyLast;
|
|
// allocatable values change rarely so divergence in practice is negligible.
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "B",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "k8s.node.allocatable_cpu",
|
|
TimeAggregation: metrictypes.TimeAggregationLatest,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
GroupBy: []qbtypes.GroupByKey{clusterNameGroupByKey},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query C: Memory working set — sum of node memory within the group.
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "C",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "k8s.node.memory.working_set",
|
|
TimeAggregation: metrictypes.TimeAggregationAvg,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
GroupBy: []qbtypes.GroupByKey{clusterNameGroupByKey},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query D: Memory allocatable — sum of node allocatable memory within the group.
|
|
// Same Latest caveat as Query B.
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "D",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "k8s.node.allocatable_memory",
|
|
TimeAggregation: metrictypes.TimeAggregationLatest,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
GroupBy: []qbtypes.GroupByKey{clusterNameGroupByKey},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
}
|
|
|
|
return &qbtypes.QueryRangeRequest{
|
|
RequestType: qbtypes.RequestTypeScalar,
|
|
CompositeQuery: qbtypes.CompositeQuery{
|
|
Queries: queries,
|
|
},
|
|
}
|
|
}
|