<p>My application is deployed on a Kubernetes Cluster that runs on Google Cloud. I want to fetch logs written by my application using <a href="https://cloud.google.com/logging/docs/reference/v2/rest/v2/logs/list" rel="nofollow noreferrer">Stackdriver's REST APIs for logging</a>.</p>

<p>From the above documentation page and <a href="https://googlecloudplatform.github.io/google-cloud-python/latest/logging/usage.html#retrieving-log-entries" rel="nofollow noreferrer">this example</a>, it seems that I can only list logs of a project, organization, billing account or folder.</p>

<p>I want to know if there are any REST APIs using which I can fetch logs of:</p>

<ul>
<li>A pod in a Kubernetes Cluster running on Google Cloud</li>
<li>A VM instance running on Google Cloud</li>
</ul>

<p>you need to request per <a href="https://cloud.google.com/logging/docs/reference/v2/rest/v2/MonitoredResource" rel="nofollow noreferrer">MonitoredResource</a>, which permits instance names and alike... for GCE that would be <code>gce_instance</code> while for GKE it would be <code>container</code>. individual pods of a cluster can be filtered by their <code>cluster_name</code> &amp; <code>pod_id</code>; the documentation for <a href="https://cloud.google.com/logging/docs/api/v2/resource-list" rel="nofollow noreferrer">resource-list</a> describes it:</p>
<blockquote>
<p><strong>container</strong> (GKE Container) A Google Container Engine (GKE) container instance.</p>
<p><strong>project_id</strong>: The identifier of the GCP project associated with this resource, such as &quot;my-project&quot;.</p>
<p><strong>cluster_name</strong>: An immutable name for the cluster the container is running in.</p>
<p><strong>namespace_id</strong>: Immutable ID of the cluster namespace the container is running in.</p>
<p><strong>instance_id</strong>: Immutable ID of the GCE instance the container is running in.</p>
<p><strong>pod_id</strong>: Immutable ID of the pod the container is running in.</p>
<p><strong>container_name</strong>: Immutable name of the container.</p>
<p><strong>zone</strong>: The GCE zone in which the instance is running.</p>
</blockquote>
