Help Center> Cloud Container Engine> API Reference> Kubernetes APIs> Event> Listing Events in a Specified Namespace

Listing Events in a Specified Namespace

Function

This API is used to list all events in a specified namespace.

URI

GET /api/v1/namespaces/{namespace}/events

Table 1 describes the parameters of this API.

Table 1 Description

Parameter

Mandatory

Description

namespace

Yes

Object name and auth scope, such as for teams and projects.

pretty

No

If 'true', then the output is pretty printed.

includeUninitialized

No

If true, partially initialized resources are included in the response.

fieldSelector

No

A selector to restrict the list of returned objects by their fields. Defaults to everything.

labelSelector

No

A selector to restrict the list of returned objects by their labels. Defaults to everything.

resourceVersion

No

When specified with a watch call, shows changes that occur after that particular version of a resource. Defaults to changes from the beginning of history.

timeoutSeconds

No

Timeout for the list/watch call.

watch

No

Watch for changes to the described resources and return them as a stream of add, update, and remove notifications. Specify resourceVersion.

Request

N/A

Response

Response parameters:

For the description about response parameters, see Table 2.

Table 2 Response parameters

Parameter

Type

Description

kind

String

A string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase.

apiVersion

String

Versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values.

metadata

metadata object

-

items

items object

List of replication controllers.

Table 3 Data structure of the items field

Parameter

Type

Description

metadata

metadata object

Standard object's metadata.

involvedObject

involvedObject object

The object that this event is about.

kind

String

Kind is a string value representing the REST resource this object represents.

reason

String

This should be a short, machine understandable string that gives the reason for the transition into the object's current status.

message

String

A human-readable description of the status of this operation.

source

source object

The component reporting this event. Should be a short machine understandable string.

firstTimestamp

Time

The time at which the event was first recorded. (Time of server receipt is in TypeMeta.)

lastTimestamp

Time

The time at which the most recent occurrence of this event was recorded.

count

Integer

The number of times this event has occurred.

type

String

Type of this event (Normal, Warning), new types could be added in the future.

Table 4 Data structure of the involvedObject field

Parameter

Type

Description

kind

String

Kind of the referent.

namespace

String

Namespace of the referent.

name

String

Name of the referent.

uid

String

UID of the referent.

apiVersion

String

API version of the referent.

resourceVersion

String

Specific resourceVersion to which this reference is made.

fieldPath

String

If referring to a piece of an object instead of an entire object, this string should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2]. For example, if the object reference is to a container within a pod, this would take on a value like: "spec.containers{name}" (where "name" refers to the name of the container that triggered the event) or if no container name is specified "spec.containers[2]" (container with index 2 in this pod). This syntax is chosen only to have some well-defined way of referencing a part of an object.

Table 5 Data structure of the source field

Parameter

Type

Description

component

String

Component from which the event is generated.

host

String

Node name on which the event is generated.

Example response:

{
    "kind": "EventList",
    "apiVersion": "v1",
    "metadata": {
        "selfLink": "/api/v1/namespaces/default/events",
        "resourceVersion": "6218"
    },
    "items": [
        {
            "metadata": {
                "name": "asdf-554b5dfc44-7mm4f.152b13061a06a7c2",
                "namespace": "default",
                "selfLink": "/api/v1/namespaces/default/events/asdf-554b5dfc44-7mm4f.152b13061a06a7c2",
                "uid": "9e033be0-4ea6-11e8-8c02-fa163e69d0fd",
                "resourceVersion": "6218",
                "creationTimestamp": "2018-05-03T07:50:15Z",
                "enable": true
            },
            "involvedObject": {
                "kind": "Pod",
                "namespace": "default",
                "name": "asdf-554b5dfc44-7mm4f",
                "uid": "9dff08f2-4ea6-11e8-8c02-fa163e69d0fd",
                "apiVersion": "v1",
                "resourceVersion": "1767656"
            },
            "reason": "FailedScheduling",
            "message": "0/1 nodes are available: 1 Insufficient memory.",
            "source": {
                "component": "default-scheduler"
            },
            "firstTimestamp": "2018-05-03T07:50:15Z",
            "lastTimestamp": "2018-05-03T07:50:22Z",
            "count": 5,
            "type": "Warning",
            "eventTime": null,
            "reportingComponent": "",
            "reportingInstance": ""
        }
    ]
}

Status Code

Table 6 describes the status code of this API.

Table 6 Status code

Status Code

Description

200

This operation succeeds, and an Event resource object is returned.

For the description about error status codes, see Status Code.