Browse docs
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.

Shell
obi apply -f FILE_OR_DIRECTORY [-f ...] [-R] [--dry-run]

Configuration as code

Export what you have, commit it, and apply it from CI:

Shell
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:

YAML
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

FlagMeaning
-f, --filename PATHA file, a directory, or - for stdin. Repeat it for more.
-R, --recursiveRead directories recursively.
--dry-runShow what would be created or changed without changing anything.