I have been exploring to transfer the JsonPayload message field
from Logs viewer service (which are syslogs of a service) of GCP to a slack network, but owing to this I am not able to find any predefined services (like alerting policies to transfer Payload) available on Stackdriver. I have been able to create a counter or distribution user-metrics for logs but this will only provide me with some int64 value instead of a string value or the actual message body. Is there a way in GCP
to actually send a payload of logs over slack or any email?
Asked
Active
Viewed 2,151 times
3

john mich
- 2,477
- 3
- 17
- 32
-
2Do you want to transfer existing Stackdriver log entries to Slack or setup a service to send new log entries to Slack? Neither is directly supported by GCP, but you can create a log sink, write a Cloud Function to process new entries and post to Slack via a WebHook. – John Hanley Apr 15 '20 at 19:31
-
I would create this in the first step before creating a new service and send logs from the start irrespective of old and new. Where would log sink send the data to? Would it be a BigQuery or Pubsub? – john mich Apr 16 '20 at 15:26
-
1If you are using a Cloud Function to post to Slack, you would use Pub/Sub. – John Hanley Apr 16 '20 at 15:48
-
Ok, noted. Thanks – john mich Apr 17 '20 at 20:29
3 Answers
1
In GCP, you can export logs to Pub/Sub, Cloud Storage, or BigQuery. There is no other way within GCP to export logs at the moment.

Jason Gawrych
- 120
- 5
1
We had a similar issue where we wanted to be able to send certain events to slack and for fatal issues trigger an issue with our ops team via VictorOps.
Couldn't find anything out there to fit our needs so we just created our own slack / VictorOps Cloudfunction.
1
As of 2022, I found this can be done as follows:
In GCP Logs viewer (not legacy version) choose the create alert button.. One of the options here is a GCP notification channel, which supports slack. Some points here:
- The slack channel can't be private as far as I can tell
- Slack channel must be in your correct slack space. If your org has multiple slack spaces, make sure GCP is trying to connect to correct one.
Put in the log query criteria you want. THen go into Monitoring and you will see this in Alerting dropdown.

Adam Hughes
- 14,601
- 12
- 83
- 122