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
messagecontain 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"
        }
    }
}
                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'
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With