4

I've built a docker image for GKE, and want to use Google Stackdriver Logging.

For the moment I'm just trying to log Service started when a service starts.

While running the container on my host works well (In Google Cloud Console > Logs Viewer > Global, I can see Service started when expected), running the container the exact same way on Google Cloud Shell doesn't log anything. Deploying to GKE does the exact same behavior, no errors but I can't find the supposedly created logs.

Here are the scopes for my cluster: cloud-platform,compute-rw,datastore,default,storage-full,logging-write,service-control,service-management.

Note that the logging client gets successfully created:

client, err := logging.NewClient(ctx, projectID)

if err != nil {
    log.Fatalf("Failed to create the logging client: %v", err)
} else {
    fmt.Println("Logging client created")
}

app.Logger = client.Logger(logName)

text := "Started service !"

app.Logger.Log(logging.Entry{
    Payload: text,
})

I get "Logging client created" every time in my cluster logs, or when running the container manually inside the Google Cloud Shell. But I get "Started service !" only when running the container on my own machine.

Thomas Sauvajon
  • 1,660
  • 2
  • 13
  • 26

1 Answers1

1

I ran the gcloud logging command:

gcloud logging read "logName=projects/${PROJECT_ID}/logs/${LOG_NAME}"

and I found out the type: gce_instance instead of the expected type: global.

Thanks to https://stackoverflow.com/a/45085569/7046455 I found my logs under GCE VM Instance.

It is quite surprising NOT to be able to simply gets all the logs by log name on the Google Cloud Console, while it is possible on the CLI...

EDIT: these are actually the logs from the Google Cloud Shell, NOT from my containers ! I still haven't found out why my logs are not created in my cluster ...

Thomas Sauvajon
  • 1,660
  • 2
  • 13
  • 26