# Mapping Workflow ## TOC - [Before You Start — Intake](#before-you-start--intake) - [Workflow A — Suggest a New Mapping](#workflow-a--suggest-a-new-mapping) - [Workflow B1 — Static Validation](#workflow-b1--static-validation) - [Shared: Content Field Analysis](#shared-content-field-analysis) - [Shared: Field Priority Order](#shared-field-priority-order) - [Mapping Table Template](#mapping-table-template) --- ## Before You Start — Intake Confirm before any mapping or validation: 1. Log target: `fetch logs` (not `security.events`). 2. `log.source` value(s) the vendor uses. 3. At least 1 raw vendor log sample; 3+ recommended per log class. 4. `content` field format: flat string or JSON object? 5. Audit log class: authentication, authorization, user_action, or access/request. 6. For B1: is the pasted event a final ingested Dynatrace record or a pre-ingest draft? 7. For B2: confirm `log.source` to query and that live tenant access is available. If inputs are incomplete, continue with a partial draft but list missing evidence explicitly. --- ## Workflow A — Suggest a New Mapping Triggered when the user provides a raw vendor log payload and no existing mapping. ### A.1 Parse the Input 1. If the input is a raw vendor log (entire JSON becomes the Dynatrace `content` string on ingest): reference all fields by their original vendor path — top-level fields by name (e.g. `host.name`, `service.name`), nested fields in dot notation (e.g. `content.user_name`, `content.ip_address`). Do NOT use any pipeline variable prefix (e.g. `c.`) in mapping tables — that is an OpenPipeline implementation detail for Phase 2 only. 2. If `content` is already a JSON string on a pre-ingest draft: deserialize and reference sub-fields as `content.`. 3. If `content` is a flat string: note the format; extraction requires a log parsing rule. 4. Identify audit log class from field names and values. ### A.2 Run Content Field Analysis See [Shared: Content Field Analysis](#shared-content-field-analysis). ### A.3 Build Mapping Candidate Map fields to semantic targets using [Shared: Field Priority Order](#shared-field-priority-order). Rules: - `log.source` MUST be the human-readable integration name as a constant (e.g. `"JFrog"`, `"Okta"`) — not the raw vendor identifier from the payload. - `timestamp` is auto-generated by Dynatrace on ingest — do NOT map from the vendor payload. Map the vendor's event time to `audit.time` instead (audit log classes only). - `content` is auto-enriched by Dynatrace on ingest — do NOT include it in the mapping table. - Map `content` sub-fields to top-level semantic attributes where a match exists. - Extract a vendor field to the top level only if it meets at least one of: 1. Maps to an SD-canonical field (always extract). 2. Provides valuable additional context not captured by SD fields (extract to `.`). - Limit vendor namespace (`.*`) extractions to ~5 fields per integration — only the highest-value data points not covered by SD fields. - Do NOT extract fields that are redundant, null, or carry no operational value (e.g. `-1` sentinel values, duplicates already covered by SD fields). - Discard string sentinel values — fields whose value is a meaningless placeholder (e.g. `"UNKNOWN"`, `"N/A"`, `"-"`, `"null"`) should be omitted from the mapping, not promoted. - Verify truly unknown fields against the live SD before classifying as vendor-extension: ```dql-snippet fetch dt.semantic_dictionary.fields | filter name == "" | fields name, type, description, stability ``` ### A.4 Phase 1 Output — Present and Wait for Approval 1. Mapping table (see [Mapping Table Template](#mapping-table-template)). 2. Content field promotion plan: source → target → transform → OpenPipeline rule needed? 3. Gap summary: required fields that cannot be mapped. 4. Discrepancies list: critical → major → minor. 5. Confidence tier. **Stop here. Do not produce Phase 2 until the user approves.** ### A.5 Phase 2 Output (after approval) 1. One sample mapped JSON log record. 2. Inline annotations for every transform applied. 3. OpenPipeline processor sketch for promoted content fields. OpenPipeline extraction pattern for a serialized-`content` field (JSON string). Do **not** use `parseJson` — it is not an OpenPipeline function. Use `parse content, "json:content"` (the `json` DPL token is case-insensitive), then access fields via subscript notation `content[key]` in `fieldsAdd`. `content` always retains the raw payload, so re-parse it in each processor that needs buried values — do not assume an earlier processor's parse persists. Also check for **root-level fields** already parsed at ingest (e.g. `` `service.name` ``) and reference those directly. See `openpipeline-constraints.md`. ```dql-snippet | parse content, "json:content" // turn JSON string into a structured record | fieldsAdd audit.identity = content[user_name] // subscript access: content[key] for JSON keys | fieldsAdd actor.ips = array(toIp(content[ip_address])) // → ipAddress[] | fieldsAdd audit.action = content[action] | fieldsAdd audit.result = if(content[success] == "True", "Succeeded", else: "Failed") | fieldsAdd loglevel = if(content[success] == "True", "INFO", else: "ERROR") | fieldsAdd status = loglevel ``` --- ## Workflow B1 — Static Validation Triggered when the user pastes an ingested log event (or a pre-ingest mapping draft). ### B1.0 Determine Input Mode - **Final ingested event**: top-level semantic fields + `content` as JSON string are both present. Use `content` (deserialized) as the source payload for comparison. - **Pre-ingest draft**: `content` may still be a JSON object. Do not fail for this; flag as a reminder to serialize. ### B1.1 Parse Content Deserialize `content` (if it is a JSON string). Build a side-by-side view: `content.*` sub-fields vs top-level semantic fields on the log record. ### B1.2 Run Content Field Analysis See [Shared: Content Field Analysis](#shared-content-field-analysis). ### B1.3 Apply Validation Rules Run all rules from `validation-rules.md`. For each missing required semantic field, check `content` for a candidate source path and add a `➕ add` entry with the proposed OpenPipeline extraction. ### B1.4 Produce Diff-Highlighted Mapping Table | Source Field | Current Target | Suggested Target | Transform | Status | Reason | |---|---|---|---|---|---| | `content.user_name` | — | `audit.identity` | direct | ➕ add | required audit field not promoted | | `content.ip_address` | `client.ip` | `actor.ips` | string→array | ⚠ change | use array field; keep `client.ip` as acceptable duplicate | | `loglevel` | `loglevel` | `loglevel` | normalize enum | ✅ ok | | | `content.internalRef` | `internal.ref` | — | — | ❌ remove | not in SD or samples | Marker legend: ✅ ok · ⚠ change · ➕ add · ❌ remove --- ## Shared: Content Field Analysis Apply in both A and B1. **Inventory every `content` sub-field and classify:** | Classification | Criteria | Action | |---|---|---| | `✅ promoted` | Top-level semantic field has same/equivalent value | Note — acceptable | | `➕ promotable` | Maps to a known SD field; not yet at top level | Add to mapping + OpenPipeline plan | | `🏷 vendor-specific` | No SD equivalent; unique vendor context | Keep in content; optionally add as `.` | | `ℹ️ duplicate` | Identical value already at top level | Leave in content (raw payload); do NOT add a second top-level copy | | `❓ unknown` | Not in SD, not in samples, purpose unclear | Flag for clarification | **Report:** `X of Y content fields promoted | Z promotable gaps remaining` --- ## Shared: Field Priority Order Map in this order: 1. `log.source` (constant — integration name), `loglevel`, `status`, `event.type` 2. `audit.action`, `audit.identity`, `audit.result`, `audit.status`, `audit.time` 3. `actor.ips`, `client.ip`, `client.app.name` 4. `actor.geo.*` 5. `browser.name`, `browser.version`, `device.*` 6. `object.id`, `object.name`, `object.type` 7. `result.code`, `result.message`, `result.detail` 8. `cloud.provider`, `azure.tenant.*`, `aws.account.*`, `gcp.organization.*` 9. Vendor namespace (`.*`) — must add information not in SD-canonical fields above --- ## Common Mapping Patterns Reusable patterns observed across vendor integrations. Apply where applicable. ### host.* as connector metadata When `host.*` fields originate from the log shipper or SaaS connector (not the target host being audited), do NOT map to `host.*` SD fields. Move to vendor namespace (e.g. `.instance.name`, `.instance.id`). Recognition signal: `host.name` is a cloud service name (e.g. `"jfrog-cloud"`), constant across all log records from the integration. ### service.name as audit object When the vendor provides a `service.name` or equivalent that identifies the system being audited, and no explicit object ID/name exists in the payload, map to `object.name` + `object.id` with `object.type = "service"`. ### audit.action from code combination When the vendor uses separate event-type and subtype codes (e.g. `event = "TKN"`, `event_type = "C"`), combine as `event:subtype` → `audit.action` (e.g. `"TKN:C"`). ### result.code and result.message - `result.code` (long): use when the vendor provides a numeric status or error code (e.g. HTTP status, error number). Coerce string→long if needed. - `result.message` (string): use the vendor's outcome string when no numeric code exists (e.g. `"ACCEPTED"`, `"DENIED"`). For change-tracking audit logs, the change-type key name (e.g. `"added"`, `"removed"`, `"modified"`) is a good result.message candidate. ### audit.time vs timestamp `timestamp` is always Dynatrace ingest time — never map from vendor. The vendor's event time (when the action occurred) maps to `audit.time` for audit log classes. For http class logs, event time stays in `content`. --- ## Mapping Table Template **Workflow A — Suggestion:** | Source Field | Target Field | Transform | Required | Sample Value | Notes | |---|---|---|---|---|---| | `content.username` | `audit.identity` | direct | yes | `jsmith@acme.com` | | | `content.source` | `actor.ips` | string→array | yes | `["44.198.0.1"]` | wrap in array | | `content.action` | `audit.action` | direct | yes | `"login"` | | | `content.success` | `audit.result` | `"True"`→`"Succeeded"`, `"False"`→`"Failed"` | recommended | `"Succeeded"` | | | derived | `loglevel` | from `audit.result` | yes | `"INFO"` | ERROR if Failed | | — | `log.source` | constant | yes | `"CyberArk"` | hardcoded per integration | **Workflow B1 — Diff:** | Source Field | Current Target | Suggested Target | Transform | Status | Reason | |---|---|---|---|---|---| | `log.source` | `log.source` | `log.source` | direct | ✅ ok | | | `content.username` | — | `audit.identity` | direct | ➕ add | required field not promoted |