Stackdriver webhook not work with google hangout chat.

476 views
Skip to first unread message

Ondřej Fuchs

unread,
May 16, 2019, 10:24:33 AM5/16/19
to Google Stackdriver Discussion Forum
Stackdriver webhook with Google hangout chat
 - for sending alert messages to chat room.

After I prepared google chat room, setting webhook to incoming messages and test without auth (token only) by python script works ok, but on Stackdriver side cant send testing and also alerting message to google chat. 
- Also also testing connection by default button (and I got "Test notification sent!"), but nothing in google chat room.
- URL, what I have https://chat.googleapis.com/v1/spaces/<AAAA.....>/messages?key=<our_key>&token=<our_token>
- Also not found any info that Stackdriver and google chat works ok together.

Any info help me a lot. 
Thanks.

Michael Safyan

unread,
May 16, 2019, 11:45:29 AM5/16/19
to Ondřej Fuchs, Google Stackdriver Discussion Forum
Hi, Ondřej.

The specification of the payload that is delivered by a Stackdriver webhook and the specification of the request body expected by Google Chat are different. Stackdriver webhook payloads represent a "Stackdriver incident" and include details that make sense in the context of Stackdriver. Google Chat messages represent information to be displayed that is specific to Google Chat and its various messaging capabilities. In general, attempting to point a webhook directly at another service (whether Google Chat or any other API, whether Google-owned or third party), will not work. The expectation with the webhook channel is that you will implement your own microservice to receive them and that is designed to accept the particular format of the Stackdriver webhook payload. This microservice can be implemented on Google Cloud (e.g. using Cloud Run, Cloud Functions, App Engine, Kubernetes Engine, Compute Engine, etc.), on a third-party cloud provider, or on premise. That microservice can then convert the Stackdriver webhook payload, which typically looks something like:

{
  "version": "1.2",
   "incident": {
      # ID of the incident that was opened or closed.
      "incident_id": "123412574752",

      # More incident metadata
      "policy_name": "Display Name of the Policy",
      "condition_name": "Display Name of the Condition",

      # The resource on which the incident took place; type and labels will vary
      # depending on the specific resource in question.
      "resource": {
         "type": "global",
          "labels": {
              "project_id": "some-project-id",
           }
      },

      # Whether the incident is "open" or "closed".
      "state": "closed",

      # Timing information. The "ended_at" property will only
      # be available if the incident is closed.
      "started_at": 172127410205,
      "ended_at": 172127410206,

      # ...
   }
}

...into a Google Chat message, which can use simple text or a more sophisticated card representation, and issue its own HTTP request to the Google Chat API. This approach (having your own microservice to receive webhooks and then transforming the data before invoking other services) is the general pattern that I would recommend even in the case of third parties that accept the Stackdriver payload format, since having that microservice under your control as an intermediary will give you more operational visibility (e.g. knowing that a webhook was issued but that the third party invocation failed) and will also give you more capability to recover in the face of failure (e.g. retrying the third party API invocation).

In terms of Google Chat, specifically, we know that this is a gap and that there should be a way to use it in Stackdriver directly, without using webhook at all. But, for now, my recommendation would be to workaround through the use of such an intermediary microservice to do this integration.

Michael Safyan

Senior Software Engineer · Stackdriver Monitoring

6425 Penn Ave 7th Floor; Pittsburgh, PA 15206

http://www.michaelsafyan.com | michae...@google.com



--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Stackdriver Discussion Google Group (google-stackdr...@googlegroups.com) to participate in discussions with other members of the GoogleStackdriver community.
---
You received this message because you are subscribed to the Google Groups "Google Stackdriver Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-stackdriver-d...@googlegroups.com.
To post to this group, send email to google-stackdr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-stackdriver-discussion/bc59d71d-d8f2-4494-98d7-22649972a6e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ieuan Jenkins

unread,
Jul 29, 2019, 11:37:34 AM7/29/19
to Google Stackdriver Discussion Forum
Hi Michael,

In terms of the gap in functionality you mention between GCP Stackdriver Alerting and G Suite Chat, is this the right place to watch for any progress/updates in that area or is this something that has to be raised elsewhere?

Thanks,
Ieuan
Email preferences: You received this email because you signed up for the Google Stackdriver Discussion Google Group (google-stackdriver-discu...@googlegroups.com) to participate in discussions with other members of the GoogleStackdriver community.

---
You received this message because you are subscribed to the Google Groups "Google Stackdriver Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-stackdriver-discussion+unsub...@googlegroups.com.

Michael Safyan

unread,
Jul 29, 2019, 3:19:24 PM7/29/19
to Ieuan Jenkins, Google Stackdriver Discussion Forum, Rory Petty
Hi, Ieuan!

We're unlikely to publish regular updates in this forum, but we hear you on the feature request for direct integration of Hangouts Chat / G Suite Chat for alert notifications. Full disclosure: while we have this on our roadmap, work on this particular item is unlikely to start until 2020 given other project priorities; for the time being, the webhook => handler of your own (in Cloud Run, Cloud Functions, App Engine, Compute Engine, or some other system) => G Suite Chat API is the best approach for integration.

If you'd like regular updates, I'd recommend opening up a support case, since the support staff will periodically check-in on status and provide updates. If you do open a support request, I'd also recommend indicating to what extent this feature blocks adoption of Stackdriver Monitoring and Google Cloud Platform more generally, as that can help inform our prioritization.

Michael Safyan

Senior Software Engineer · Stackdriver Monitoring

6425 Penn Ave 7th Floor; Pittsburgh, PA 15206

http://www.michaelsafyan.com | michae...@google.com


Email preferences: You received this email because you signed up for the Google Stackdriver Discussion Google Group (google-stackdr...@googlegroups.com) to participate in discussions with other members of the GoogleStackdriver community.

---
You received this message because you are subscribed to the Google Groups "Google Stackdriver Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-stackdriver-d...@googlegroups.com.

--
© 2016 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Stackdriver Discussion Google Group (google-stackdr...@googlegroups.com) to participate in discussions with other members of the GoogleStackdriver community.

---
You received this message because you are subscribed to the Google Groups "Google Stackdriver Discussion Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-stackdriver-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-stackdriver-discussion/90f4a2b9-c7cf-46d6-b49f-ddf62de89f4d%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages