简体   繁体   中英

GCP StackDriver RESTful API not logging even though it returns a 200

I have enabled GCP monitoring and can see the logger view. I wish to use the RESTful api to send logs to Stackdriver.

I have got the correct JWT setup evident by the fact I get a token back.

I make the request with the bellow JSON and above token and get a 200 back. Yet no log entry. Any advice would be appreciated.

{


"logName": "projects/myProject/logs/myLogGroup",
  "resource": {
    "type": "api"
  },
  "labels": {
    "zone": "us-central1-a"
  },
  "entries": [
    {
      "severity": "INFO",
      "textPayload": "Unsent log message boo"
    }
  ],
  "partialSuccess": true
}

I have used both the Google API helper in the docs with the above message. As well as PAW(Like Postman) to craft all the requests my self. Always 200 and never a message logged.

All the parameters are correct because if I changed anything like the logName or resource type I get the error "Resource type not supported:" so I am some what confident the massage is correct.

I am viewing the logs on the GCP website, I go to the log viewer under logger in the left hand burger menu. All filters off and log level set to show all levels.

When one views Stackdriver logs through the Cloud Console, the tool that is used is named "Logs Viewer". This web interfaced viewer has two primary modes.

The first mode is a guided presentation where you select high level functional sources of data to be presented. These are described in natural language (eg. Cloud Functions) and are selected from menu pull-downs.

A second mode is the the underlying technology that is actually used. This is engaged by selecting the pull-down in the Filter area which is called "Convert to advanced filter". Now you will be presented with the underlying (raw) filters being applied to Stackdriver data retrieval.

If you clear those filters you will now be seeing all the log records that are being collected from all sources. This can be useful to use if you believe that log records are being recorded but you can't find them in the wizard driven approach. You can see all the log records being recorded, cause your desired log record to be generated and then see it in the unfiltered set. That will usually give you that "aha" moment where you can now see fields that you can then use in a future filter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM