Skip to content

OpenTelemetry Collector

The Collector is the most general route: every backend on these pages accepts OTLP directly or has a Collector exporter, and vendor-specific work (renaming fields, extra redaction, routing, fan-out) belongs in the Collector rather than in ARTEX. Use the contrib distribution, or a vendor distribution that includes the components below.

  • Tails the three stream files with file_log, parses each line into attributes, takes the record time as the log timestamp and the severity from severity_text, and moves service.name, service.version, service.instance.id and, when present, artex.engagement_id onto the resource. It then lifts event_name and body into the log record’s own fields, which also replaces the parsed line in the body, so a field the redaction step removes from the attributes does not survive there.
  • Scrubs common secret-bearing query parameters again as defense in depth. ARTEX already redacts URLs before it writes them; this is for a site policy that is stricter.
  • Routes by artex.stream to three pipelines. The anthropic pipeline runs an allow-list redaction processor, so only the listed metadata leaves.
  • Fans the target and agent streams out to two exporters. Each exporter gets its own copy.
receivers:
file_log/artex:
include:
- ${env:ARTEX_AUDIT_DIR}/target.jsonl
- ${env:ARTEX_AUDIT_DIR}/agent.jsonl
- ${env:ARTEX_AUDIT_DIR}/anthropic.jsonl
start_at: beginning
storage: file_storage
operators:
- type: json_parser
parse_to: attributes
timestamp:
parse_from: attributes.time
layout_type: gotime
layout: "2006-01-02T15:04:05.999999999Z07:00"
severity:
parse_from: attributes.severity_text
# These describe the writer, so they go on the resource.
- type: move
from: attributes["service.name"]
to: resource["service.name"]
- type: move
from: attributes["service.version"]
to: resource["service.version"]
- type: move
from: attributes["service.instance.id"]
to: resource["service.instance.id"]
# Absent when serve runs without an engagement.
- type: move
if: 'attributes["artex.engagement_id"] != nil'
from: attributes["artex.engagement_id"]
to: resource["artex.engagement_id"]
extensions:
file_storage:
directory: /var/lib/otelcol/storage
create_directory: true
processors:
batch: {}
transform/scrub:
error_mode: ignore
log_statements:
- context: log
statements:
# time, severity_*, event_name and body are log record fields, not attributes.
# Lifting body also drops the parsed line, which would otherwise still carry every field.
- set(log.event_name, log.attributes["event_name"]) where log.attributes["event_name"] != nil
- set(log.body, log.attributes["body"]) where log.attributes["body"] != nil
- delete_matching_keys(log.attributes, "^(time|severity_number|severity_text|event_name|body)$")
- replace_pattern(log.attributes["url.full"], "([?&](token|key|code|session)=)[^&]*", "$${1}REDACTED")
- delete_key(log.attributes, "user_agent.original")
# Allow-list gate for the anthropic stream.
redaction/anthropic:
allow_all_keys: false
allowed_keys:
# The allow-list applies to resource attributes too.
- service.name
- service.version
- service.instance.id
- artex.engagement_id
- log.record.uid
- artex.schema_version
- artex.stream
- artex.seq
- trace_id
- span_id
- artex.exchange_id
- artex.anthropic.request_id
- gen_ai.provider.name
- gen_ai.operation.name
- gen_ai.request.model
- gen_ai.response.model
- gen_ai.response.id
- gen_ai.response.finish_reasons
- gen_ai.usage.input_tokens
- gen_ai.usage.output_tokens
- gen_ai.usage.cache_read.input_tokens
- gen_ai.usage.cache_creation.input_tokens
- artex.time_to_first_token_ns
- artex.duration_ns
- artex.prompt.hmac
- server.address
- http.request.method
- http.response.status_code
- url.template
- error.type
blocked_values:
- "sk-ant-[A-Za-z0-9_-]+"
summary: info
connectors:
routing/streams:
default_pipelines: [logs/target]
table:
- condition: log.attributes["artex.stream"] == "anthropic"
pipelines: [logs/anthropic]
- condition: log.attributes["artex.stream"] == "agent"
pipelines: [logs/agent]
exporters:
# Replace with your backend: otlphttp to any OTLP intake, or a vendor exporter.
otlphttp/backend:
endpoint: ${env:BACKEND_OTLP_ENDPOINT}
headers:
Authorization: ${env:BACKEND_AUTH_HEADER}
otlphttp/archive:
endpoint: ${env:ARCHIVE_OTLP_ENDPOINT}
service:
extensions: [file_storage]
pipelines:
logs/in:
receivers: [file_log/artex]
processors: [transform/scrub]
exporters: [routing/streams]
logs/target:
receivers: [routing/streams]
processors: [batch]
exporters: [otlphttp/backend, otlphttp/archive]
logs/agent:
receivers: [routing/streams]
processors: [batch]
exporters: [otlphttp/backend, otlphttp/archive]
logs/anthropic:
receivers: [routing/streams]
processors: [redaction/anthropic, batch]
exporters: [otlphttp/backend]

Environment:

Variable Example
ARTEX_AUDIT_DIR /artex/audit (the ARTEX audit directory mounted read-only)
BACKEND_OTLP_ENDPOINT Your backend’s OTLP/HTTP base URL
BACKEND_AUTH_HEADER The value of the Authorization header your backend expects
ARCHIVE_OTLP_ENDPOINT A second OTLP destination, for example a long-retention store
  • Replace otlphttp/backend with a vendor exporter where one is better suited (splunk_hec, elasticsearch, datadog), or keep OTLP for backends that take it natively. The vendor pages show which.
  • The artex.model_request record never holds prompt or completion text, only the keyed digest artex.prompt.hmac, and ARTEX masks credential headers before anything reaches disk. The anthropic gate is defense in depth against a field added later. It also strips the counters from the heartbeat, artex.audit_config and artex.audit_pruned records on that stream; add their keys if you alert on them there.
  • In replace_pattern, a capture group in the replacement must be written ${1}, and $ is escaped as $$ in Collector config, giving $${1}. A bare $$1REDACTED silently drops the match, because Go reads $1REDACTED as a group named 1REDACTED. The dry run caught this.
  • file_log is the current receiver name; filelog still works in 0.166.0 but logs a deprecation warning.
  • file_storage keeps read offsets across restarts, so the Collector resumes where it stopped instead of re-reading from the start. Name only the active files: rotated generations (target.jsonl.<UTC time>, older ones .gz) must not match the include patterns.
  • If Claude Code’s own telemetry (CLAUDE_CODE_ENABLE_TELEMETRY=1) goes to the same Collector, route on resource.attributes["service.name"] to separate claude-code from artex-cc.
  • With OTLP export (#395), ARTEX would send the same records to an otlp receiver on port 4318 instead of the Collector tailing the files, with the resource attributes already in place.
  • With metrics (#396), a prometheus receiver would scrape ARTEX’s /metrics, or ARTEX would push OTLP metrics to the same receiver.
  • With runner resource attributes (#392), Claude Code’s telemetry from the web UI runner would carry ARTEX’s artex.* resource attributes, so both services could be filtered together downstream.
  • otelcol-contrib validate --config=collector.yaml with otelcol-contrib 0.166.0: passed. A deliberately misspelled OTTL function failed validation, so the check does parse OTTL statements.
  • A run with the exporters replaced by debug against the schema’s golden fixtures (audit/testdata/), plus a record without artex.engagement_id: records were parsed with the right timestamps and severities, routed to the matching pipeline, came out with event_name and body as log record fields and the resource attributes on the resource, and the anthropic records kept only allow-listed attributes. The record without an engagement passed the guarded move without an error. JSON numbers arrive as doubles, as with any json_parser input.
  • Not run against a real backend.