VictoriaLogs supports both client open-telemetry SDK and collector .

Client SDK #

Specify EndpointURL for http-exporter builder to /insert/opentelemetry/v1/logs.

Consider the following example for Go SDK:

      logExporter, err := otlploghttp.New(ctx,
  otlploghttp.WithEndpointURL("http://victorialogs:9428/insert/opentelemetry/v1/logs"),
)
    

VictoriaLogs treats all the resource labels as log stream fields . The list of log stream fields can be overridden via VL-Stream-Fields HTTP header if needed. For example, the following config uses only host and app labels as log stream fields, while the remaining labels are stored as regular log fields :

      logExporter, err := otlploghttp.New(ctx,
  otlploghttp.WithEndpointURL("http://victorialogs:9428/insert/opentelemetry/v1/logs"),
  otlploghttp.WithHeaders(map[string]string{
    "VL-Stream-Fields": "host,app",
  }),
)
    

VictoriaLogs uses the log body as the log message . The log message can be taken from other fields via VL-Msg-Field HTTP header if needed. In this case the log body is stored in the body field Available from v1.54.0 . For example, the following config uses the msg log record attribute as the log message, and falls back to the log body if the msg attribute is missing:

      logExporter, err := otlploghttp.New(ctx,
  otlploghttp.WithEndpointURL("http://victorialogs:9428/insert/opentelemetry/v1/logs"),
  otlploghttp.WithHeaders(map[string]string{
    "VL-Msg-Field": "msg,body",
  }),
)
    

VictoriaLogs supports other HTTP headers - see the list here .

The ingested log entries can be queried according to these docs .

Collector configuration #

VictoriaLogs supports receiving logs from the following OpenTelemetry collectors:

Elasticsearch #

      exporters:
  elasticsearch:
    endpoints:
      - http://victorialogs:9428/insert/elasticsearch
receivers:
  filelog:
    include: [/tmp/logs/*.log]
    resource:
      region: us-east-1
service:
  pipelines:
    logs:
      receivers: [filelog]
      exporters: [elasticsearch]
    

If Elasticsearch stores the log message in the field other than _msg , then it can be moved to _msg field by using the VL-Msg-Field HTTP header. For example, if the log message is stored in the Body field, then it can be moved to _msg field via the following config:

      exporters:
  elasticsearch:
    endpoints:
      - http://victorialogs:9428/insert/elasticsearch
    headers:
      VL-Msg-Field: Body
    

VictoriaLogs supports other HTTP headers - see the list here .

OpenTelemetry #

Specify logs endpoint for OTLP/HTTP exporter in configuration file for sending the collected logs to VictoriaLogs:

      exporters:
  otlphttp:
    logs_endpoint: http://localhost:9428/insert/opentelemetry/v1/logs
    

VictoriaLogs supports various HTTP headers, which can be used during data ingestion - see the list here . These headers can be passed to OpenTelemetry exporter config via headers options. For example, the following config instructs ignoring foo and bar fields during data ingestion:

      exporters:
  otlphttp:
    logs_endpoint: http://localhost:9428/insert/opentelemetry/v1/logs
    headers:
      VL-Ignore-Fields: foo,bar
    

Field names #

By default, VictoriaLogs stores resource attributes and log record attributes without a prefix. This works well in most cases, but attributes from different sources may cause field name collisions. See this issue . So it is recommended to set the -opentelemetry.consistentPrefix command-line flag Available from the next release for new installations at every component, which accepts OpenTelemetry data (VictoriaLogs, vlinsert or vlagent). The flag is disabled by default for compatibility with already ingested logs, since it changes field names.

For example, the following OpenTelemetry log record (shown in JSON format for readability):

      {
  "resourceLogs": [{
    "resource": {"attributes": [{"key": "service.name", "value": {"stringValue": "checkout"}}]},
    "scopeLogs": [{
      "scope": {"name": "payment", "version": "2.4.1", "attributes": [{"key": "lib.language", "value": {"stringValue": "go"}}]},
      "logRecords": [{
        "severityNumber": 17,
        "severityText": "ERROR",
        "traceId": "5b8efff798038103d269b633813fc60c",
        "spanId": "eee19b7ec3c1b174",
        "body": {"stringValue": "payment failed"},
        "attributes": [{"key": "http.method", "value": {"stringValue": "POST"}}]
      }]
    }]
  }]
}
    

is stored with the following fields by default:

      {
  "service.name": "checkout",
  "scope.name": "payment",
  "scope.version": "2.4.1",
  "scope.attributes.lib.language": "go",
  "_msg": "payment failed",
  "http.method": "POST",
  "trace_id": "5b8efff798038103d269b633813fc60c",
  "span_id": "eee19b7ec3c1b174",
  "severity_number": "17",
  "severity_text": "ERROR"
}
    

and with the following fields when -opentelemetry.consistentPrefix is set:

      {
  "resource.attribute.service.name": "checkout",
  "scope.name": "payment",
  "scope.version": "2.4.1",
  "scope.attribute.lib.language": "go",
  "_msg": "payment failed",
  "log.attribute.http.method": "POST",
  "trace_id": "5b8efff798038103d269b633813fc60c",
  "span_id": "eee19b7ec3c1b174",
  "severity_number": "17",
  "severity_text": "ERROR"
}
    

Fields of a key-value log body are stored as <key> by default and as body.<key> with the flag.

When the flag is set, HTTP headers such as VL-Stream-Fields, VL-Msg-Field and VL-Ignore-Fields must refer to the prefixed field names, for example VL-Msg-Field: log.attribute.msg,body.

The flag also helps to align field names with VictoriaMetrics and VictoriaTraces later, when they follow the same naming convention for OpenTelemetry data. See this issue .

See also: