Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/nobl9/nobl9-go

go 1.25.7
go 1.25.8

require (
github.com/BurntSushi/toml v1.6.0
Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.25.7
go 1.25.8

use (
.
Expand Down
10 changes: 10 additions & 0 deletions manifest/v1alpha/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type Spec struct {
AzurePrometheus *AzurePrometheusConfig `json:"azurePrometheus,omitempty"`
Coralogix *CoralogixConfig `json:"coralogix,omitempty"`
Atlas *AtlasConfig `json:"atlas,omitempty"`
Dash0 *Dash0Config `json:"dash0,omitempty"`
HistoricalDataRetrieval *v1alpha.HistoricalDataRetrieval `json:"historicalDataRetrieval,omitempty"`
QueryDelay *v1alpha.QueryDelay `json:"queryDelay,omitempty"`
// Interval, Timeout and Jitter are readonly and cannot be set via API
Expand All @@ -96,6 +97,7 @@ type Environment struct {
IntervalOverride *v1alpha.Interval `json:"intervalOverride,omitempty"`
}

//nolint:gocyclo
func (s Spec) GetType() (v1alpha.DataSourceType, error) {
switch {
case s.Prometheus != nil:
Expand Down Expand Up @@ -156,6 +158,8 @@ func (s Spec) GetType() (v1alpha.DataSourceType, error) {
return v1alpha.Coralogix, nil
case s.Atlas != nil:
return v1alpha.Atlas, nil
case s.Dash0 != nil:
return v1alpha.Dash0, nil
}
return 0, errors.New("unknown agent type")
}
Expand Down Expand Up @@ -301,3 +305,9 @@ type AtlasConfig struct {
SlicStep int `json:"slicStep,omitempty"`
DataReplayURL string `json:"dataReplayUrl"`
}

// Dash0Config represents content of Dash0 Configuration typical for Agent Object.
type Dash0Config struct {
URL string `json:"url"`
Step int `json:"step,omitempty"`
}
27 changes: 27 additions & 0 deletions manifest/v1alpha/agent/examples/dash0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: n9/v1alpha
kind: Agent
metadata:
name: dash0
displayName: Dash0 Agent
project: default
annotations:
area: latency
env: prod
region: us
team: sales
spec:
description: Example Dash0 Agent
releaseChannel: stable
dash0:
url: https://api.eu-west-1.aws.dash0.com/api/prometheus
step: 60
historicalDataRetrieval:
maxDuration:
value: 30
unit: Day
defaultDuration:
value: 15
unit: Day
queryDelay:
value: 1
unit: Second
18 changes: 18 additions & 0 deletions manifest/v1alpha/agent/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ var specValidation = govy.New[Spec](
govy.ForPointer(func(s Spec) *AtlasConfig { return s.Atlas }).
WithName("atlas").
Include(atlasValidation),
govy.ForPointer(func(s Spec) *Dash0Config { return s.Dash0 }).
WithName("dash0").
Include(dash0Validation),
)

var (
Expand Down Expand Up @@ -258,6 +261,16 @@ var (
Required().
Rules(rules.URL(), newHTTPSchemeRule()),
)
dash0Validation = govy.New[Dash0Config](
govy.Transform(func(d Dash0Config) string { return d.URL }, url.Parse).
WithName("url").
Required().
Rules(rules.URL(), newHTTPSchemeRule()),
govy.For(func(d Dash0Config) int { return d.Step }).
WithName("step").
OmitEmpty().
Rules(rules.GTE(15)),
)
prometheusValidation = govy.New[PrometheusConfig](
govy.For(func(p PrometheusConfig) string { return p.URL }).
WithName("url").
Expand Down Expand Up @@ -458,6 +471,11 @@ var exactlyOneDataSourceTypeValidationRule = govy.NewRule(func(spec Spec) error
return err
}
}
if spec.Dash0 != nil {
if err := typesMatch(v1alpha.Dash0); err != nil {
return err
}
}
if onlyType == 0 {
return errors.New("must have exactly one data source type, none were provided")
}
Expand Down
6 changes: 6 additions & 0 deletions manifest/v1alpha/agent/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,12 @@ func validAgentSpec(typ v1alpha.DataSourceType) Spec {
DataReplayURL: "https://replay.atlas.example.com",
},
},
v1alpha.Dash0: {
Dash0: &Dash0Config{
URL: "https://api.eu-west-1.aws.dash0.com/api/prometheus",
Step: 60,
},
},
}

return specs[typ]
Expand Down
4 changes: 4 additions & 0 deletions manifest/v1alpha/data_sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ LogicMonitor
AzurePrometheus
Coralogix
Atlas
Dash0
)*/
type DataSourceType int

Expand Down Expand Up @@ -233,6 +234,7 @@ func GetQueryDelayDefaults() QueryDelayDefaults {
AzurePrometheus: {Value: ptr(0), Unit: Second},
Coralogix: {Value: ptr(0), Unit: Second},
Atlas: {Value: ptr(10), Unit: Minute},
Dash0: {Value: ptr(1), Unit: Minute},
}
}

Expand Down Expand Up @@ -391,6 +393,7 @@ var agentDataRetrievalMaxDuration = map[DataSourceType]HistoricalRetrievalDurati
ThousandEyes: {Value: ptr(30), Unit: HRDDay},
SumoLogic: {Value: ptr(30), Unit: HRDDay},
Atlas: {Value: ptr(730), Unit: HRDDay},
Dash0: {Value: ptr(30), Unit: HRDDay},
}

var directDataRetrievalMaxDuration = map[DataSourceType]HistoricalRetrievalDuration{
Expand All @@ -408,6 +411,7 @@ var directDataRetrievalMaxDuration = map[DataSourceType]HistoricalRetrievalDurat
LogicMonitor: {Value: ptr(30), Unit: HRDDay},
ThousandEyes: {Value: ptr(30), Unit: HRDDay},
SumoLogic: {Value: ptr(30), Unit: HRDDay},
Dash0: {Value: ptr(30), Unit: HRDDay},
}

func GetDataRetrievalMaxDuration(kind manifest.Kind, typ DataSourceType) (HistoricalRetrievalDuration, error) {
Expand Down
7 changes: 6 additions & 1 deletion manifest/v1alpha/data_sources_enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions manifest/v1alpha/direct/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type Spec struct {
Honeycomb *HoneycombConfig `json:"honeycomb,omitempty"`
LogicMonitor *LogicMonitorConfig `json:"logicMonitor,omitempty"`
AzurePrometheus *AzurePrometheusConfig `json:"azurePrometheus,omitempty"`
Dash0 *Dash0Config `json:"dash0,omitempty"`
HistoricalDataRetrieval *v1alpha.HistoricalDataRetrieval `json:"historicalDataRetrieval,omitempty"`
QueryDelay *v1alpha.QueryDelay `json:"queryDelay,omitempty"`
// Interval, Timeout and Jitter are readonly and cannot be set via API
Expand Down Expand Up @@ -96,6 +97,7 @@ var validDirectTypes = map[v1alpha.DataSourceType]struct{}{
v1alpha.Honeycomb: {},
v1alpha.LogicMonitor: {},
v1alpha.AzurePrometheus: {},
v1alpha.Dash0: {},
}

func IsValidDirectType(directType v1alpha.DataSourceType) bool {
Expand Down Expand Up @@ -145,6 +147,8 @@ func (spec Spec) GetType() (v1alpha.DataSourceType, error) {
return v1alpha.LogicMonitor, nil
case spec.AzurePrometheus != nil:
return v1alpha.AzurePrometheus, nil
case spec.Dash0 != nil:
return v1alpha.Dash0, nil
}
return 0, errors.New("BUG: unknown direct type")
}
Expand Down Expand Up @@ -283,3 +287,10 @@ type AzurePrometheusConfig struct {
ClientSecret string `json:"clientSecret"`
Step int `json:"step,omitempty"`
}

// Dash0Config represents content of Dash0 Configuration typical for Direct Object.
type Dash0Config struct {
URL string `json:"url"`
AccessToken string `json:"accessToken"`
Step int `json:"step,omitempty"`
}
28 changes: 28 additions & 0 deletions manifest/v1alpha/direct/examples/dash0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: n9/v1alpha
kind: Direct
metadata:
name: dash0
displayName: Dash0 Direct
project: default
annotations:
area: latency
env: prod
region: us
team: sales
spec:
description: Example Dash0 Direct
releaseChannel: stable
dash0:
url: https://api.eu-west-1.aws.dash0.com/api/prometheus
accessToken: "[secret]"
step: 60
historicalDataRetrieval:
maxDuration:
value: 30
unit: Day
defaultDuration:
value: 15
unit: Day
queryDelay:
value: 1
unit: Second
15 changes: 15 additions & 0 deletions manifest/v1alpha/direct/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ var specValidation = govy.New[Spec](
govy.ForPointer(func(s Spec) *AzurePrometheusConfig { return s.AzurePrometheus }).
WithName("azurePrometheus").
Include(azurePrometheusValidation),
govy.ForPointer(func(s Spec) *Dash0Config { return s.Dash0 }).
WithName("dash0").
Include(dash0Validation),
)

var (
Expand Down Expand Up @@ -223,6 +226,13 @@ var (
Required().
Rules(rules.StringUUID()),
)
dash0Validation = govy.New[Dash0Config](
urlPropertyRules(func(d Dash0Config) string { return d.URL }),
govy.For(func(d Dash0Config) string { return d.AccessToken }).
WithName("accessToken").
HideValue().
Required(),
)
)

const (
Expand Down Expand Up @@ -344,6 +354,11 @@ var exactlyOneDataSourceTypeValidationRule = govy.NewRule(func(spec Spec) error
return err
}
}
if spec.Dash0 != nil {
if err := typesMatch(v1alpha.Dash0); err != nil {
return err
}
}
if onlyType == 0 {
return errors.New("must have exactly one data source type, none were provided")
}
Expand Down
6 changes: 6 additions & 0 deletions manifest/v1alpha/direct/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,12 @@ func validDirectSpec(typ v1alpha.DataSourceType) Spec {
ClientSecret: "secret",
},
},
v1alpha.Dash0: {
Dash0: &Dash0Config{
URL: "https://api.eu-west-1.aws.dash0.com/api/prometheus",
AccessToken: "secret",
},
},
}

return specs[typ]
Expand Down
6 changes: 6 additions & 0 deletions manifest/v1alpha/examples/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func (a agentExample) Generate() v1alphaAgent.Agent {
return agent
}

//nolint:gocyclo
func (a agentExample) generateVariant(agent v1alphaAgent.Agent) v1alphaAgent.Agent {
switch a.typ {
case v1alpha.AmazonPrometheus:
Expand Down Expand Up @@ -202,6 +203,11 @@ func (a agentExample) generateVariant(agent v1alphaAgent.Agent) v1alphaAgent.Age
SlicStep: 60,
DataReplayURL: "https://replay.atlas.atlas",
}
case v1alpha.Dash0:
agent.Spec.Dash0 = &v1alphaAgent.Dash0Config{
URL: "https://api.eu-west-1.aws.dash0.com/api/prometheus",
Step: 60,
}
default:
panic(fmt.Sprintf("unexpected v1alpha.DataSourceType: %#v", a.typ))
}
Expand Down
6 changes: 6 additions & 0 deletions manifest/v1alpha/examples/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ func (d directExample) generateVariant(direct v1alphaDirect.Direct) v1alphaDirec
ClientSecret: "[secret]",
Step: 60,
}
case v1alpha.Dash0:
direct.Spec.Dash0 = &v1alphaDirect.Dash0Config{
URL: "https://api.eu-west-1.aws.dash0.com/api/prometheus",
AccessToken: "[secret]",
Step: 60,
}
default:
panic(fmt.Sprintf("unexpected v1alpha.DataSourceType: %#v", d.typ))
}
Expand Down
4 changes: 4 additions & 0 deletions manifest/v1alpha/examples/slo.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ var customMetricExamples = map[v1alpha.DataSourceType]map[metricVariant][]metric
metricVariantThreshold: []metricSubVariant{},
metricVariantSingleQueryGoodRatio: []metricSubVariant{},
},
v1alpha.Dash0: {
metricVariantThreshold: []metricSubVariant{},
metricVariantGoodRatio: []metricSubVariant{},
},
}

var goodOverTotalVariants = []string{
Expand Down
15 changes: 15 additions & 0 deletions manifest/v1alpha/examples/slo_variants.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,19 @@ func (s sloExample) generateMetricVariant(slo v1alphaSLO.SLO) v1alphaSLO.SLO {
},
}))
}
case v1alpha.Dash0:
switch s.MetricVariant {
case metricVariantThreshold:
return setThresholdMetric(slo, newMetricSpec(v1alphaSLO.Dash0Metric{
PromQL: ptr(`sum(rate(http_requests_total[5m]))`),
}))
case metricVariantGoodRatio:
return setGoodOverTotalMetric(slo, newMetricSpec(v1alphaSLO.Dash0Metric{
PromQL: ptr(`sum(rate(http_requests_total{status=~"2.."}[5m]))`),
}), newMetricSpec(v1alphaSLO.Dash0Metric{
PromQL: ptr(`sum(rate(http_requests_total[5m]))`),
}))
}
default:
panic(fmt.Sprintf("unsupported data source type: %s", s.DataSourceType))
}
Expand Down Expand Up @@ -1224,6 +1237,8 @@ func newMetricSpec(metric any) *v1alphaSLO.MetricSpec {
spec.Coralogix = &v
case v1alphaSLO.AtlasMetric:
spec.Atlas = &v
case v1alphaSLO.Dash0Metric:
spec.Dash0 = &v
default:
panic(fmt.Sprintf("unsupported metric type: %T", metric))
}
Expand Down
Loading
Loading