Send Data

You can send logs, events, and metrics to the Cloud Monitoring service. To send data to the service, use a separate client class - SendClient. Create an instance of this class:

MonitoringServiceClient.send()

You can send logs, events, and metrics as:

  • binary data stream
  • SendResult logs(String source, InputStream data)

      Parameters:

      source: a source name validated using the following regular expression: [\w+\-_!.'()]{1,255}

      data: binary data stream in the utf-8 format. Has to be a valid JSON string.

  • binary data
  • SendResult logs(String source, byte[] data)

      Parameters:

      source: a source name validated using the following regular expression: [\w+\-_!.'()]{1,255}

      data: binary data in the utf-8 format. Has to be a valid JSON string.

  • records
  • SendResult logs(String source, LogRecord... records)

      Parameters:

      source: a source name validated using the following regular expression: [\w+\-_!.'()]{1,255}

      data: an array of LogRecord

  • records from a collection of objects. You can use LogRecord, EventRecord, MetricRecord, or your custom object. The system uses a Jackson mapper.
  • SendResult logs(String source, Collection<LogRecord> records)

      Parameters:

      source: a source name validated using the following regular expression: [\w+\-_!.'()]{1,255}

      data: an array of LogRecord

Note: We recommend you send data to the Cloud Monitoring service as a binary data stream using the InputStream methods. When you do this, data is sent in the HTTP stream that does not require data buffering.