sensu.sensu_go.filter (0.7.6) — module

Manages Sensu filters

Authors: Paul Arthur (@flowerysong), Aljaz Kosir (@aljazkosir), Miha Plesko (@miha-plesko), Tadej Borovsak (@tadeboro)

preview | supported by XLAB Steampunk

Install collection

Install with ansible-galaxy collection install sensu.sensu_go:==0.7.6


Add to requirements.yml

  collections:
    - name: sensu.sensu_go
      version: 0.7.6

Description

For more information, refer to the Sensu documentation at U(https://docs.sensu.io/sensu-go/latest/reference/filters/)

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a filter
  filter:
    name: filter
    action: deny
    expressions:
      - event.check.interval == 10
      - event.check.occurrences == 1
    runtime_assets: awesomeness
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a production filter
  filter:
    name: filter
    action: allow
    expressions:
      - event.entity.labels['environment'] == 'production'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a filter with JS expression
  filter:
    name: filter
    action: deny
    expressions:
      - "_.reduce(event.check.history, function(memo, h) { return (memo || h.status != 0); })"
    runtime_assets:
      - underscore
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Handling repeated events
  filter:
    name: filter_interval_60_hourly
    action: allow
    expressions:
      - event.check.interval == 60
      - event.check.occurrences == 1 || event.check.occurrences % 60 == 0

Inputs

    
auth:
    description:
    - Authentication parameters. Can define each of them with ENV as well.
    suboptions:
      namespace:
        default: default
        description:
        - RBAC namespace to operate in. If this is not set the value of the SENSU_NAMESPACE
          environment variable will be checked.
        type: str
      password:
        default: P@ssw0rd!
        description:
        - The Sensu user's password. If this is not set the value of the SENSU_PASSWORD
          environment variable will be checked.
        type: str
      url:
        default: http://localhost:8080
        description:
        - Location of the Sensu backend API. If this is not set the value of the SENSU_URL
          environment variable will be checked.
        type: str
      user:
        default: admin
        description:
        - The username to use for connecting to the Sensu API. If this is not set the
          value of the SENSU_USER environment variable will be checked.
        type: str
    type: dict

name:
    description:
    - The Sensu object's name.
    required: true
    type: str

state:
    choices:
    - present
    - absent
    default: present
    description:
    - Target state of the Sensu object.
    type: str

action:
    choices:
    - allow
    - deny
    description:
    - Action to take with the event if the filter expressions match.
    type: str

labels:
    description:
    - Custom metadata fields that can be accessed within Sensu, as key/value pairs.
    type: dict

annotations:
    description:
    - Custom metadata fields with fewer restrictions, as key/value pairs.
    - These are preserved by Sensu but not accessible as tokens or identifiers, and are
      mainly intended for use with external tools.
    type: dict

expressions:
    description:
    - Filter expressions to be compared with event data.
    type: list

runtime_assets:
    description:
    - Assets to be applied to the filter's execution context. JavaScript files in the
      lib directory of the asset will be evaluated.
    type: list

Outputs

object:
  description: object representing Sensu filter
  returned: success
  type: dict