Skip to content

Insuffecient Slack Integration Docs #634

Open

Description

@pulkitanz

There's no slack integration docs when configuring alerts so it's very hard to debug when configuring slack notifications.

By docs, I mean do we have to configure webhook, what permissions does the slack-bot require and how the secret should be configured. There's little to no information here: https://fluxcd.io/flux/monitoring/alerts/#define-a-provider

I am facing this error and I have no idea what's wrong with my slack configuration:

{"level":"error","ts":"xxx","logger":"event-server","msg":"failed to send notification","eventInvolvedObject":{"kind":"Kustomization","namespace":"flux-system"}, "alert":{"name":"slack-monitoring","namespace":"flux-system"},"error":"postMessage failed: failed to execute request: context deadline exceeded"}

Any leads would help!

Activity

  1. makkes commented on Oct 24, 2023

    @makkes
    Member

    There is more documentation and an example here. Does that help you clarify how to integrate Slack?

  2. hiddeco commented on Oct 24, 2023

    @hiddeco
    Member

    In addition, "context deadline exceeded" usually means a time-out of some sort. Which may be due to the controller being unable to reach out to Slack.

  3. kingdonb commented on Oct 26, 2023

    @kingdonb
    Member

    This link is even more specific: https://fluxcd.io/flux/components/notification/providers/#slack-example

    We could put an earlier additional reference to this link up here:

    Screenshot 2023-10-26 at 1 44 31 PM

    It might be too early to call out the reference to every Provider type, but we are giving some favoritism to Slack as the first most prominent example.

  4. gecube commented on Nov 1, 2023

    @gecube

    Hi!

    I did not find any issues with Slack integration. The documentation is clear enough. The only culprit was how to prepare the proper slack token and how to put it into the secret. Then everything worked for me. BTW, I am using the full address of slack hook, not the token itself. Something like this:

    apiVersion: notification.toolkit.fluxcd.io/v1beta2
    kind: Alert
    metadata:
      name: slack-p0
      namespace: flux-system
    spec:
      eventSeverity: error
      eventSources:
        - kind: GitRepository
          name: '*'
        - kind: Kustomization
          name: '*'
        - kind: HelmRelease
          name: '*'
      providerRef:
        name: slack-p0
      summary: "UAT cluster"
    apiVersion: notification.toolkit.fluxcd.io/v1beta2
    kind: Provider
    metadata:
      name: slack-p0
      namespace: flux-system
    spec:
      channel: sys-fluxcd-errors
      secretRef:
        name: slack-url-p0-uat
      type: slack
    kind: Secret
    apiVersion: v1
    metadata:
      name: slack-url-p0-uat
      namespace: flux-system
    data:
      address: >-
        aHR......dndP
    type: Opaque

    the address looked like https://hooks.slack.com/services/XXXXXXXXXXX/XXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX

    So it is obvious that two or more options how to prepare the integration with Slack exists.

  5. nishasati6oct commented on Mar 4, 2024

    @nishasati6oct

    I am using encrypted SOPS secret and defining the secret in this way giving me error "invalid URI for request". Here is my configuration

    apiVersion: notification.toolkit.fluxcd.io/v1beta3
    kind: Provider
    metadata:
      name: slack-bot-dev
      namespace: flux-system
    spec:
      type: slack
      secretRef:
        name: webhook-url
    ---
    apiVersion: notification.toolkit.fluxcd.io/v1beta3
    kind: Alert
    metadata:
      name: slack-bot-dev
      namespace: flux-system
    spec:
      summary: "flux notification"
      eventMetadata:
        env: "dev"
        cluster: "aks-cluster"
        region: "West Europe"
      providerRef:
        name: slack-bot-dev
      eventSeverity: info
      eventSources:
        - kind: Kustomization
          name: '*'
        - kind: HelmRelease
          name: '*'
    Sops encrypted secret
    apiVersion: v1
    kind: Secret
    metadata:
        name: webhook-url
        namespace: flux-system
    stringData:
        address: ENC[AES256_GCM,data:VzeQbZEpTsB+ocrLE96tU+BtgtnkB894Qz5k79ffRewUYIFPgnz1c9APytr38AnO6y08qg1Gw6iZ23zwoX+eTejydvIEJRFfrlNY8LzAmd7WTysPR3kgk2qI=,tag:Q4k4q2kdORMoHqNJ4V7k8w==,type:str]
    sops original secret
    apiVersion: v1
    kind: Secret
    metadata:
        name: webhook-url
        namespace: flux-system
    stringData:
        address: "https://hooks.slack.com/services/XXXXXX/XXXXXXX/XXXXXXXXXXXXX"
  6. gecube commented on Mar 4, 2024

    @gecube

    @nishasati6oct Hi! Nice to meet you here. It is very pity to hear that you have the issue. Also could you please use markdown format, otherwise it is very difficult to read and understand your snippets. Thanks in advance.

  7. nishasati6oct commented on Mar 5, 2024

    @nishasati6oct

    @nishasati6oct Hi! Nice to meet you here. It is very pity to hear that you have the issue. Also could you please use markdown format, otherwise it is very difficult to read and understand your snippets. Thanks in advance.

    Updated my comment in markdown format :)
    My SOPS issue is resolved now. But I have another query regarding the notification of HR. My HR's are present in their application namespace (not in flux-system). Here is my config for alert (Note: Using wildcard entry for namespace?.

    apiVersion: notification.toolkit.fluxcd.io/v1beta3
    kind: Alert
    metadata:
      name: slack-bot-dev
      namespace: flux-system
    spec:
      summary: "flux notification"
      eventMetadata:
        env: "dev"
        cluster: "aks-cluster"
        region: "West Europe"
      providerRef:
        name: slack-bot-dev
      eventSeverity: info
      eventSources:
        - kind: HelmRelease
          namespace: '*-dev'
          name: '*'

    But in slack notification, I am not getting any HR notification. Please let me know if any changes needed here in alert configuration. Thanks for your help. :)

  8. gecube commented on Mar 9, 2024

    @gecube

    @nishasati6oct Hi! It looks like that you need to put the Alert object inside of the same namespace like HR itself. I think it should help.

  9. stefanprodan commented on Mar 9, 2024

    @stefanprodan
    Member

    This doesn't work namespace: '*-dev' we don't support wildcards for namespaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions