logs.proto 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. // Copyright 2020, OpenTelemetry Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package opentelemetry.proto.logs.v1;
  16. import "opentelemetry/proto/common/v1/common.proto";
  17. import "opentelemetry/proto/resource/v1/resource.proto";
  18. option csharp_namespace = "OpenTelemetry.Proto.Logs.V1";
  19. option java_multiple_files = true;
  20. option java_package = "io.opentelemetry.proto.logs.v1";
  21. option java_outer_classname = "LogsProto";
  22. option go_package = "go.opentelemetry.io/proto/otlp/logs/v1";
  23. // LogsData represents the logs data that can be stored in a persistent storage,
  24. // OR can be embedded by other protocols that transfer OTLP logs data but do not
  25. // implement the OTLP protocol.
  26. //
  27. // The main difference between this message and collector protocol is that
  28. // in this message there will not be any "control" or "metadata" specific to
  29. // OTLP protocol.
  30. //
  31. // When new fields are added into this message, the OTLP request MUST be updated
  32. // as well.
  33. message LogsData {
  34. // An array of ResourceLogs.
  35. // For data coming from a single resource this array will typically contain
  36. // one element. Intermediary nodes that receive data from multiple origins
  37. // typically batch the data before forwarding further and in that case this
  38. // array will contain multiple elements.
  39. repeated ResourceLogs resource_logs = 1;
  40. }
  41. // A collection of ScopeLogs from a Resource.
  42. message ResourceLogs {
  43. reserved 1000;
  44. // The resource for the logs in this message.
  45. // If this field is not set then resource info is unknown.
  46. opentelemetry.proto.resource.v1.Resource resource = 1;
  47. // A list of ScopeLogs that originate from a resource.
  48. repeated ScopeLogs scope_logs = 2;
  49. // The Schema URL, if known. This is the identifier of the Schema that the resource data
  50. // is recorded in. Notably, the last part of the URL path is the version number of the
  51. // schema: http[s]://server[:port]/path/<version>. To learn more about Schema URL see
  52. // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
  53. // This schema_url applies to the data in the "resource" field. It does not apply
  54. // to the data in the "scope_logs" field which have their own schema_url field.
  55. string schema_url = 3;
  56. }
  57. // A collection of Logs produced by a Scope.
  58. message ScopeLogs {
  59. // The instrumentation scope information for the logs in this message.
  60. // Semantically when InstrumentationScope isn't set, it is equivalent with
  61. // an empty instrumentation scope name (unknown).
  62. opentelemetry.proto.common.v1.InstrumentationScope scope = 1;
  63. // A list of log records.
  64. repeated LogRecord log_records = 2;
  65. // The Schema URL, if known. This is the identifier of the Schema that the log data
  66. // is recorded in. Notably, the last part of the URL path is the version number of the
  67. // schema: http[s]://server[:port]/path/<version>. To learn more about Schema URL see
  68. // https://opentelemetry.io/docs/specs/otel/schemas/#schema-url
  69. // This schema_url applies to all logs in the "logs" field.
  70. string schema_url = 3;
  71. }
  72. // Possible values for LogRecord.SeverityNumber.
  73. enum SeverityNumber {
  74. // UNSPECIFIED is the default SeverityNumber, it MUST NOT be used.
  75. SEVERITY_NUMBER_UNSPECIFIED = 0;
  76. SEVERITY_NUMBER_TRACE = 1;
  77. SEVERITY_NUMBER_TRACE2 = 2;
  78. SEVERITY_NUMBER_TRACE3 = 3;
  79. SEVERITY_NUMBER_TRACE4 = 4;
  80. SEVERITY_NUMBER_DEBUG = 5;
  81. SEVERITY_NUMBER_DEBUG2 = 6;
  82. SEVERITY_NUMBER_DEBUG3 = 7;
  83. SEVERITY_NUMBER_DEBUG4 = 8;
  84. SEVERITY_NUMBER_INFO = 9;
  85. SEVERITY_NUMBER_INFO2 = 10;
  86. SEVERITY_NUMBER_INFO3 = 11;
  87. SEVERITY_NUMBER_INFO4 = 12;
  88. SEVERITY_NUMBER_WARN = 13;
  89. SEVERITY_NUMBER_WARN2 = 14;
  90. SEVERITY_NUMBER_WARN3 = 15;
  91. SEVERITY_NUMBER_WARN4 = 16;
  92. SEVERITY_NUMBER_ERROR = 17;
  93. SEVERITY_NUMBER_ERROR2 = 18;
  94. SEVERITY_NUMBER_ERROR3 = 19;
  95. SEVERITY_NUMBER_ERROR4 = 20;
  96. SEVERITY_NUMBER_FATAL = 21;
  97. SEVERITY_NUMBER_FATAL2 = 22;
  98. SEVERITY_NUMBER_FATAL3 = 23;
  99. SEVERITY_NUMBER_FATAL4 = 24;
  100. }
  101. // LogRecordFlags represents constants used to interpret the
  102. // LogRecord.flags field, which is protobuf 'fixed32' type and is to
  103. // be used as bit-fields. Each non-zero value defined in this enum is
  104. // a bit-mask. To extract the bit-field, for example, use an
  105. // expression like:
  106. //
  107. // (logRecord.flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK)
  108. //
  109. enum LogRecordFlags {
  110. // The zero value for the enum. Should not be used for comparisons.
  111. // Instead use bitwise "and" with the appropriate mask as shown above.
  112. LOG_RECORD_FLAGS_DO_NOT_USE = 0;
  113. // Bits 0-7 are used for trace flags.
  114. LOG_RECORD_FLAGS_TRACE_FLAGS_MASK = 0x000000FF;
  115. // Bits 8-31 are reserved for future use.
  116. }
  117. // A log record according to OpenTelemetry Log Data Model:
  118. // https://github.com/open-telemetry/oteps/blob/main/text/logs/0097-log-data-model.md
  119. message LogRecord {
  120. reserved 4;
  121. // time_unix_nano is the time when the event occurred.
  122. // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
  123. // Value of 0 indicates unknown or missing timestamp.
  124. fixed64 time_unix_nano = 1;
  125. // Time when the event was observed by the collection system.
  126. // For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK)
  127. // this timestamp is typically set at the generation time and is equal to Timestamp.
  128. // For events originating externally and collected by OpenTelemetry (e.g. using
  129. // Collector) this is the time when OpenTelemetry's code observed the event measured
  130. // by the clock of the OpenTelemetry code. This field MUST be set once the event is
  131. // observed by OpenTelemetry.
  132. //
  133. // For converting OpenTelemetry log data to formats that support only one timestamp or
  134. // when receiving OpenTelemetry log data by recipients that support only one timestamp
  135. // internally the following logic is recommended:
  136. // - Use time_unix_nano if it is present, otherwise use observed_time_unix_nano.
  137. //
  138. // Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
  139. // Value of 0 indicates unknown or missing timestamp.
  140. fixed64 observed_time_unix_nano = 11;
  141. // Numerical value of the severity, normalized to values described in Log Data Model.
  142. // [Optional].
  143. SeverityNumber severity_number = 2;
  144. // The severity text (also known as log level). The original string representation as
  145. // it is known at the source. [Optional].
  146. string severity_text = 3;
  147. // A value containing the body of the log record. Can be for example a human-readable
  148. // string message (including multi-line) describing the event in a free form or it can
  149. // be a structured data composed of arrays and maps of other values. [Optional].
  150. opentelemetry.proto.common.v1.AnyValue body = 5;
  151. // Additional attributes that describe the specific event occurrence. [Optional].
  152. // Attribute keys MUST be unique (it is not allowed to have more than one
  153. // attribute with the same key).
  154. repeated opentelemetry.proto.common.v1.KeyValue attributes = 6;
  155. uint32 dropped_attributes_count = 7;
  156. // Flags, a bit field. 8 least significant bits are the trace flags as
  157. // defined in W3C Trace Context specification. 24 most significant bits are reserved
  158. // and must be set to 0. Readers must not assume that 24 most significant bits
  159. // will be zero and must correctly mask the bits when reading 8-bit trace flag (use
  160. // flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK). [Optional].
  161. fixed32 flags = 8;
  162. // A unique identifier for a trace. All logs from the same trace share
  163. // the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes OR
  164. // of length other than 16 bytes is considered invalid (empty string in OTLP/JSON
  165. // is zero-length and thus is also invalid).
  166. //
  167. // This field is optional.
  168. //
  169. // The receivers SHOULD assume that the log record is not associated with a
  170. // trace if any of the following is true:
  171. // - the field is not present,
  172. // - the field contains an invalid value.
  173. bytes trace_id = 9;
  174. // A unique identifier for a span within a trace, assigned when the span
  175. // is created. The ID is an 8-byte array. An ID with all zeroes OR of length
  176. // other than 8 bytes is considered invalid (empty string in OTLP/JSON
  177. // is zero-length and thus is also invalid).
  178. //
  179. // This field is optional. If the sender specifies a valid span_id then it SHOULD also
  180. // specify a valid trace_id.
  181. //
  182. // The receivers SHOULD assume that the log record is not associated with a
  183. // span if any of the following is true:
  184. // - the field is not present,
  185. // - the field contains an invalid value.
  186. bytes span_id = 10;
  187. // A unique identifier of event category/type.
  188. // All events with the same event_name are expected to conform to the same
  189. // schema for both their attributes and their body.
  190. //
  191. // Recommended to be fully qualified and short (no longer than 256 characters).
  192. //
  193. // Presence of event_name on the log record identifies this record
  194. // as an event.
  195. //
  196. // [Optional].
  197. //
  198. // Status: [Development]
  199. string event_name = 12;
  200. }