Healthz

The Healthz service provides access to the status of a path on the
system. Addtitionally it allows the implementor to provide path specific
diagnositic data into the status return.

Healthz is expected to work in conjunction with the component OC model.

Method Name Request / Response Type Description
Get GetRequest
GetResponse

Get will get the latest health status for a gNMI path. If no status is
available for the requested path an error will be returned.

List ListRequest
ListResponse

List returns all events for the provided component path.

Acknowledge AcknowledgeRequest
AcknowledgeResponse

Acknowledge will set the acknowledged field for the event.
This is an idempotent operation.

Artifact ArtifactRequest
ArtifactResponse

Artifact will stream the artifact contents for the provided artifact id.

Check CheckRequest
CheckResponse

Check will invoke the healthz on the provided component path. This RPC
can be expensive depending on the vendor implementation.

Field Type Description
path gnoi.types.Path

id string

Healthz event id.

Field Type Description
status ComponentStatus

Field Type Description
id string

ID of the artifact.

artifact_type (one of)
file FileArtifactType

proto ProtoArtifactType

custom google.protobuf.Any

Field Type Description
id string

Artifact ID to be streamed.

Field Type Description
contents (one of)
header ArtifactHeader

Header is the first message in the stream. It contains
the id of the artifact and metadata for the artifact
based on the type of the artifact.
OC defines FileArtifactType and ProtoArtifactType.

trailer ArtifactTrailer

bytes bytes

proto google.protobuf.Any

ArtifactTrailer

ArtifactTrailer is the last message in the artifact stream.

Empty message

Field Type Description
path gnoi.types.Path

event_id string

When event_id is populated the check request refers to an
event that has already been reported by the system. The
device receiving the CheckRequest should populate artifacts
that are relevant to the event that were not automatically
collected. Previous artifacts MUST NOT be overwritten.

Field Type Description
status ComponentStatus

Field Type Description
path gnoi.types.Path

path of subcomponent.

subcomponents (repeated) ComponentStatus

Subcomponents that are aggregated by this status.

status Status

Status of this component.

healthz google.protobuf.Any

Opaque data for how the healthcheck is implemented. This can be any proto
defined by the vendor. This could be the equivalent to outputs like
"show tech" or core files or any other diagnostic data.

artifacts (repeated) ArtifactHeader

Artifacts provides links to all artifacts contained in this event.
The individual artifacts can be retrieved via the Artifact() RPC.

id string

ID is the unique key for this event in the system.

acknowledged bool

Acknowledged is set when at least one caller has processed the event.

created google.protobuf.Timestamp

Created is the timestamp when this event was created.

expires google.protobuf.Timestamp

Expires is the timestamp when the system will clean up the
artifact. If unset, the artifact is not scheduled for garbage
collection.

Field Type Description
name string

Local file name of the artifact.

path string

Path to file on the local file system. (optional)

mimetype string

Mimetype of the file.

size int64

Size of the file.

hash gnoi.types.HashType

Hash of the file.

Field Type Description
path gnoi.types.Path

Path defines the component to try to fetch healthz state for. Get
retrieves the latest healthz results for a specific component
that have been collected as a result of a call to Check, or by
the target itself.

Field Type Description
component ComponentStatus

Field Type Description
path gnoi.types.Path

include_acknowledged bool

By default only the unacknowledged events for the component will be
returned.

Field Type Description
statuses (repeated) ComponentStatus

ProtoArtifactType

Generic proto message artifact stream.
This proto tells the caller that the artifact stream
will be a stream of proto encoded messages that make up
the artifact. Each message must be deserialized by the caller
and there are no other assumptions about the number of
messages or length of the stream or how those messages are to
be reassembled.

Empty message

Name Number Description
STATUS_UNSPECIFIED 0

The path doesn't support healthz

STATUS_HEALTHY 1

The path is healthy

STATUS_UNHEALTHY 2

The path is unhealthy

Any

`Any` contains an arbitrary serialized protocol buffer message along with a
URL that describes the type of the serialized message.

Protobuf library provides support to pack/unpack Any values in the form
of utility functions or additional generated methods of the Any type.

Example 1: Pack and unpack a message in C++.

Foo foo = ...;
Any any;
any.PackFrom(foo);
...
if (any.UnpackTo(&foo)) {
...
}

Example 2: Pack and unpack a message in Java.

Foo foo = ...;
Any any = Any.pack(foo);
...
if (any.is(Foo.class)) {
foo = any.unpack(Foo.class);
}
// or ...
if (any.isSameTypeAs(Foo.getDefaultInstance())) {
foo = any.unpack(Foo.getDefaultInstance());
}

Example 3: Pack and unpack a message in Python.

foo = Foo(...)
any = Any()
any.Pack(foo)
...
if any.Is(Foo.DESCRIPTOR):
any.Unpack(foo)
...

Example 4: Pack and unpack a message in Go

foo := &pb.Foo{...}
any, err := anypb.New(foo)
if err != nil {
...
}
...
foo := &pb.Foo{}
if err := any.UnmarshalTo(foo); err != nil {
...
}

The pack methods provided by protobuf library will by default use
'type.googleapis.com/full.type.name' as the type URL and the unpack
methods only use the fully qualified type name after the last '/'
in the type URL, for example "foo.bar.com/x/y.z" will yield type
name "y.z".

JSON

The JSON representation of an `Any` value uses the regular
representation of the deserialized, embedded message, with an
additional field `@type` which contains the type URL. Example:

package google.profile;
message Person {
string first_name = 1;
string last_name = 2;
}

{
"@type": "type.googleapis.com/google.profile.Person",
"firstName": ,
"lastName":
}

If the embedded message type is well-known and has a custom JSON
representation, that representation will be embedded adding a field
`value` which holds the custom JSON in addition to the `@type`
field. Example (for message [google.protobuf.Duration][]):

{
"@type": "type.googleapis.com/google.protobuf.Duration",
"value": "1.212s"
}

Field Type Description
type_url string

A URL/resource name that uniquely identifies the type of the serialized
protocol buffer message. This string must contain at least
one "/" character. The last segment of the URL's path must represent
the fully qualified name of the type (as in
`path/google.protobuf.Duration`). The name should be in a canonical form
(e.g., leading "." is not accepted).

In practice, teams usually precompile into the binary all types that they
expect it to use in the context of Any. However, for URLs which use the
scheme `http`, `https`, or no scheme, one can optionally set up a type
server that maps type URLs to message definitions as follows:

* If no scheme is provided, `https` is assumed.
* An HTTP GET on the URL must yield a [google.protobuf.Type][]
value in binary format, or produce an error.
* Applications are allowed to cache lookup results based on the
URL, or have them precompiled into a binary to avoid any
lookup. Therefore, binary compatibility needs to be preserved
on changes to types. (Use versioned type names to manage
breaking changes.)

Note: this functionality is not currently available in the official
protobuf release, and it is not used for type URLs beginning with
type.googleapis.com.

Schemes other than `http`, `https` (or the empty scheme) might be
used with implementation specific semantics.

value bytes

Must be a valid serialized protocol buffer of the above specified type.

Timestamp

A Timestamp represents a point in time independent of any time zone or local
calendar, encoded as a count of seconds and fractions of seconds at
nanosecond resolution. The count is relative to an epoch at UTC midnight on
January 1, 1970, in the proleptic Gregorian calendar which extends the
Gregorian calendar backwards to year one.

All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
second table is needed for interpretation, using a [24-hour linear
smear](https://developers.google.com/time/smear).

The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
restricting to that range, we ensure that we can convert to and from [RFC
3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.

# Examples

Example 1: Compute Timestamp from POSIX `time()`.

Timestamp timestamp;
timestamp.set_seconds(time(NULL));
timestamp.set_nanos(0);

Example 2: Compute Timestamp from POSIX `gettimeofday()`.

struct timeval tv;
gettimeofday(&tv, NULL);

Timestamp timestamp;
timestamp.set_seconds(tv.tv_sec);
timestamp.set_nanos(tv.tv_usec * 1000);

Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.

FILETIME ft;
GetSystemTimeAsFileTime(&ft);
UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;

// A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
// is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
Timestamp timestamp;
timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));

Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.

long millis = System.currentTimeMillis();

Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
.setNanos((int) ((millis % 1000) * 1000000)).build();

Example 5: Compute Timestamp from Java `Instant.now()`.

Instant now = Instant.now();

Timestamp timestamp =
Timestamp.newBuilder().setSeconds(now.getEpochSecond())
.setNanos(now.getNano()).build();

Example 6: Compute Timestamp from current time in Python.

timestamp = Timestamp()
timestamp.GetCurrentTime()

# JSON Mapping

In JSON format, the Timestamp type is encoded as a string in the
[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
where {year} is always expressed using four digits while {month}, {day},
{hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
is required. A proto3 JSON serializer should always use UTC (as indicated by
"Z") when printing the Timestamp type and a proto3 JSON parser should be
able to accept both UTC and other timezones (as indicated by an offset).

For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
01:30 UTC on January 15, 2017.

In JavaScript, one can convert a Date object to this format using the
standard
[toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
method. In Python, a standard `datetime.datetime` object can be converted
to this format using
[`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
the Joda Time's [`ISODateTimeFormat.dateTime()`](
http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
) to obtain a formatter capable of generating timestamps in this format.

Field Type Description
seconds int64

Represents seconds of UTC time since Unix epoch
1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
9999-12-31T23:59:59Z inclusive.

nanos int32

Non-negative fractions of a second at nanosecond resolution. Negative
second values with fractions must still have non-negative nanos values
that count forward in time. Must be from 0 to 999,999,999
inclusive.

Credentials

Credentials defines credentials needed to perform authentication on a device.

Field Type Description
username string

password (one of)
cleartext string

hashed HashType

HashType

HashType defines the valid hash methods for data verification. UNSPECIFIED
should be treated an error.

Field Type Description
method HashType.HashMethod

hash bytes

Path

Path encodes a data tree path as a series of repeated strings, with
each element of the path representing a data tree node name and the
associated attributes.
Reference: gNMI Specification Section 2.2.2.

Field Type Description
origin string

Label to disambiguate path.

elem (repeated) PathElem

Elements of the path.

PathElem

PathElem encodes an element of a gNMI path, along with any attributes (keys)
that may be associated with it.
Reference: gNMI Specification Section 2.2.2.

Field Type Description
name string

The name of the element in the path.

key (repeated) PathElem.KeyEntry

Map of key (attribute) name to value.

Field Type Description
key string

value string

Name Number Description
UNSPECIFIED 0

SHA256 1

SHA512 2

MD5 3

L3Protocol

Generic Layer 3 Protocol enumeration.

Name Number Description
UNSPECIFIED 0

IPV4 1

IPV6 2

.google.protobuf.FileOptions.gnoi_version

The gNOI service semantic version.

Extension Type Base Number Description
gnoi_version string .google.protobuf.FileOptions 1002

The gNOI service semantic version.

Proto Type Notes C++ Java Python Go C# PHP Ruby
double double double float float64 double float Float
float float float float float32 float float Float
int32 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. int32 int int int32 int integer Bignum or Fixnum (as required)
int64 Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. int64 long int/long int64 long integer/string Bignum
uint32 Uses variable-length encoding. uint32 int int/long uint32 uint integer Bignum or Fixnum (as required)
uint64 Uses variable-length encoding. uint64 long int/long uint64 ulong integer/string Bignum or Fixnum (as required)
sint32 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. int32 int int int32 int integer Bignum or Fixnum (as required)
sint64 Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. int64 long int/long int64 long integer/string Bignum
fixed32 Always four bytes. More efficient than uint32 if values are often greater than 2^28. uint32 int int uint32 uint integer Bignum or Fixnum (as required)
fixed64 Always eight bytes. More efficient than uint64 if values are often greater than 2^56. uint64 long int/long uint64 ulong integer/string Bignum
sfixed32 Always four bytes. int32 int int int32 int integer Bignum or Fixnum (as required)
sfixed64 Always eight bytes. int64 long int/long int64 long integer/string Bignum
bool bool boolean boolean bool bool boolean TrueClass/FalseClass
string A string must always contain UTF-8 encoded or 7-bit ASCII text. string String str/unicode string string string String (UTF-8)
bytes May contain any arbitrary sequence of bytes. string ByteString str []byte ByteString string String (ASCII-8BIT)

Created by Siva Sivakumar / Roman Dodin / srl-labs