How do I know who changed my Cloud Function

Viewed 309

Yesterday, on a beautiful Saturday, I was resting. When suddenly the phone rings and the "system has stopped working". When I observed the "cloud functions" one of them had an upload that I did not do, probably another member of the team. After all, I was resting!

Now, my manager wants the deployment history for all functions. How to know and where to get this information?

Entering the "cloud function" I can even see that there was the deploy, but it does not say "which user did it".

4 Answers

There are audit logs kept for all user actions. You can determine who updated the function by:

  1. Go to Logging > Logs Explorer

  2. In the Query Builder text box, add the following search term:

protoPayload.methodName="google.cloud.functions.v1.CloudFunctionsService.UpdateFunction"

  1. Click the Run Query button and then filter down by the date and time of when it was deployed and you'll see the user's email in the principal_email property.

@Brian's answer is good. But here's another way to check Audit logs and see all operations happening on Cloud Functions:

  1. Go to Navigation Menu > Home > Activity
  2. Go to Filter Categories on the right part of the screen and make sure all Activity types are selected (checking only Data Access and configuration works fine as well).
  3. Click Resource type and uncheck all but don't click OK yet.
  4. Type to filter "Cloud Function" then check it.
  5. Click OK.
  1. In logs for the functions you have the information about deployment it should look something like that:

    {"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{},"authenticationInfo":{"principalEmail":"EMAIL@gmail.com"},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"projects/ffunctions-nodejs/locations/us-central1/functions/CRON_1440_OptimisationCall"}

I would start with reviewing this information (it is on the Console -> Project -> Functions -> logs)

  1. Down the rabbit hole, we can go into console.cloud.google.com (Console -> Project -> Functions -> click on the three dots and go "Detailed usage statistics").

not really sure what you can dig in there though

Go to the Logs explorer and paste the below to find the updaed users of the cloud function.

resource.type = "cloud_function"
resource.labels.function_name = "your_cloud_function_name"
protoPayload.methodName="google.cloud.functions.v1.CloudFunctionsService.UpdateFunction"

Hope this helps!!

enter image description here

Related