Skip to content
Closed
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
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ check/vulns:
$(call _print_step,Running govulncheck)
$(GO_ENV) govulncheck $(GO_PACKAGES)

.PHONY: generate generate/go generate/govydoc
.PHONY: generate generate/go generate/govydoc generate/jsonschema
## Auto generate files.
generate: generate/go generate/govydoc
generate: generate/go generate/govydoc generate/jsonschema

## Generate Golang code.
generate/go:
Expand All @@ -87,6 +87,11 @@ generate/govydoc:
$(call _print_step,Generating object docs)
$(GO_ENV) go run ./internal/cmd/objectdoc/main.go > ./docs/manifest.json

## Generate JSON Schema files for all OpenSLO objects.
generate/jsonschema:
$(call _print_step,Generating JSON Schema files)
$(GO_ENV) go run ./internal/cmd/jsonschema/main.go ./docs/jsonschema

.PHONY: format format/go
## Format files.
format: format/go
Expand Down
148 changes: 148 additions & 0 deletions docs/jsonschema/v1/alert-condition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://openslo.com/schemas/v1/alert-condition.json",
"$anchor": "AlertCondition",
"$defs": {
"AlertConditionSpec": {
"$anchor": "AlertConditionSpec",
"properties": {
"severity": {
"type": "string",
"description": "Severity is an implementation-defined classification such as \"sev1\" or \"page\"."
},
"condition": {
"$ref": "#/$defs/AlertConditionType",
"description": "Condition defines the burn-rate comparison used to determine whether this alert condition is breaching."
},
"description": {
"type": "string",
"description": "Description summarizes the alert condition."
}
},
"additionalProperties": false,
"type": "object",
"required": [
"severity",
"condition"
],
"description": "AlertConditionSpec defines an alert's severity and burn-rate condition."
},
"AlertConditionType": {
"$anchor": "AlertConditionType",
"properties": {
"kind": {
"type": "string",
"description": "Kind selects the condition calculation.\nOpenSLO defaults Kind to [AlertConditionKindBurnRate].\nThis SDK does not apply that default."
},
"op": {
"type": "string",
"description": "Operator compares the calculated burn rate with Threshold."
},
"threshold": {
"type": "number",
"description": "Threshold sets the numeric burn-rate boundary."
},
"lookbackWindow": {
"$ref": "#/$defs/DurationShorthand",
"description": "LookbackWindow sets the period for burn-rate calculation."
},
"alertAfter": {
"$ref": "#/$defs/DurationShorthand",
"description": "AlertAfter sets how long the burn-rate comparison must remain true before the condition becomes breaching.\nAn [AlertPolicy] controls whether that state triggers an alert.\nOpenSLO treats an omitted value as \"0m\".\nThis SDK leaves it unset."
}
},
"additionalProperties": false,
"type": "object",
"required": [
"kind",
"op",
"threshold",
"lookbackWindow"
],
"description": "AlertConditionType defines a comparison against an SLO's burn rate."
},
"Annotations": {
"additionalProperties": {
"type": "string"
},
"type": "object",
"description": "Annotations maps metadata keys to implementation- or system-specific values."
},
"DurationShorthand": {
"type": "string",
"pattern": "^[0-9]+[mhdwMQY]$",
"description": "A shorthand representation of time duration, e.g. '1m', '10d', '2w'."
},
"Label": {
"oneOf": [
{
"type": "string"
},
{
"items": {
"type": "string"
},
"type": "array"
}
],
"description": "A label value that can be either a single string or an array of strings."
},
"Labels": {
"additionalProperties": {
"$ref": "#/$defs/Label"
},
"type": "object",
"description": "Labels maps each metadata key to a set of values."
},
"Metadata": {
"$anchor": "Metadata",
"properties": {
"name": {
"type": "string",
"description": "Name identifies the object."
},
"displayName": {
"type": "string",
"description": "DisplayName is the object's human-readable name."
},
"labels": {
"$ref": "#/$defs/Labels",
"description": "Labels contains metadata associated with the object."
},
"annotations": {
"$ref": "#/$defs/Annotations",
"description": "Annotations contains implementation- or system-specific metadata."
}
},
"additionalProperties": false,
"type": "object",
"required": [
"name"
],
"description": "Metadata identifies and describes an OpenSLO v1 object."
}
},
"properties": {
"apiVersion": {
"type": "string"
},
"kind": {
"type": "string"
},
"metadata": {
"$ref": "#/$defs/Metadata"
},
"spec": {
"$ref": "#/$defs/AlertConditionSpec"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"apiVersion",
"kind",
"metadata",
"spec"
],
"description": "AlertCondition defines a burn-rate condition for an SLO."
}
104 changes: 104 additions & 0 deletions docs/jsonschema/v1/alert-notification-target.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://openslo.com/schemas/v1/alert-notification-target.json",
"$anchor": "AlertNotificationTarget",
"$defs": {
"AlertNotificationTargetSpec": {
"$anchor": "AlertNotificationTargetSpec",
"properties": {
"description": {
"type": "string",
"description": "Description summarizes the notification target."
},
"target": {
"type": "string",
"description": "Target specifies the notification destination in the format required by the consuming implementation.\nExamples include email, Slack, a webhook, and Opsgenie."
}
},
"additionalProperties": false,
"type": "object",
"required": [
"target"
],
"description": "AlertNotificationTargetSpec defines an implementation-specific notification destination."
},
"Annotations": {
"additionalProperties": {
"type": "string"
},
"type": "object",
"description": "Annotations maps metadata keys to implementation- or system-specific values."
},
"Label": {
"oneOf": [
{
"type": "string"
},
{
"items": {
"type": "string"
},
"type": "array"
}
],
"description": "A label value that can be either a single string or an array of strings."
},
"Labels": {
"additionalProperties": {
"$ref": "#/$defs/Label"
},
"type": "object",
"description": "Labels maps each metadata key to a set of values."
},
"Metadata": {
"$anchor": "Metadata",
"properties": {
"name": {
"type": "string",
"description": "Name identifies the object."
},
"displayName": {
"type": "string",
"description": "DisplayName is the object's human-readable name."
},
"labels": {
"$ref": "#/$defs/Labels",
"description": "Labels contains metadata associated with the object."
},
"annotations": {
"$ref": "#/$defs/Annotations",
"description": "Annotations contains implementation- or system-specific metadata."
}
},
"additionalProperties": false,
"type": "object",
"required": [
"name"
],
"description": "Metadata identifies and describes an OpenSLO v1 object."
}
},
"properties": {
"apiVersion": {
"type": "string"
},
"kind": {
"type": "string"
},
"metadata": {
"$ref": "#/$defs/Metadata"
},
"spec": {
"$ref": "#/$defs/AlertNotificationTargetSpec"
}
},
"additionalProperties": false,
"type": "object",
"required": [
"apiVersion",
"kind",
"metadata",
"spec"
],
"description": "AlertNotificationTarget identifies a destination for SLO alert notifications."
}
Loading