Rocket.chat: Grafana Web Integration Via Slack Broken

Created on 19 Jul 2018  Â·  11Comments  Â·  Source: RocketChat/Rocket.Chat

Description:

Upon creating a notification channel in Grafana using the Slack channel, sending any notification over error are reported in Rocket Chat

Steps to reproduce:

  1. Create notification channel using Slack in Grafana and send notification
  2. Check for errors in Rocket Chat Logs

Expected behavior:

Messages are displayed within the configured chat room

Actual behavior:

The following log is displayed;

Jul 19 14:28:45  rocketchat: #033[34mIntegrations âž” Incoming WebHook.info#033[39m Post integration: localhost - Grafana
Jul 19 14:28:45  rocketchat: #033[34mIntegrations âž” Incoming WebHook.debug#033[39m @urlParams: { integrationId: 'xxxxxxxxxxxx',
Jul 19 14:28:45  rocketchat: token: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' }
Jul 19 14:28:45  rocketchat: #033[34mIntegrations âž” Incoming WebHook.debug#033[39m @bodyParams: { attachments:
Jul 19 14:28:45  rocketchat: [ { color: '#D63232',
Jul 19 14:28:45  rocketchat: fallback: '[Alerting] Test notification',
Jul 19 14:28:45  rocketchat: fields: [Array],
Jul 19 14:28:45  rocketchat: footer: 'Grafana v5.2.1',
Jul 19 14:28:45  rocketchat: footer_icon: 'https://grafana.com/assets/img/fav32.png',
Jul 19 14:28:45  rocketchat: image_url: '',
Jul 19 14:28:45  rocketchat: text: '@all Someone is testing the alert notification within grafana.',
Jul 19 14:28:45  rocketchat: title: '[Alerting] Test notification',
Jul 19 14:28:45  rocketchat: title_link: 'http://localhost/',
Jul 19 14:28:45  rocketchat: ts: 1532010525 } ],
Jul 19 14:28:45  rocketchat: channel: '#critical-alerts',
Jul 19 14:28:45  rocketchat: parse: 'full' }
Jul 19 14:28:45  rocketchat: #033[34mAPI âž” debug#033[39m Failure { statusCode: 400,
Jul 19 14:28:45  rocketchat: body:
Jul 19 14:28:45  rocketchat: { success: false,
Jul 19 14:28:45  rocketchat: error: 'Match error: Match error: Expected string, got number in field value' } }

Server Setup Information:

  • Version of Rocket.Chat Server: 0.66.3
  • Operating System: Centos 7.5
  • Deployment Method: tar
  • Number of Running Instances: 1
  • DB Replicaset Oplog:
  • NodeJS Version: v8.9.3
  • MongoDB Version: 2.6.12
webhooks bug

Most helpful comment

As a temporary workaround, you can use a manually applied script:

class Script {

    process_incoming_request({ request }) {

        request.content.attachments.forEach(function (attachment) {
            attachment.fields.forEach(function (field) {
                field.value = field.value.toString();
            });
        });

        return request;

    }
}

All 11 comments

same here

Same issue, worked on 0.5x releases (plus Grafana 4x).
I updated both rocketchat to last 0.66 and Grafana to 5.2.1. Not sure if something has changed on Grafana side

I receive this same error:
rocketchat: error: 'Match error: Match error: Expected string, got number in field value' } }

Seams to be more on the RocketChat side as Grafana 5.2.1 can send to slack fine but when switching to a rocketchat webhook-url the error occures.
image

FTR: I'm running rocket chat v0.66.3

As a temporary workaround, you can use a manually applied script:

class Script {

    process_incoming_request({ request }) {

        request.content.attachments.forEach(function (attachment) {
            attachment.fields.forEach(function (field) {
                field.value = field.value.toString();
            });
        });

        return request;

    }
}

@RocketChat/core any idea why this workaround would be needed? :top:

It seems our webhook is not 100% slack compatible. Can we do something like the above workaround in our webhook to maintain slack compatible?

@makubi thanks for posting your workaround. I personally have needed this also :)

From my tests the reason is Grafana doesn't send the text field and seems that we require it.

so the fix would be making text field optional.

Are you sure? @APenketh's log output says

Jul 19 14:28:45 rocketchat: error: 'Match error: Match error: Expected string, got number in field value' } }

and the workaround just converts the value value of all fields to Strings.

https://github.com/RocketChat/Rocket.Chat/blob/develop/packages/rocketchat-lib/server/functions/sendMessage.js#L25 looks like this line right here forces the field value to be a string.

@sampaiodiego should we make it any? or is there a way with check to make it anything but array or object? :no_mouth:

Went ahead and opened a PR. I assume string and ints are the only real values that should be here.

_maybe_ bools?

Hi,
currently running on 0.70.0, some of my grafana notifications are not received (I receive them via Email and via rocket-chat (via the slack notification channel), and sometimes the notifications are only received per Email)
I could not find anything in the logs from the administration page, (log level of 1). I just switched to 2.

Any hints how I could debug? / what file to look at ?

Many thanks !
François

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jadeqwang picture jadeqwang  Â·  81Comments

gwillen picture gwillen  Â·  77Comments

mitar picture mitar  Â·  68Comments

bazarnew picture bazarnew  Â·  87Comments

AmShaegar13 picture AmShaegar13  Â·  74Comments