Git Product home page Git Product logo

sensu-dependencies-filter's Introduction

Core Dependencies Filter

Overview

This Sensu Go filter looks for dependencies defined in check and entity annotations and invokes the sensu.CheckDependencies query expression to determine if any of the defined dependecies are in a non-OK state.

coreDependencies

The coreDependencies function implemented by this library is intended as proof-of-concept reproduction of the Sensu Core dependencies filter.

In Sensu Core the dependencies were expressed as an array. For this implementation I've chosen to use comma separated values.

Example: check dependencies

Given you have a check called https-health which monitors your website's /health endpoint, you want to suppress alerts from the https-cert check when https-health is in a non-OK state:

type: CheckConfig
api_version: core/v2
metadata:
  name: https-cert
  annotations:
    dependencies: https-health
spec:
  command: check-https-cert.rb --url https://www.example.com
  handlers:
  - pagerduty
  interval: 60
  subscriptions:
  - website

Provided that the pagerduty handler has been configured as shown below in Usage examples, the dependencies annotation with the value https-health will prevent alerts from https-cert from reaching pagerduty when https-health is not OK.

Example: entity dependencies

Given you have an agent running in a remote site with unreliable network link. Sometimes the ethernet cable falls out of port 5 on the switch, other times the ISP link fails. And yet you soldier on. It's fine.

You want to suppress alerts from any check this agent runs when either a. the remote-site-link is in a non-OK state b. the state of check port5 on entity remote-switch is in a non-OK state (entity/check syntax)

For an agent entity, you can set this in the agent.yml annotations:

# agent.yml
annotations:
  dependencies: remote-site-link,remote-switch/port5

Or whatever method as appropriate for the entity type or your Sensu version.

Usage examples

Asset Registration

sensuctl asset add sensu/sensu-dependencies-filter -r dependencies-filter

Filter definition

Define an event filter using the coreDependencies function. This function requires the event object as its only argument.

---
type: EventFilter
api_version: core/v2
metadata:
  name: dependencies
  namespace: default
spec:
  action: allow
  expressions:
  - coreDependencies(event)
  runtime_assets:
  - dependencies-filter

Handler definition

Add the filter to any of your existing handlers. Here's a Pagerduty handler with the above event filter applied:

---
type: Handler
api_version: core/v2
metadata:
  name: pagerduty
  namespace: default
spec:
  type: pipe
  command: sensu-pagerduty-handler
  timeout: 10
  runtime_assets:
  - sensu-pagerduty-handler
  filters:
  - dependencies-filter

Acknowledgements

Inspired by Sensu Core dependencies filter extension.

sensu-dependencies-filter's People

Contributors

agoddard avatar jspaleta avatar

Stargazers

Matt Mercer avatar

Watchers

 avatar James Phillips avatar Troy Howard avatar James Cloos avatar Francis Guimond avatar Eric Chlebek avatar Michael Gibson avatar Gustav Danielsson avatar Hillary Fraley avatar  avatar Justin Henderson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.