Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter Events by JSONPATH #559

Closed
h4wkmoon opened this issue Jan 17, 2022 · 4 comments
Closed

Filter Events by JSONPATH #559

h4wkmoon opened this issue Jan 17, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@h4wkmoon
Copy link

resources:
Hi,
I'm watching my velero backups with botkube. I'd like to have only failures, or partial failures notifications.

I would like to be able to specify a field in the object, by its jsonpath, for example, and the values I want (or do not want) notifications for.

Currently, I can only filter by the CRUD kind of the event. So for a backup, I have CREATE (when the kubernetes object is created), and several updates. Failures and successes are notified the same way.

This would be great also to watch sealedsecret being unsuccessfully unsealed. With a jsonpath filter, in the yaml config file, it would be veeery easy to do great things.

ex for velero:

This would only send notifications for UPDATE event when the field status.phase is not "Completed".

      - name: velero.io/v1/backups
        fields:
        - path: status.phase
          exclude: ["Completed"]
        namespaces:
          include:
            - all
        events:
          - update
        updateSetting:
          includeDiff: true
          fields:
            - status.phase

@h4wkmoon h4wkmoon added the enhancement New feature or request label Jan 17, 2022
@andromedi4
Copy link

I am looking for exactly the same solution. I want to receive messages only if the backup status is not "Completed".
Is there any news about such a solution?

@pkosiec
Copy link
Member

pkosiec commented Feb 7, 2023

Hi,
Unfortunately we don't support JSON paths currently. However, in 0.19 we'll introduce include/exclude regex patterns for event message or reason: #954. Is this something you can use to solve your use case? Or does it depend strictly on the Kubernetes object attached to a given event?

@andromedi4
Copy link

Hi,
I updated to the latest version (v1.0.0) now my config looks like this:

      velero:
        botkube/kubernetes:
          enabled: true
          config:
            event:
              types:
              - create
              - update
              - error
              message:
                include:
                - ".*"
                exclude:
                - "^InProgress.*"
                - "^Completed.*"
                - "^Deleting.*"
            namespaces:
              include:
              - ".*"
            resources:
            - type: velero.io/v1/backups
              updateSetting:
                fields:
                  - status.phase
                includeDiff: true
            - type: velero.io/v1/restores
              updateSetting:
                fields:
                  - status.phase
                includeDiff: true
          context:
            defaultNamespace: default
            rbac:
              group:
                prefix: ""
                static:
                  values:
                  - botkube-plugins-default
                type: Static

But this did not solve the issue with extra messages come:
image

@pkosiec
Copy link
Member

pkosiec commented Oct 10, 2023

Hey,
I remember we had a fix related to the updateSetting.fields in one of the post-1.0 versions: #1122. I'm pretty sure it solves the issue.
Also, for Botkube 1.0+ we do support regexes for event filters (message, reason, etc.): https://docs.botkube.io/configuration/source/kubernetes. @h4wkmoon Could you please upgrade to the latest Botkube (v1.5.0) and try again? I'll close it for now, but we can reopen it anytime if it didn't help. Cheers!

@pkosiec pkosiec closed this as completed Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants