Init Command
The init
command parses the target file or directories for in code annotations describing a service's SLOs,
this will then output, to stdout or file, the generated SLOs definitions specification in either yaml or json.
sloscribe init
Usage​
The init command parses files in the target directory for comments using the @sloth tags
Usage:
sloscribe init [flags]
Flags:
--dirs strings Comma separated list of directories to be parses by the tool (default [/home/jetstack-oluwole/go/src/github.com/slosive/sloscribe])
-f, --file string Target file to parse. example: ./metrics.go
--format strings Output format (yaml,json). (default [yaml])
-h, --help help for init
--lang string Language of the source files. (go) (default "go")
--services strings Comma separated list of service names. These will select the output service specifications returned by the tool.
--specification string The name of the specification the tool should parse the source file for, example: sloth or sloth-k8s. (default "sloth")
--to-file Print the generated specifications to file, under ./slo_definitions.
Global Flags:
--log-level string Only log messages with the given severity or above. One of: [none, debug, info, warn], errors will always be printed (default "info")
By default, the command outputs the generated specification to stdout.
Flags​
--dirs
​
Is the comma separated list of directories the tool will parse to find SLO annotations. If no arguments are passed to the flag, it will default to parse the current working directory.
Example:
sloscribe init --dirs
The --dirs
flag cannot be used together with the --file
flag.
--file
​
Is the name of the target file that the tool will parse for SLO annotations.
Examples:
sloscribe init -f metrics.go
or
cat metrics.go | ./sloscribe init -f -
--format
​
Is the format of the output of the SLO specification, Yaml or JSON are the currently supported formats.
--lang
​
Set the language of the target source code expected by the parser, ie: GoLang.
--services
​
In the case multiple services SLO specifications are found when parsing the target directory, the --services
allows users to specify which services should be outputted.
Example:
sloscribe init --services chatgpt
--to-file
​
Set the tool to parse and output SLO specification to file rather than stdout. The output will be store under the ./slo_definitions
directory.
--specification
​
Set the target specification the tool should parse the source code for.
Available values:
sloth
andsloth-k8s
.
Examples:
sloscribe init -f metrics.go --specification sloth-k8s
The example will tell the tool to parse the source file for sloth-k8s annotations, in this case are the same as sloth annotations, and return sloth specifications in the form of Kubernetes objects, used for the sloth Kubernetes controller.
# Code generated by sloscribe: https://github.com/slosive/sloscribe.
# DO NOT EDIT.
Labels: {}
SLOs:
- Alerting:
Annotations: {}
Labels: {}
Name: ChatGPTAvailability
PageAlert:
Annotations: null
Disable: false
Labels: null
TicketAlert:
Annotations: null
Disable: false
Labels: null
Description: 95% of logins to the chat-gpt app should be successful.
Labels: {}
Name: chat-gpt-availability
Objective: 95
SLI:
Events:
ErrorQuery: sum(rate(tenant_failed_login_operations_total{client="chat-gpt"}[{{.window}}]))
OR on() vector(0)
TotalQuery: sum(rate(tenant_login_operations_total{client="chat-gpt"}[{{.window}}]))
Plugin: null
Raw: null
Service: chatgpt
Version: prometheus/v1