On this page
obi apply
Create or update resources from YAML or JSON manifest files, for configuration kept in version control.
obi apply creates or updates resources from manifest files. An object that
already exists with the manifest's name is updated, and the rest are created.
obi apply -f FILE_OR_DIRECTORY [-f ...] [-R] [--dry-run]
Configuration as code
Export what you have, commit it, and apply it from CI:
obi get alerts,dashboards --export > observability.yaml
obi apply -f observability.yaml --dry-run
obi apply -f observability.yaml
obi apply -f ./observability/ -R # every file in a directory tree
cat alert.yaml | obi apply -f - # from stdin
If any document fails, obi apply names the file it came from and exits with a
non-zero status, so a CI job fails.
Manifests
Files may be YAML, with several documents separated by ---, or JSON. A
manifest names its kind and object, and holds the settings under spec:
apiVersion: obistack.com/v1
kind: AlertRule
metadata:
name: payments-errors
spec:
query: level:error service:payments
conditionType: log_volume
conditionOperator: ">"
conditionThreshold: 50
windowSeconds: 300
obi get TYPE NAME --export prints any object in this form. Exports leave out
fields the server sets (ids, timestamps, current state), so a file you export
applies cleanly back. A resource that belongs to another names its parent in
metadata, for example metadata.alert for a silence.
Dashboards use the Perses document format. A
dashboard file from the console's Code tab or from percli applies as-is, and
every apply is saved as a dashboard revision you can roll back to with
obi rollback dashboard NAME --to-revision N.
Flags
| Flag | Meaning |
|---|---|
-f, --filename PATH | A file, a directory, or - for stdin. Repeat it for more. |
-R, --recursive | Read directories recursively. |
--dry-run | Show what would be created or changed without changing anything. |