Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/cli. OpenStatus CLI www.openstatus.dev
cli cli-app synthetic-monitoring
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200package config
type Monitor struct { // Name of the monitor Name string `json:"name" ,yaml:"name"` Description string `json:"description,omitempty" ,yaml:"description,omitempty"` Frequency Frequency `json:"frequency" ,yaml:"frequency"` // Regions to run the request in Regions []Region `json:"regions" ,yaml:"regions"` // Whether the monitor is active Active bool `json:"active"` Kind CoordinateKind `json:"kind" ,yaml:"kind"` // Number of retries to attempt Retry int64 `json:"retry,omitempty" ,yaml:"retry,omitempty"` // Whether the monitor is public Public bool `json:"public,omitempty" ,yaml:"public,omitempty"` // The HTTP Request we are sending Request Request `json:"request" ,yaml:"request"` // Time in milliseconds to wait before marking the request as degraded DegradedAfter int64 `json:"degradedAfter,omitempty" ,yaml:"degradedAfter,omitempty"` // Time in milliseconds to wait before marking the request as timed out Timeout int64 `json:"timeout,omitempty" ,yaml:"timeout,omitempty"` // Assertions to run on the response Assertions []Assertion `json:"assertions,omitempty" ,yaml:"assertions,omitempty"` // OpenTelemetry configuration OpenTelemetry OpenTelemetryConfig `json:"openTelemetry,omitempty" ,yaml:"openTelemetry,omitempty"`}
type Assertion struct { // Comparison operator Compare Compare `json:"compare" ,yaml:"compare"` Kind AssertionKind `json:"kind" ,yaml:"kind"` // Status code to assert // // Header value to assert // // Text body to assert Target any `json:"target" ,yaml:"target"` // Header key to assert Key string `json:"key,omitempty" ,yaml:"key,omitempty"`}
// The HTTP Request we are sendingtype Request struct { // Body to send with the request Body string `json:"body,omitempty" ,yaml:"body,omitempty"` Headers map[string]string `json:"headers,omitempty" ,yaml:"headers,omitempty"` Method Method `json:"method,omitempty" ,yaml:"method,omitempty"` // URL to request URL string `json:"url,omitempty" ,yaml:"url,omitempty"` // Whether to follow HTTP redirects (defaults to true when not specified) FollowRedirects *bool `json:"followRedirects,omitempty" ,yaml:"followRedirects,omitempty"` // Host to connect to Host string `json:"host,omitempty" ,yaml:"host,omitempty"` // Port to connect to Port int64 `json:"port,omitempty" ,yaml:"port,omitempty"`}
type OpenTelemetryConfig struct { Endpoint string `json:"endpoint,omitempty" ,yaml:"endpoint,omitempty"` Headers map[string]string `json:"headers,omitempty" ,yaml:"headers,omitempty"`}
// Comparison operatortype Compare string
const ( Contains Compare = "contains" Empty Compare = "empty" Eq Compare = "eq" Gt Compare = "gt" Gte Compare = "gte" LTE Compare = "lte" Lt Compare = "lt" NotContains Compare = "not_contains" NotEmpty Compare = "not_empty" NotEq Compare = "not_eq")
type AssertionKind string
const ( Header AssertionKind = "header" StatusCode AssertionKind = "statusCode" TextBody AssertionKind = "textBody")
type Frequency string
const ( The10M Frequency = "10m" The1H Frequency = "1h" The1M Frequency = "1m" The30M Frequency = "30m" The30S Frequency = "30s" The5M Frequency = "5m")
type CoordinateKind string
const ( HTTP CoordinateKind = "http" TCP CoordinateKind = "tcp" ICMP CoordinateKind = "icmp")
type Region string
const ( Ams Region = "ams" Arn Region = "arn" Atl Region = "atl" BOM Region = "bom" Bog Region = "bog" Bos Region = "bos" Cdg Region = "cdg" Den Region = "den" Dfw Region = "dfw" Ewr Region = "ewr" Eze Region = "eze" Fra Region = "fra" Gdl Region = "gdl" Gig Region = "gig" Gru Region = "gru" Hkg Region = "hkg" Iad Region = "iad" Jnb Region = "jnb" Lax Region = "lax" Lhr Region = "lhr" Mad Region = "mad" Mia Region = "mia" Nrt Region = "nrt" Ord Region = "ord" Otp Region = "otp" Phx Region = "phx" Private Region = "private" Qro Region = "qro" Scl Region = "scl" Sea Region = "sea" Sin Region = "sin" Sjc Region = "sjc" Syd Region = "syd" Waw Region = "waw" Yul Region = "yul" Yyz Region = "yyz" // Koyeb regions (disambiguated from Fly.io regions with same airport code) KoyebFra Region = "koyeb_fra" KoyebPar Region = "koyeb_par" KoyebSfo Region = "koyeb_sfo" KoyebSin Region = "koyeb_sin" KoyebTyo Region = "koyeb_tyo" KoyebWas Region = "koyeb_was" // Railway regions RailwayUsWest2 Region = "railway_us-west2" RailwayUsEast4 Region = "railway_us-east4-eqdc4a" RailwayEuropeWest4 Region = "railway_europe-west4-drams3a" RailwayAsiaSoutheast1 Region = "railway_asia-southeast1-eqsg3a")
type Method string
const ( Delete Method = "DELETE" Get Method = "GET" Head Method = "HEAD" Options Method = "OPTIONS" Patch Method = "PATCH" Post Method = "POST" Put Method = "PUT")
type Target struct { Int *int64 String *string}
// ConvertAssertionTargets safely converts assertion targets to the appropriate types// based on the assertion kind. This prevents panics from unsafe type assertions.func ConvertAssertionTargets(assertions []Assertion) { for i := range assertions { assertion := &assertions[i] switch assertion.Kind { case Header, TextBody: if s, ok := assertion.Target.(string); ok { assertion.Target = s } case StatusCode: // YAML may parse integers as int, int64, or float64 switch v := assertion.Target.(type) { case int: assertion.Target = v case int64: assertion.Target = int(v) case float64: assertion.Target = int(v) } } }}