Repository navigation
feat(landing): log parsing guide #1578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
8a77b16
5d1cb98
5a5c325
a8109ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # debug.yaml: print parsed records instead of exporting them | ||
| exporters: | ||
| debug: | ||
| verbosity: detailed | ||
|
|
||
| service: | ||
| pipelines: | ||
| logs: | ||
| exporters: [debug] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| receivers: | ||
| file_log/app: | ||
| include: [/var/log/app/app.json.log] | ||
| operators: | ||
| - type: json_parser | ||
| timestamp: | ||
| parse_from: attributes.ts | ||
| layout_type: gotime | ||
| layout: "2006-01-02T15:04:05Z07:00" | ||
| severity: | ||
| parse_from: attributes.level | ||
| - type: move | ||
| from: attributes.msg | ||
| to: body |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| receivers: | ||
| file_log/worker: | ||
| include: [/var/log/worker/worker.log] | ||
| operators: | ||
| - type: key_value_parser | ||
| timestamp: | ||
| parse_from: attributes.time | ||
| layout_type: gotime | ||
| layout: "2006-01-02T15:04:05Z07:00" | ||
| severity: | ||
| parse_from: attributes.level |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| receivers: | ||
| file_log/java: | ||
| include: [/var/log/checkout/app.log] | ||
| multiline: | ||
| line_start_pattern: '^\d{4}-\d{2}-\d{2} ' | ||
| operators: | ||
| - type: regex_parser | ||
| regex: '(?s)^(?P<time>\S+ \S+) (?P<level>[A-Z]+)\s+\[(?P<thread>[^\]]+)\] (?P<logger>\S+) - (?P<message>.*)$' | ||
| timestamp: | ||
| parse_from: attributes.time | ||
| layout: "%Y-%m-%d %H:%M:%S,%L" | ||
| location: UTC | ||
| severity: | ||
| parse_from: attributes.level |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| receivers: | ||
| file_log/nginx: | ||
| include: [/var/log/nginx/access.log] | ||
| operators: | ||
| - type: regex_parser | ||
| regex: '^(?P<client_address>\S+) \S+ \S+ \[(?P<time_local>[^\]]+)\] "(?P<method>[A-Z]+) (?P<path>[^ ?"]+)[^ "]* HTTP/[0-9.]+" (?P<status>\d{3}) (?P<body_bytes>\d+|-) "[^"]*" "(?P<user_agent>[^"]*)"$' | ||
| timestamp: | ||
| parse_from: attributes.time_local | ||
| layout: "%d/%b/%Y:%H:%M:%S %z" | ||
| severity: | ||
| parse_from: attributes.status | ||
| overwrite_text: true | ||
| mapping: | ||
| info: | ||
| - min: 100 | ||
| max: 399 | ||
| warn: 4xx | ||
| error: 5xx | ||
| - type: move | ||
| from: attributes.client_address | ||
| to: attributes["client.address"] | ||
| on_error: send_quiet | ||
| - type: move | ||
| from: attributes.method | ||
| to: attributes["http.request.method"] | ||
| on_error: send_quiet | ||
| - type: move | ||
| from: attributes.path | ||
| to: attributes["url.path"] | ||
| on_error: send_quiet | ||
| - type: move | ||
| from: attributes.status | ||
| to: attributes["http.response.status_code"] | ||
| on_error: send_quiet | ||
| - type: move | ||
| from: attributes.body_bytes | ||
| to: attributes["http.response.body.size"] | ||
| on_error: send_quiet | ||
| - type: move | ||
| from: attributes.user_agent | ||
| to: attributes["user_agent.original"] | ||
| on_error: send_quiet | ||
| - type: remove | ||
| field: attributes.time_local | ||
| on_error: send_quiet | ||
|
|
||
| processors: | ||
| transform/nginx: | ||
| error_mode: ignore | ||
| log_statements: | ||
| - set(resource.attributes["service.name"], "nginx") | ||
| - delete_key(log.attributes, "http.response.body.size") where log.attributes["http.response.body.size"] == "-" | ||
| - set(log.attributes["http.response.status_code"], Int(log.attributes["http.response.status_code"])) where log.attributes["http.response.status_code"] != nil | ||
| - set(log.attributes["http.response.body.size"], Int(log.attributes["http.response.body.size"])) where log.attributes["http.response.body.size"] != nil | ||
| batch: {} | ||
|
|
||
| exporters: | ||
| otlphttp/maple: | ||
| endpoint: https://ingest.maple.dev | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Make the ingest endpoint match the Maple organization’s region. If a reader uses an EU organization’s ingest key, 🤖 Prompt for AI Agents |
||
| compression: gzip | ||
| headers: | ||
| x-maple-ingest-key: ${env:MAPLE_INGEST_KEY} | ||
|
|
||
| service: | ||
| pipelines: | ||
| logs: | ||
| receivers: [file_log/nginx] | ||
| processors: [transform/nginx, batch] | ||
| exporters: [otlphttp/maple] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| receivers: | ||
| file_log/syslog: | ||
| include: [/var/log/remote/hosts.log] | ||
| operators: | ||
| - type: syslog_parser | ||
| protocol: rfc5424 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| processors: | ||
| transform/parse: | ||
| error_mode: ignore | ||
| log_statements: | ||
| - merge_maps(log.attributes, ParseJSON(log.body), "upsert") where IsMatch(log.body, "^\\{") | ||
| - merge_maps(log.attributes, ParseKeyValue(log.body), "upsert") where IsMatch(log.body, "^time=") | ||
| - merge_maps(log.attributes, ExtractGrokPatterns(log.body, "%{HTTPD_COMBINEDLOG}", true), "upsert") where log.attributes["log.file.name"] == "access.log" |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -66,6 +66,13 @@ const investigationGuides = [ | |||||
| description: "Measure the right latency clock, isolate the slow requests, and trace a regression to the release and operation responsible.", | ||||||
| read: "14 min", | ||||||
| }, | ||||||
| { | ||||||
| href: "/guides/log-parsing", | ||||||
| label: "Logs", | ||||||
| title: "Log parsing: from raw lines to structured fields", | ||||||
| description: "Parse syslog, nginx, JSON and multiline logs with regex, grok and Linux commands, then in the OpenTelemetry Collector.", | ||||||
| read: "14 min", | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Use the same reading time as the guide page. The index card shows Proposed fix- read: "14 min",
+ read: "10 min",📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| }, | ||||||
| ]; | ||||||
|
|
||||||
| const fieldNotes = (await getCollection("blog") as BlogPost[]) | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Preserve access-log records across Collector restarts.
The filelog receiver defaults to
start_at: endand keeps offsets only in memory. If Nginx writes records while the Collector is stopped, the restarted Collector skips those records. A pre-existing sample file is also skipped until new lines arrive. Setstart_at: beginningand configure persistent filelog offset storage so the receiver can catch up without rereading the whole file on each restart. (raw.githubusercontent.com)🤖 Prompt for AI Agents