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.

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

cheers,
DamianS

1 Like

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.

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

1 Like

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.