Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stackdriver error reporting with gcloud

I'm retying to use the gcloud cli to send events to StackDriver Error Reporting.
The (very limited) documentation is here: https://cloud.google.com/sdk/gcloud/reference/beta/error-reporting/events/report

Regardless of what I send as a message I seem to get this error:

ERROR: (gcloud.beta.error-reporting.events.report) INVALID_ARGUMENT: ReportedErrorEvent.context must contain a location unless message contain an exception or stacktrace.

I have tried formatting the message as a JSON representation of an error report: https://cloud.google.com/error-reporting/docs/formatting-error-messages but the message seems to be the same. Here's an example command and JSON:

gcloud beta error-reporting events report --service foo --message-file err.json

{
    "serviceContext": {
        "service": "foo"
    },
    "message": "Whoops!",
    "context": {
        "reportLocation": {
            "filePath": "/usr/local/bin/test",
            "lineNumber": 123,
            "functionName": "main"
        }
    }
}
like image 650
Robert Jordan Avatar asked Sep 19 '17 02:09

Robert Jordan


1 Answers

Yet another way.

gcloud logging write --payload-type=json test-errors-log '
{
  "serviceContext": {"service": "foo"},                        
  "message": "message with stacktrace\n at /test.js"
}
'
gcloud logging write --payload-type=json test-errors-log '
{
  "@type": "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent",
  "message": "message without stacktrace"
}
'
gcloud beta error-reporting events report --service foo --message 'message with stacktrace
at /test.js'
like image 122
Koichi Nakashima Avatar answered Oct 22 '22 00:10

Koichi Nakashima