-
Notifications
You must be signed in to change notification settings - Fork 94
Add Microsoft Common Schema log processor #2788
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
Open
lalitb
wants to merge
6
commits into
open-telemetry:main
Choose a base branch
from
lalitb:split/microsoft-common-schema-processor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0c9b067
Add Microsoft Common Schema processor
lalitb 364e87f
Add Common Schema guide shape test
lalitb c43a975
Fix Common Schema review findings
lalitb 626e4ca
Preallocate Common Schema encode buffer
lalitb 652f8ca
Merge branch 'main' into split/microsoft-common-schema-processor
lalitb 510e3b7
Address common schema processor review comments
lalitb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...crates/contrib-nodes/src/processors/microsoft_common_schema_processor/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| # Microsoft Common Schema Processor | ||
|
|
||
| URN: `urn:microsoft:processor:common_schema_otel_logs` | ||
|
|
||
| This processor promotes decoded Microsoft Common Schema log attributes into typed | ||
| OTLP log fields. It is intended for pipelines where the producer is known to | ||
| emit Microsoft Common Schema records, such as the Linux `user_events` receiver | ||
| using `event_header` format. | ||
|
|
||
| ## Configuration | ||
|
|
||
| The processor currently has no options: | ||
|
|
||
| ```yaml | ||
| processors: | ||
| common_schema: | ||
| kind: "urn:microsoft:processor:common_schema_otel_logs" | ||
| config: {} | ||
| ``` | ||
|
|
||
| Unknown configuration fields are rejected. | ||
|
|
||
| ## Promotion Rules | ||
|
|
||
| Only records with `__csver__ == 0x400` and `PartB._typeName == "Log"` are | ||
| promoted. Other records are forwarded unchanged. | ||
|
|
||
| | Common Schema attribute | OTLP destination | | ||
| | --- | --- | | ||
| | `PartA.time` | `time_unix_nano` | | ||
| | `PartA.name` | `event_name` when `PartB.name` is absent | | ||
| | `PartB.name` | `event_name` | | ||
| | `PartA.ext_dt_traceId` | `trace_id` | | ||
| | `PartA.ext_dt_spanId` | `span_id` | | ||
| | `PartA.ext_dt_traceFlags` | `flags` | | ||
| | `PartA.ext_cloud_role` | `service.name` attribute | | ||
| | `PartA.ext_cloud_roleInstance` | `service.instance.id` attribute | | ||
| | `PartB.body` | `body` | | ||
| | `PartB.severityNumber` | `severity_number` | | ||
| | `PartB.severityText` | `severity_text` | | ||
| | `PartC.*` | Attribute with the `PartC.` prefix removed | | ||
|
|
||
| `PartB.name` takes precedence over `PartA.name`. Severity values above the OTLP | ||
| range are clamped to `24`; severity `0` is preserved as OTLP `UNSPECIFIED`. | ||
| Recognized `PartA.*` and `PartB.*` fields are removed after promotion. Unknown | ||
| `PartA.*` and `PartB.*` fields are preserved with their original names. | ||
|
|
||
| Malformed trace and span IDs are kept as attributes named `trace.id` and | ||
| `span.id` instead of being promoted to typed ID fields. | ||
|
|
||
| ## Arrow Conversion Cost | ||
|
|
||
| The current implementation promotes records by converting payloads to OTLP proto | ||
| bytes and mutating OTLP `LogsData` / `LogRecord` values. Incoming Arrow batches | ||
| that do not contain a `__csver__` log attribute are forwarded without this | ||
| conversion. Arrow batches that contain a `__csver__` log attribute still pay the | ||
| Arrow-to-OTLP conversion cost. If no records are promoted after inspection, the | ||
| original Arrow payload is forwarded unchanged. | ||
|
|
||
| This processor should be wired only where Common Schema records are expected. | ||
| Using it in a heterogeneous logs pipeline may add conversion work to batches | ||
| that do not benefit from promotion. | ||
|
|
||
| The full Arrow-native implementation is deferred. It needs a reusable | ||
| cross-batch transform that can read log attributes by `parent_id`, set typed | ||
| root log columns, and rebuild `LogAttrs` with promoted fields removed while | ||
| preserving the remaining attributes. | ||
|
|
||
| ## Metrics | ||
|
|
||
| The processor reports these metrics: | ||
|
|
||
| - `records_seen`: log records inspected after conversion to OTLP. | ||
| - `records_promoted`: log records promoted as Microsoft Common Schema logs. | ||
| - `records_skipped_not_common_schema`: inspected records that did not match | ||
| Common Schema gating. | ||
| - `batches_promoted`: log batches with at least one promoted record. | ||
| - `arrow_batches_skipped_no_csver`: Arrow batches forwarded without OTLP | ||
| conversion because no `__csver__` attribute was present. | ||
29 changes: 29 additions & 0 deletions
29
...dataflow/crates/contrib-nodes/src/processors/microsoft_common_schema_processor/metrics.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| //! Metrics for the Microsoft Common Schema processor. | ||
|
|
||
| use otap_df_telemetry::instrument::Counter; | ||
| use otap_df_telemetry_macros::metric_set; | ||
|
|
||
| /// Internal telemetry for the Microsoft Common Schema processor. | ||
| #[metric_set(name = "microsoft.common_schema.processor.metrics")] | ||
| #[derive(Debug, Default, Clone)] | ||
| pub(super) struct MicrosoftCommonSchemaProcessorMetrics { | ||
| /// Number of log records inspected by the processor. | ||
| #[metric(unit = "{item}")] | ||
| pub records_seen: Counter<u64>, | ||
| /// Number of log records promoted as Microsoft Common Schema logs. | ||
| #[metric(unit = "{item}")] | ||
| pub records_promoted: Counter<u64>, | ||
| /// Number of log records inspected but not promoted as Microsoft Common Schema. | ||
| #[metric(unit = "{item}")] | ||
| pub records_skipped_not_common_schema: Counter<u64>, | ||
| /// Number of log batches that had at least one promoted record. | ||
| #[metric(unit = "{batch}")] | ||
| pub batches_promoted: Counter<u64>, | ||
| /// Number of Arrow log batches forwarded without OTLP conversion because no | ||
| /// `__csver__` attribute was present. | ||
| #[metric(unit = "{batch}")] | ||
| pub arrow_batches_skipped_no_csver: Counter<u64>, | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.