数据模型附录
注意:本文档不是规范,而是为支持 Logs 数据模型规范而提供的。此处提供的示例纯粹用于演示目的,并非详尽或规范性;如果需要精确的详细信息,请参阅相应的导出器文档。
附录 A. 示例映射
本节包含将其他事件和日志格式映射到此数据模型的示例。
RFC5424 Syslog
| 属性 | 类型 | 描述 | 映射到统一模型字段 |
| TIMESTAMP | Timestamp | 事件发生的时间,由源时钟测量。 | Timestamp |
| SEVERITY | enum | 定义事件的重要性。示例:Debug | Severity |
| FACILITY | enum | 描述事件的来源。预定义的 Unix 进程列表。是事件源标识的一部分。示例:mail system | Attributes["syslog.facility"] |
| VERSION | number | 元数据:协议版本,与事件正交。 | Attributes["syslog.version"] |
| HOSTNAME | 字符串 | 描述事件发生的地点。可能的值包括 FQDN、IP 地址等。 | Resource["host.name"] |
| APP-NAME | 字符串 | 用户定义的应用程序名称。是事件源标识的一部分。 | Resource["service.name"] |
| PROCID | 字符串 | 未明确定义。可用作协议操作目的的元数据字段,或可能是事件源标识的一部分。 | Attributes["syslog.procid"] |
| MSGID | 字符串 | 定义事件的类型。是事件源标识的一部分。示例:“TCPIN” | Attributes["syslog.msgid"] |
| STRUCTURED-DATA | map | 取决于 SDID 的各种用例 可以描述事件源标识。 可以包含描述事件特定发生的数据。 可以是元数据,例如时间戳值的质量。 | SDID origin.swVersion 映射到 Resource["service.version"]。SDID origin.ip 映射到 Attributes["client.address"]。其余 SDID -> Attributes["syslog.*"] |
| MSG | 字符串 | 关于事件的自由格式文本消息。通常是人类可读的。 | Body |
Windows Event Log
| 属性 | 类型 | 描述 | 映射到统一模型字段 |
| TimeCreated | Timestamp | 记录事件的时间戳。 | Timestamp |
| Level | enum | 包含事件的严重级别。 | Severity |
| Computer | 字符串 | 事件发生的计算机的名称。 | Resource["host.name"] |
| EventID | uint | 提供程序用于标识事件的标识符。 | Attributes["winlog.event_id"] |
| Message | 字符串 | 消息字符串。 | Body |
| Rest of the fields. | any | 事件中的所有其他字段。 | Attributes["winlog.*"] |
SignalFx Events
| 字段 | 类型 | 描述 | 映射到统一模型字段 |
| Timestamp | Timestamp | 事件发生的时间,由源时钟测量。 | Timestamp |
| EventType | 字符串 | 简短的机器可理解的字符串,描述事件类型。SignalFx 特有的概念。无命名空间。示例:k8s Event Reason 字段。 | Attributes["com.splunk.signalfx.event_type"] |
| Category | enum | 描述事件的来源和原因。SignalFx 特有的概念。示例:AGENT。 | Attributes["com.splunk.signalfx.event_category"] |
| Dimensions | map<string, string> | 有助于与 EventType 和 Category 一起定义事件源的标识。来自同一事件源的事件的多个发生可能随时间发生,它们都具有 Dimensions 的值。 | Resource |
| Properties | map<string, any> | 关于特定事件发生情况的附加信息。与 Dimensions(对于特定事件源固定)不同,Properties 可以拥有来自同一事件源的每个事件发生的具有不同值。 | Attributes |
Splunk HEC
我们将 HEC 映射到统一模型
| 字段 | 类型 | 描述 | 映射到统一模型字段 |
| time | numeric, string | 事件时间,以 epoch 时间格式,单位为秒。 | Timestamp |
| host | 字符串 | 要分配给事件数据的 host 值。这通常是您从中发送数据的客户端的 host 名称。 | Resource["host.name"] |
| 源代码 | 字符串 | 要分配给事件数据的 source 值。例如,如果您从正在开发的应用程序发送数据,您可以将此键设置为应用程序的名称。 | Resource["com.splunk.source"] |
| sourcetype | 字符串 | 要分配给事件数据的 sourcetype 值。 | Resource["com.splunk.sourcetype"] |
| event | any | 事件原始正文的 JSON 表示。它可以是字符串、数字、字符串数组、数字数组、JSON 对象或 JSON 数组。 | Body |
| fields | map<string, any> | 指定一个包含显式自定义字段的 JSON 对象。 | Attributes |
| index | 字符串 | 事件数据要索引的索引名称。如果您使用的 token 设置了 indexes 参数,则在此处指定的索引必须在允许的索引列表中。 | Attributes["com.splunk.index"] |
当从统一模型映射到 HEC 时,我们应用此附加映射
| Unified model element | 类型 | 描述 | 映射到 HEC |
| SeverityText | 字符串 | 事件的严重性,作为人类可读的字符串。 | fields['otel.log.severity.text'] |
| SeverityNumber | 字符串 | 事件的严重性,作为数字。 | fields['otel.log.severity.number'] |
| 名称 | 字符串 | 简短的事件标识符,不包含可变部分。 | fields['otel.log.name'] |
| TraceId | 字符串 | 请求的 trace id。 | fields['trace_id'] |
| SpanId | 字符串 | 请求的 span id。 | fields['span_id'] |
| TraceFlags | 字符串 | W3C trace flags。 | fields['trace_flags'] |
Log4j
| 字段 | 类型 | 描述 | 映射到统一模型字段 |
| Instant | Timestamp | 事件发生的时间,由源时钟测量。 | Timestamp |
| Level | enum | Log level。 | Severity |
| Message | 字符串 | Human readable message。 | Body |
| All other fields | any | Structured data。 | Attributes |
Zap
| 字段 | 类型 | 描述 | 映射到统一模型字段 |
| ts | Timestamp | 事件发生的时间,由源时钟测量。 | Timestamp |
| level | enum | Logging level。 | Severity |
| caller | 字符串 | Calling function 的文件名和行号。 | Attributes, key=TBD |
| msg | 字符串 | Human readable message。 | Body |
| All other fields | any | Structured data。 | Attributes |
Apache HTTP Server access log
| 字段 | 类型 | 描述 | 映射到统一模型字段 |
| %t | Timestamp | 事件发生的时间,由源时钟测量。 | Timestamp |
| %a | 字符串 | Client address | Attributes["network.peer.address"] |
| %A | 字符串 | Server address | Attributes["network.local.address"] |
| %h | 字符串 | Client hostname。 | Attributes["client.address"] |
| %m | 字符串 | The request method。 | Attributes["http.request.method"] |
| %v,%p,%U,%q | 字符串 | 可以组合成 URL 的多个字段。 | Attributes["url.full"] |
| %>s | 字符串 | Response status。 | Attributes["http.response.status_code"] |
| All other fields | any | Structured data。 | Attributes, key=TBD |
CloudTrail Log Event
| 字段 | 类型 | 描述 | 映射到统一模型字段 |
| eventTime | 字符串 | 请求的时间(协调世界时 UTC)。 | Timestamp |
| eventSource | 字符串 | 发出请求的服务。此名称通常是服务名称的简短形式,无空格,后跟 .amazonaws.com。 | Resource["service.name"]? |
| awsRegion | 字符串 | 请求的 AWS 区域,例如 us-east-2。 | Resource["cloud.region"] |
| sourceIPAddress | 字符串 | 发出请求的 IP 地址。 | Attributes["client.address"] |
| errorCode | 字符串 | 如果请求返回错误,则为 AWS 服务错误。 | Attributes["cloudtrail.error_code"] |
| errorMessage | 字符串 | 如果请求返回错误,则为错误的描述。 | Body |
| All other fields | * | Attributes["cloudtrail.*"] |
Google Cloud Logging
| 字段 | 类型 | 描述 | 映射到统一模型字段 |
|---|---|---|---|
| timestamp | 字符串 | 日志条目所描述事件发生的时间。 | Timestamp |
| resource | MonitoredResource | 生成此日志条目的被监控资源。 | Resource |
| log_name | 字符串 | log_name 字段的 URL 编码的 LOG_ID 后缀标识了此条目属于哪个日志流。 | Attributes[“gcp.log_name”] |
| json_payload | google.protobuf.Struct | 日志条目负载,表示为 JSON 对象表示的结构。 | Body |
| proto_payload | google.protobuf.Any | 日志条目负载,表示为协议缓冲区。 | Body |
| text_payload | 字符串 | 日志条目负载,表示为 Unicode 字符串(UTF-8)。 | Body |
| severity | LogSeverity | 日志条目的严重性。 | Severity |
| trace | 字符串 | 日志条目关联的 trace,如果有的话。 | TraceId |
| span_id | 字符串 | 日志条目关联的 trace 中的 span ID。 | SpanId |
| labels | map<string,string> | 一组用户定义的(键,值)数据,提供关于日志条目的附加信息。 | Attributes |
| http_request | HttpRequest | 日志条目关联的 HTTP 请求,如果有的话。 | Attributes[“gcp.http_request”] |
| trace_sampled | 布尔值 | 日志条目关联的 trace 的采样决策。 | TraceFlags.SAMPLED |
| All other fields | Attributes[“gcp.*”] |
Elastic Common Schema
| 字段 | 类型 | 描述 | 映射到统一模型字段 |
| @timestamp | datetime | 记录事件的时间 | Timestamp |
| message | 字符串 | Any type of message | Body |
| labels | key/value | Arbitrary labels related to the event | Attributes[*] |
| tags | array of string | List of values related to the event | ? |
| trace.id | 字符串 | Trace ID | TraceId |
| span.id* | 字符串 | Span ID | SpanId |
| agent.ephemeral_id | 字符串 | Ephemeral ID created by agent | **Resource |
| agent.id | 字符串 | Unique identifier of this agent | **Resource |
| agent.name | 字符串 | Name given to the agent | Resource["telemetry.sdk.name"] |
| agent.type | 字符串 | Type of agent | Resource["telemetry.sdk.language"] |
| agent.version | 字符串 | Version of agent | Resource["telemetry.sdk.version"] |
| source.ip, client.ip | 字符串 | 发出请求的 IP 地址。 | Attributes["client.address"] |
| cloud.account.id | 字符串 | ID of the account in the given cloud | Resource["cloud.account.id"] |
| cloud.availability_zone | 字符串 | Availability zone in which this host is running. | Resource["cloud.zone"] |
| cloud.instance.id | 字符串 | Instance ID of the host machine. | **Resource |
| cloud.instance.name | 字符串 | Instance name of the host machine. | **Resource |
| cloud.machine.type | 字符串 | Machine type of the host machine. | **Resource |
| cloud.provider | 字符串 | Name of the cloud provider. Example values are aws, azure, gcp, or digitalocean. | Resource["cloud.provider"] |
| cloud.region | 字符串 | Region in which this host is running. | Resource["cloud.region"] |
| cloud.image.id* | 字符串 | Resource["host.image.name"] | |
| container.id | 字符串 | Unique container id | Resource["container.id"] |
| container.image.name | 字符串 | Name of the image the container was built on. | Resource["container.image.name"] |
| container.image.tag | Array of string | Container image tags。 | **Resource |
| container.labels | key/value | Image labels。 | Attributes[*] |
| container.name | 字符串 | Container name。 | Resource["container.name"] |
| container.runtime | 字符串 | Runtime managing this container. Example: "docker" | **Resource |
| destination.address | 字符串 | Destination address for the event | Attributes["destination.address"] |
| error.code | 字符串 | Error code describing the error. | Attributes["error.code"] |
| error.id | 字符串 | Unique identifier for the error. | Attributes["error.id"] |
| error.message | 字符串 | Error message。 | Attributes["error.message"] |
| error.stack_trace | 字符串 | The stack trace of this error in plain text。 | Attributes["error.stack_trace] |
| host.architecture | 字符串 | Operating system architecture | **Resource |
| host.domain | 字符串 | Name of the domain of which the host is a member。 For example, on Windows this could be the host’s Active Directory domain or NetBIOS domain name. For Linux this could be the domain of the host’s LDAP provider。 | **Resource |
| host.name | 字符串 | Hostname of the host。 It normally contains what the hostname command returns on the host machine。 | Resource["host.name"] |
| host.id | 字符串 | Unique host id。 | Resource["host.id"] |
| host.ip | Array of string | Host IP | Resource["host.ip"] |
| host.mac | array of string | MAC addresses of the host | Resource["host.mac"] |
| host.name | 字符串 | Name of the host。 It may contain what hostname returns on Unix systems, the fully qualified, or a name specified by the user。 | Resource["host.name"] |
| host.type | 字符串 | Type of host。 | Resource["host.type"] |
| host.uptime | 字符串 | Seconds the host has been up。 | ? |
| service.ephemeral_id | 字符串 | Ephemeral identifier of this service | **Resource |
| service.id | 字符串 | Unique identifier of the running service. If the service is comprised of many nodes, the service.id should be the same for all nodes。 | **Resource |
| service.name | 字符串 | Name of the service data is collected from。 | Resource["service.name"] |
| service.node.name | 字符串 | Specific node serving that service | Resource["service.instance.id"] |
| service.state | 字符串 | Current state of the service。 | Attributes["service.state"] |
| service.type | 字符串 | The type of the service data is collected from。 | **Resource |
| service.version | 字符串 | Version of the service the data was collected from。 | Resource["service.version"] |
* Not yet formalized into ECS。
** A resource that doesn’t exist in the OpenTelemetry resource semantic convention。
This is a selection of the most relevant fields. See for the full reference for an exhaustive list。
附录 B: SeverityNumber 示例映射
| Syslog | WinEvtLog | Log4j | Zap | java.util.logging | .NET (Microsoft.Extensions.Logging) | SeverityNumber |
|---|---|---|---|---|---|---|
| TRACE | FINEST | LogLevel.Trace | TRACE | |||
| Debug | Verbose | DEBUG | Debug | FINER | LogLevel.Debug | DEBUG |
| FINE | DEBUG2 | |||||
| CONFIG | DEBUG3 | |||||
| Informational | Information | INFO | Info | INFO | LogLevel.Information | INFO |
| Notice | INFO2 | |||||
| 警告 | 警告 | WARN | Warn | WARNING | LogLevel.Warning | WARN |
| Error | Error | ERROR | Error | SEVERE | LogLevel.Error | ERROR |
| 严重 | 严重 | Dpanic | ERROR2 | |||
| Alert | Panic | ERROR3 | ||||
| Emergency | FATAL | Fatal | LogLevel.Critical | FATAL |