Skip to content

YAML formatting tool, useful for Prometheus rule formatting

License

Notifications You must be signed in to change notification settings

devopyio/yamlfmt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yamlfmt

Build Status yamlfmt

Get it from the Snap Store

Formats yaml files.

Install

Linux:

sudo snap install yamlfmt

Brew

brew install devopyio/yamlfmt/yamlfmt

Windows

scoop bucket add yamlfmt https://github.com/devopyio/scoop-yamlfmt
scoop install yamlfmt

Using go get

go get -u github.com/devopyio/yamlfmt

Usage

cat example.yaml | yamlfmt

Or you can simply execute:

yamlfmt -filename example.yaml

Example:

"groups": 
- "name": "etcd"
  "rules": 
  - "alert": "EtcdInsufficientMembers"
    "annotations": 
      "message": "Etcd cluster \"{{ $labels.job }}\": insufficient members ({{ $value }})."
    "expr": |
      count(up{job="etcd"} == 0) by (job) > (count(up{job="etcd"}) by (job) / 2 - 1)
    "for": "3m"
    "labels": 
      "severity": "critical"

Becomes:

groups:
- name: etcd
  rules:
  - alert: EtcdInsufficientMembers
    annotations:
      message: 'Etcd cluster "{{ $labels.job }}": insufficient members ({{ $value
        }}).'
    expr: |
      count(up{job="etcd"} == 0) by (job) > (count(up{job="etcd"}) by (job) / 2 - 1)
    for: 3m
    labels:
      severity: critical