Extract label loggin alert

Hello guys,

I use cloud alert and slack to receive nodifications.

I would like to receive the jsonPayload.message field in Slack, but I don't know how to configure this extraction,

Would anyone know?

In the print below, you can see how the data is in cloud loggin.

alert-gcp.png

 

Solved Solved
0 3 1,868
1 ACCEPTED SOLUTION

Hi DamianS,

I tested it the way you showed and it works correctly, but Google recently released something that I hadn't seen, now there is an "Extract log labels" option, this option appears when you create an alert based on log entries.

alert-gcp-2.png

I believe that now it is much simpler to do this extraction.

 

 

View solution in original post

3 REPLIES 3

Hi,

There is no ( at least known by me ) option to print exact json payload taken from Stackdriver. You can use values from payload by configuring log0based metrics and labels, and log-based alerts and documentation section.

1. Create log-based metric and define labels[1]
2. Create log-based alert from metric[2]
3. At alerting policy, use "Documentation" section to obtain values from metric[3, step 7]
4. Logs will be collected AFTER creation log-based alerts. 

[1]. https://cloud.google.com/logging/docs/logs-based-metrics/counter-metrics
https://cloud.google.com/logging/docs/logs-based-metrics/labels
[2]. https://cloud.google.com/logging/docs/alerting/log-based-alerts
[3, step 7]. https://cloud.google.com/monitoring/alerts/using-alerting-ui#preview

DamianS_0-1696312218954.png

DamianS_1-1696312239393.png

cheers,
DamianS

Hi DamianS,

I tested it the way you showed and it works correctly, but Google recently released something that I hadn't seen, now there is an "Extract log labels" option, this option appears when you create an alert based on log entries.

alert-gcp-2.png

I believe that now it is much simpler to do this extraction.

 

 

hi, but were you able to put this extracted log label, in the slack alert.

I've used other labels in the slack alert with this syntax ${LABEL}. 
but for the extracted label, it doesn't work.