Skip to content

Commit

Permalink
PC-10133: Move SLO into separate package (#141)
Browse files Browse the repository at this point in the history
* add validation poc

* further refine the validation example

* current progress

* simplify rule logic

* remove v1alpha aliases

* add errors tests

* add rules tests

* add strings tests

* make sure labels testing is deterministic

* invert dependency between project and v1alpha

* facilitate recent suggestions and feedback

* rename object validation to struct

* fix error handling

* change labels validation rule name

* let compiler infer the type

* declare the function once

* move service to separate pkg

* extract common validation

* use common validators

* revert changes

* move replya away

* come up with extended API for validaiton

* remove unneccessary level

* refactor naming to match fluent

* move replay

* extend tests coverage

* move sli analysis away for time being

* fix replya status through redefinition

* fix prepending name solution

* current progress

* split validator

* basic metadata validation

* correct expected metadata test result

* correct example

* add budgeting method validation

* post merge fixes

* introduce foreach validation

* test spec.service and spec.alertPolicies

* adjust for each errors

* add url validation

* validate attachments

* add oneof validation

* validate composite

* add extended length rules

* add unique rule and finish up anomaly config testing

* add time window validation

* add basic indicator validation

* add new instructions around required and omitempty

* current progress

* refactor errors handling

* correct tests

* fix linter

* finish up with general metric spec validation

* kinda finish appdynamics

* corrrect appd validation

* current lighstep progress

* lighstep finish up

* finish up lighstep validation

* init pingdom work

* add pingdom validation

* add sumologic rules

* add sumologic tests

* finish sumologic testing

* add thousand eyes validation

* finish AzureMonitor validation

* bring back bad/good validation

* finish instana validation

* add redshift validation

* add bigquery validation

* add cloudwatch validation

* extract the rest of metrics

* add prometheuses and datadog

* add dynatrace, elastic, gcm, graphite and influx

* add loki, newrelic, opentsdb, splunkobs

* post merge addons

* fix linter

* remove old validator from slo pkg

* rename big query file

* brin back aws account id

* move time window

* add helper functions for value and target

* add tests recording capabilities

* add ability to record tests

* use octalliteral

* fix gosec

* improve recorded code

* make accountId optional for cloudwatch

* cr suggestions

* apply cr suggestions

* fix pingdom required validation and record golden paths

* add record target

* post merge fix

* cr suggestions

* fix newline handling for values

* fix expresion typo

* c8a7ec3 commit changes

* migrate honeycomb and improve datasources handling

* fix typo

* fix yarn version
  • Loading branch information
nieomylnieja authored Nov 20, 2023
1 parent 72441f4 commit f032fd3
Show file tree
Hide file tree
Showing 85 changed files with 8,579 additions and 4,224 deletions.
6 changes: 0 additions & 6 deletions manifest/v1alpha/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,3 @@ type GenericAgentConfig struct {
type HoneycombAgentConfig struct {
// Honeycomb agent doesn't require any additional parameters.
}

// AgentWithSLOs struct which mapped one to one with kind: agent and slo yaml definition
type AgentWithSLOs struct {
Agent Agent `json:"agent"`
SLOs []SLO `json:"slos"`
}
6 changes: 0 additions & 6 deletions manifest/v1alpha/alert_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,3 @@ type AlertCondition struct {
LastsForDuration string `json:"lastsFor,omitempty" validate:"omitempty,validDuration,nonNegativeDuration" example:"15m"` //nolint:lll
Operator string `json:"op,omitempty" validate:"omitempty,operator" example:"lt"`
}

// AlertPolicyWithSLOs struct which mapped one to one with kind: alert policy and slo yaml definition
type AlertPolicyWithSLOs struct {
AlertPolicy AlertPolicy `json:"alertPolicy"`
SLOs []SLO `json:"slos"`
}
96 changes: 32 additions & 64 deletions manifest/v1alpha/data_sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,42 @@ import (
"github.com/nobl9/nobl9-go/manifest"
)

type DataSourceType int
//go:generate ../../bin/go-enum --values --noprefix

// DataSourceType represents the type of data source, either Agent or Direct.
//
// Beware that order of these constants is very important
// existing integrations are saved in db with type = DataSourceType.
// New integrations always have to be added as last item in this list to get new "type id".
const (
Prometheus DataSourceType = iota + 1
Datadog
NewRelic
AppDynamics
Splunk
Lightstep
SplunkObservability
Dynatrace
ThousandEyes
Graphite
BigQuery
Elasticsearch
OpenTSDB
GrafanaLoki
CloudWatch
Pingdom
AmazonPrometheus
Redshift
SumoLogic
Instana
InfluxDB
GCM
AzureMonitor
Generic
Honeycomb
)
//
/* ENUM(
Prometheus = 1
Datadog
NewRelic
AppDynamics
Splunk
Lightstep
SplunkObservability
Dynatrace
ThousandEyes
Graphite
BigQuery
Elasticsearch
OpenTSDB
GrafanaLoki
CloudWatch
Pingdom
AmazonPrometheus
Redshift
SumoLogic
Instana
InfluxDB
GCM
AzureMonitor
Generic
Honeycomb
)*/
type DataSourceType int

const DatasourceStableChannel = "stable"

Expand Down Expand Up @@ -102,42 +106,6 @@ func IsValidSourceOf(sourceOf string) bool {
return ok
}

var agentTypeToName = map[DataSourceType]string{
Prometheus: "Prometheus",
Datadog: "Datadog",
NewRelic: "NewRelic",
AppDynamics: "AppDynamics",
Splunk: "Splunk",
Lightstep: "Lightstep",
SplunkObservability: "SplunkObservability",
Dynatrace: "Dynatrace",
Elasticsearch: "Elasticsearch",
ThousandEyes: "ThousandEyes",
Graphite: "Graphite",
BigQuery: "BigQuery",
OpenTSDB: "OpenTSDB",
GrafanaLoki: "GrafanaLoki",
CloudWatch: "CloudWatch",
Pingdom: "Pingdom",
AmazonPrometheus: "AmazonPrometheus",
Redshift: "Redshift",
SumoLogic: "SumoLogic",
Instana: "Instana",
InfluxDB: "InfluxDB",
GCM: "GoogleCloudMonitoring",
AzureMonitor: "AzureMonitor",
Generic: "Generic",
Honeycomb: "Honeycomb",
}

func (dst DataSourceType) String() string {
if key, ok := agentTypeToName[dst]; ok {
return key
}
//nolint: goconst
return "Unknown"
}

// HistoricalRetrievalDuration struct was previously called Duration. However, this name was too generic
// since we also needed to introduce a Duration struct for QueryDelay, which allowed for different time units.
// Time travel is allowed for days/hours/minutes, and query delay can be set to minutes/seconds. Separating those two
Expand Down
180 changes: 180 additions & 0 deletions manifest/v1alpha/data_sources_enum.go

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

6 changes: 0 additions & 6 deletions manifest/v1alpha/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,6 @@ type PublicHoneycombDirectConfig struct {
HiddenAPIKey string `json:"apiKey,omitempty"`
}

// PublicDirectWithSLOs struct which mapped one to one with kind: direct and slo yaml definition
type PublicDirectWithSLOs struct {
Direct PublicDirect `json:"direct"`
SLOs []SLO `json:"slos"`
}

// AWSIAMRoleAuthExternalIDs struct which is used for exposing AWS IAM role auth data
type AWSIAMRoleAuthExternalIDs struct {
ExternalID string `json:"externalID"`
Expand Down
Loading

0 comments on commit f032fd3

Please sign in to comment.