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]>
267 lines
8.3 KiB
Go
267 lines
8.3 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"
|
|
)
|
|
|
|
// Helper group-by key used across all queries.
|
|
var hostNameGroupByKey = qbtypes.GroupByKey{
|
|
TelemetryFieldKey: telemetrytypes.TelemetryFieldKey{
|
|
Name: inframonitoringtypes.HostNameAttrKey,
|
|
FieldContext: telemetrytypes.FieldContextResource,
|
|
FieldDataType: telemetrytypes.FieldDataTypeString,
|
|
},
|
|
}
|
|
|
|
var hostsTableMetricNamesList = []string{
|
|
"system.cpu.time",
|
|
"system.memory.usage",
|
|
"system.cpu.load_average.15m",
|
|
"system.filesystem.usage",
|
|
}
|
|
|
|
var hostAttrKeysForMetadata = []string{
|
|
"os.type",
|
|
}
|
|
|
|
// orderByToHostsQueryNames maps the orderBy column to the query/formula names
|
|
// from HostsTableListQuery used for ranking host groups.
|
|
var orderByToHostsQueryNames = map[string][]string{
|
|
inframonitoringtypes.HostsOrderByCPU: {"A", "B", "F1"},
|
|
inframonitoringtypes.HostsOrderByMemory: {"C", "D", "F2"},
|
|
inframonitoringtypes.HostsOrderByWait: {"E", "F", "F3"},
|
|
inframonitoringtypes.HostsOrderByDiskUsage: {"H", "I", "F4"},
|
|
inframonitoringtypes.HostsOrderByLoad15: {"G"},
|
|
}
|
|
|
|
// newListHostsQuery constructs the base QueryRangeRequest with all the queries for the hosts table.
|
|
// This is kept in this file because the queries themselves do not change based on the request parameters
|
|
// only the filters, group bys, and order bys change, which are applied in buildFullQueryRequest.
|
|
func (m *module) newListHostsQuery() *qbtypes.QueryRangeRequest {
|
|
return &qbtypes.QueryRangeRequest{
|
|
RequestType: qbtypes.RequestTypeScalar,
|
|
CompositeQuery: qbtypes.CompositeQuery{
|
|
Queries: []qbtypes.QueryEnvelope{
|
|
// Query A: CPU usage logic (non-idle)
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "A",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "system.cpu.time",
|
|
TimeAggregation: metrictypes.TimeAggregationRate,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
Filter: &qbtypes.Filter{
|
|
Expression: "state != 'idle'",
|
|
},
|
|
GroupBy: []qbtypes.GroupByKey{hostNameGroupByKey},
|
|
Disabled: true,
|
|
},
|
|
},
|
|
// Query B: CPU usage (all states)
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "B",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "system.cpu.time",
|
|
TimeAggregation: metrictypes.TimeAggregationRate,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
GroupBy: []qbtypes.GroupByKey{hostNameGroupByKey},
|
|
Disabled: true,
|
|
},
|
|
},
|
|
// Formula F1: CPU Usage (%)
|
|
{
|
|
Type: qbtypes.QueryTypeFormula,
|
|
Spec: qbtypes.QueryBuilderFormula{
|
|
Name: "F1",
|
|
Expression: "A/B",
|
|
Legend: "CPU Usage (%)",
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query C: Memory usage (state = used)
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "C",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "system.memory.usage",
|
|
TimeAggregation: metrictypes.TimeAggregationAvg,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
Filter: &qbtypes.Filter{
|
|
Expression: "state = 'used'",
|
|
},
|
|
GroupBy: []qbtypes.GroupByKey{hostNameGroupByKey},
|
|
Disabled: true,
|
|
},
|
|
},
|
|
// Query D: Memory usage (all states)
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "D",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "system.memory.usage",
|
|
TimeAggregation: metrictypes.TimeAggregationAvg,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
GroupBy: []qbtypes.GroupByKey{hostNameGroupByKey},
|
|
Disabled: true,
|
|
},
|
|
},
|
|
// Formula F2: Memory Usage (%)
|
|
{
|
|
Type: qbtypes.QueryTypeFormula,
|
|
Spec: qbtypes.QueryBuilderFormula{
|
|
Name: "F2",
|
|
Expression: "C/D",
|
|
Legend: "Memory Usage (%)",
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query E: CPU Wait time (state = wait)
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "E",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "system.cpu.time",
|
|
TimeAggregation: metrictypes.TimeAggregationRate,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
Filter: &qbtypes.Filter{
|
|
Expression: "state = 'wait'",
|
|
},
|
|
GroupBy: []qbtypes.GroupByKey{hostNameGroupByKey},
|
|
Disabled: true,
|
|
},
|
|
},
|
|
// Query F: CPU time (all states)
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "F",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "system.cpu.time",
|
|
TimeAggregation: metrictypes.TimeAggregationRate,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
GroupBy: []qbtypes.GroupByKey{hostNameGroupByKey},
|
|
Disabled: true,
|
|
},
|
|
},
|
|
// Formula F3: CPU Wait Time (%)
|
|
{
|
|
Type: qbtypes.QueryTypeFormula,
|
|
Spec: qbtypes.QueryBuilderFormula{
|
|
Name: "F3",
|
|
Expression: "E/F",
|
|
Legend: "CPU Wait Time (%)",
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query G: Load15
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "G",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Legend: "CPU Load Average (15m)",
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "system.cpu.load_average.15m",
|
|
TimeAggregation: metrictypes.TimeAggregationAvg,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
GroupBy: []qbtypes.GroupByKey{hostNameGroupByKey},
|
|
Disabled: false,
|
|
},
|
|
},
|
|
// Query H: Filesystem Usage (state = used)
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "H",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "system.filesystem.usage",
|
|
TimeAggregation: metrictypes.TimeAggregationAvg,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
Filter: &qbtypes.Filter{
|
|
Expression: "state = 'used'",
|
|
},
|
|
GroupBy: []qbtypes.GroupByKey{hostNameGroupByKey},
|
|
Disabled: true,
|
|
},
|
|
},
|
|
// Query I: Filesystem Usage (all states)
|
|
{
|
|
Type: qbtypes.QueryTypeBuilder,
|
|
Spec: qbtypes.QueryBuilderQuery[qbtypes.MetricAggregation]{
|
|
Name: "I",
|
|
Signal: telemetrytypes.SignalMetrics,
|
|
Aggregations: []qbtypes.MetricAggregation{
|
|
{
|
|
MetricName: "system.filesystem.usage",
|
|
TimeAggregation: metrictypes.TimeAggregationAvg,
|
|
SpaceAggregation: metrictypes.SpaceAggregationSum,
|
|
ReduceTo: qbtypes.ReduceToAvg,
|
|
},
|
|
},
|
|
GroupBy: []qbtypes.GroupByKey{hostNameGroupByKey},
|
|
Disabled: true,
|
|
},
|
|
},
|
|
// Formula F4: Disk Usage (%)
|
|
{
|
|
Type: qbtypes.QueryTypeFormula,
|
|
Spec: qbtypes.QueryBuilderFormula{
|
|
Name: "F4",
|
|
Expression: "H/I",
|
|
Legend: "Disk Usage (%)",
|
|
Disabled: false,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
}
|