Simple Check HTTP followed by an external API Call for Remediation

Hi all,

Total Sensu beginner and equally baffled on how to do even the simplest things…
Already read a ton of documentation but I’m afraid the workflow still eludes me.

For starters I’m trying to have a simple http:80 check and if there’s a down state (sev 1 or 2), launch a one line .sh (i.e located in /sbin), to remediate the issue.
The one line simply invokes a curl that triggers a Jenkins pipeline.

Creating the ‘check’ was simple enough using http-checker with the command: “http-check --url http://somethiing.com:80”.
And… This is where I can’t progress any further, all my tries to create a handler have failed.

Any suggestions will be most helpfull.
Thanks in advance.

Some further information that might facilitate contributions to this thread…

Checker specs:

---
type: CheckConfig
api_version: core/v2
metadata:
  name: Check-Nginx
  namespace: default
  created_by: admin
spec:
  check_hooks: null
  command: http-check --url http://something.coml:80
  env_vars: null
  handlers:
    - restart
  high_flap_threshold: 0
  interval: 10
  low_flap_threshold: 0
  output_metric_format: ''
  output_metric_handlers: null
  pipelines: []
  proxy_entity_name: ''
  publish: false
  round_robin: false
  runtime_assets:
    - sensu/http-checks
  secrets: null
  stdin: false
  subdue: null
  subscriptions:
    - entity:Nginx
  timeout: 0
  ttl: 0

Handler specs

---
type: Handler
api_version: core/v2
metadata:
  name: restart
  namespace: default
  created_by: admin
spec:
  command: restartnginx.sh
  env_vars: null
  filters:
    - watermark
  handlers: null
  runtime_assets:
    - sensu-remediation-handler
  secrets: null
  timeout: 0
  type: pipe

Filter specs

---
type: EventFilter
api_version: core/v2
metadata:
  name: watermark
  namespace: default
  labels:
    sensu.io/managed_by: sensuctl
  created_by: admin
spec:
  action: allow
  expressions:
    - >-
      event.check.occurrences == 2 || (event.is_resolution &&
      event.check.occurrences_watermark >=120)
  runtime_assets: null

Try as I might, Sensu always triggers the handler twice and all I’m really looking for is ‘trigger once on state change’.
TIA.

so i have a couple of suggestions… first off, look at the fatigue filter asset : sensu-go-fatigue-check-filter versions it should be easier than manual filters. second, I would potentially use a hook, and not a handler. Hooks reference - Sensu Docs

1 Like