Maybe I missed something, under https://console.cloud.google.com/apis/api/sqladmin.googleapis.com/overview
I saw there are a lot of errors, but when I go to Logs Viewer, I couldn't find anything. Is any way I can obtain the error log?
Basically, you should create a query to obtain the data you need in the Log Viewer UI: specify a type of resource and an instance name whose logs you want to view.
GCP Console => Operations => Logging => Logs Viewer
=> Query builder => Resource
Cloud SQL Database = my-project:my-sql-instance
The query builder will show a query preview like below:
resource.type="cloudsql_database"
resource.labels.database_id="my-project:my-sql-instance"
Once you click the “Run Query” button, the log entries will appear. By default log entries for the last 1 hour are shown. You can use the "Edit time" option to change this.
Please see Cloud Logging > Doc > Basic logs queries for more details.
Related
This is part of my journey to get a clear overview of which users/service accounts are in my GCP Project and when they last logged in.
Endgoal: to be able to clean up users/service-accounts if needed when they weren't on GCP for a long time.
First question:
How can I find in the logs when a specific user used resources, so I can determine when this person last logged in?
You need the Auditlogs and to see them you can run the following query in Cloud Logging:
protoPayload.#type="type.googleapis.com/google.cloud.audit.AuditLog"
protoPayload.authenticationInfo.principalEmail="your_user_name_email_or_your_service_account_email"
You can also check the Activity logs and filter on a user:
https://console.cloud.google.com/home/activity
Related questions + answers:
Pull "last access" information on projects from Google Cloud Platform (GCP)
IAM users and last login date in google cloud
How to list, find, or search iam policies across services (APIs), resource types, and projects in google cloud platform (GCP)?
There is now also the newly added Log Analytics.
This allows you to use SQL to query your logs.
Your logging buckets _Default and _Required need to be upgraded to be able to use Log Analytics:
https://cloud.google.com/logging/docs/buckets#upgrade-bucket
After that you use for example the console to use SQL on your logs:
https://console.cloud.google.com/logs/analytics
Unfortunately, at the moment you can only query the logs that were created after you've switched on Log Analytics.
Example query in the Log Analytics:
SELECT
timestamp,
proto_Payload.audit_log.authentication_info.principal_email,
auth_info.resource,
auth_info.permission,
auth_info.granted
FROM
`logs__Default_US._AllLogs`
left join unnest(proto_Payload.audit_log.authorization_info) auth_info
WHERE
timestamp > TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
and proto_payload.type = "type.googleapis.com/google.cloud.audit.AuditLog"
and proto_Payload.audit_log.authentication_info.principal_email in ("name_of_your_user")
ORDER BY
timestamp
How can I see the logs regarding the VMs that has been created on Google Cloud Compute Engine ?
Google Operations Logging (formerly Stackdriver) provides this information.
To see the details on Google Compute Engine instances that were created in a project, filter based upon the API operation v1.compute.instances.insert and the resouce type resource.type=gce_instance.
Note: the resouce type is not always necessary but it is best to be declarative in what logging should search for.
Example using the CLI:
gcloud logging read "resource.type=gce_instance protoPayload.methodName=v1.compute.instances.insert" --format json
Example using the Google Cloud Console - Legacy Logs Viewer
Go to https://console.cloud.google.com/logs/viewer
Verify that the desired Google Cloud project is displayed in the title area.
In the box showing the text "Filter by label or text search" click the dropdown and select "Convert to advanced filter".
In the box showing the text "Filter by label or text search" enter the following (as two lines in the filter box):
resource.type="gce_instance"
protoPayload.methodName="v1.compute.instances.insert"
Select the desired date search range in the box "Last hour"
Click the "Submit Filter" button
I need your help , actually i need to create a dasboard in GCP to show TTR Time , TTR response via fetching logs from GCP logging that i am writting using script but unable to achieve it.
Below is command i am using:
gcloud logging write logging/user/TTR4 '{"Gremblin_correlation_exec_id": "correlation_id","SenerioName": "Senerio1","ServiceName": "Service1","SubsystemName": "subsystem1","TTRTime": 500,"EndTimestamp": "2020-11-30 06:06:56+00:00","Node_ipfirst": "10.128.0.55:80","node_ipsecound": "10.128.0.6:80","starttimestamp": "2020-11-30 05:58:08+00:00" }' --payload-type=json
i am getting jason data but not able to show it on dasboard like TTRTime above 500 using filter based upon service name and subsystemName.
I find myself toggling between different 'resources' to view my logs in stackdriver. For example:
Is there a way to view all combined logs from a single view? Most go to "Global", but many do not as well.
Just convert the filter to advanced view and select the resource types that you need
resource.type="bigquery_resource" OR resource.type="gce_instance" OR resource.type="audited_resource"
That will show you the logs for bigquery and audit and gce in a single view.
I believe you can do textual search across all logs, but it will not be as granular as resource type based search. You can try this with the Advanced filter feature.
On the top right corner of the search box, click the drop down menu and select "Convert to advanced filter". Then delete the "resource.type=xyz" line and type the string you want to search.
As alternative the gcloud sdk cli to search the logs without specifying resource type - for instance, gcloud logging read error --limit 1 would look for "error" string across all your logs and show only 1 matching entry.
I just created a model on ML Engine with:
gcloud ml-engine models create test_model --enable-logging
I went into the GUI and created a version. I'm hitting this model for predictions but where do I go in the GUI to find the logs for online predictions?
Thanks!
The logs can be found in StackDriver Logging:
Go to https://console.cloud.google.com
Click on the "hamburger" icon in the top left
Find the "Logging" option under "STACKDRIVER"
Click on "Logs" (you can get directly here with a link similar to: https://console.cloud.google.com/logs/viewer?project=my_project, just subsituate your actual project name)
Locate the drop down menu that allows you to select your logs.
Hover over "Cloud ML Model Version
Either click the model you're interested in or hover over it, if you want to select a specific version
(Optional) If selecting a specific version, click on it.
That said, I'll file a feature request to have a link in a more convenient place alongside the model and/or version.