Welcome, Guest Login

Support Center

Sending Annotation Events to Stackdriver

Last Updated: Mar 24, 2014 09:03PM EDT

Stackdriver supports ingesting and displaying annotation events, which place an arbitrary text note in the event timeline. To send these events, you can do the following:

  1. Create a new API key in your Stackdriver Account Settings
  2. Submit a Annotation Event with the API key

(Code snippets in this section are written in Python.)

To push an Annotation event to Stackdriver, you will POST a message to the event gateway and include the API key in the HTTP header.

Example Annotation Data:

Each Annotation has the following fields:

  • message - The contents of the message, in plain text.  Limited to 256 characters.
  • (Optional) annotated_by - The person or robot who the attribution should be attributed to
  • (Optional) level - one of INFO/WARN/ERROR, defaults to INFO if not supplied.  May affect display.
  • (Optional) instance_id - id of an instance that this event should be attached to, which will limit the contexts where this event is shown.
  • (Optional) event_epoch - Unix timestamp of where the event should appear in the timeline, defaults to now.  Be careful with this.
annotation_event = { 'message': 'About to cycle an instance on degraded hardware',
                 'annotated_by': 'Server Admin',
                 'level': 'INFO',
                 'instance_id':  'i-00000000',
                 'event_epoch': 1380908000

Example Annotation Event POST:

A complete working example of posting an annotation event:

import requests
import json

def submit_annotation_event():
    """ Submit an annotation event to Stackdriver """

    headers = { 'content-type': 'application/json',
                'x-stackdriver-apikey': '<YOURAPIKEY>' }

    annotation_event = { 'message': 'About to cycle an instance on degraded hardware',
                     'annotated_by': 'Server Admin',
                     'level': 'INFO',
                     'instance_id':  'i-00000000',
                     'event_epoch': 1380908000

    resp = requests.post( 'https://event-gateway.stackdriver.com/v1/annotationevent',

    assert resp.ok, 'Failed to submit annotation event.'

if __name__ == '__main__':

seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found