Organizing your code

You are free to organize your code any way you see fit. We recurse the directory tree and merge any YAML files into a single configuration. As such, we recommend using a skeleton main.yaml and merging in your policies and targets.

The resulting directory tree should be something like this:

tacdog/
├── main.yaml
├── policy.yaml
└── targets
    ├── www.freetheyaks.org.yaml
    ├── api.freetheyaks.org.yaml
    └── payments.freetheyaks.org.yaml

Of course, you are free to structure it however you like. Directory names are arbitrary; it is the top-level YAML key in each file that determines where it will be merged.

Your main.yaml should be a skeleton with required parameters:

---
version: '1.0'

policy:  {}
targets: []

and your policy.yaml should contain your policies. An example might be:

policy:
  datadog:
    critical:    { alert_type: error,   priority: normal }
    error:       { alert_type: error,   priority: normal }
    warning:     { alert_type: warning, priority: normal }
    notice:      { alert_type: info,    priority: normal }
    success:     { alert_type: success, priority: normal }
    performance: { alert_type: warning, priority: normal, tags: [ team:devops ] }

  pagerduty:
    critical: { severity: critical }
    error:    { severity: error }
    warning:  { severity: warning }
    notice:   { severity: info }

Each target file should have a top-level key named targets. For example:

#
# www.freetheyaks.org.yaml
#

definitions:
- &user-agent
  Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7

targets:
- name: free_the_yaks
  host: freetheyaks.org
  protocol: https
  headers:
    User-Agent: *user-agent
    Accept: application/json

  checks:
  - name: forms
    tags: [ forms ]
    interval: 60s
    rules:
    - if:
      - after: 2s
        event: { policy: critical }
      - after: 1s
        event: { policy: performance, abort: false }

    session:
    - name: home_page
      path: /index.html
      method: get
      timeout: 5s
      redirects: 5
      rules:
      - if:
        - after: 1s
          event: { policy: critical }
        - after: 0.6s
          event: { policy: performance, abort: false }