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

Insuffecient Slack Integration Docs #634

Open
pulkitanz opened this issue Oct 24, 2023 · 9 comments
Open

Insuffecient Slack Integration Docs #634

pulkitanz opened this issue Oct 24, 2023 · 9 comments

Comments

@pulkitanz
Copy link

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!

@makkes
Copy link
Member

makkes commented Oct 24, 2023

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

@hiddeco
Copy link
Member

hiddeco commented Oct 24, 2023

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.

@kingdonb
Copy link
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.

@gecube
Copy link

gecube commented Nov 1, 2023

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.

@nishasati6oct
Copy link

nishasati6oct commented Mar 4, 2024

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"

@gecube
Copy link

gecube commented Mar 4, 2024

@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.

@nishasati6oct
Copy link

nishasati6oct commented Mar 5, 2024

@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. :)

@gecube
Copy link

gecube commented Mar 9, 2024

@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.

@stefanprodan
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants