Skip to content

[azure logs] Normalize capitalized Category field for proper data stream routing #14415

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

Merged
merged 6 commits into from
Jul 9, 2025

Conversation

zmoog
Copy link
Contributor

@zmoog zmoog commented Jul 3, 2025

Proposed commit message

Rename invalid log category field Category as category to correctly infer the event.dataset, and perform the routing to the target data stream, if available.

Unfortunately, some Azure services produce logs with capitalized field names, violating the spec.

❌ Invalid format

{
  "Category": "ServicePrincipalSignInLogs",
  "CorrelationId": "ed598e34-c91b-41da-a89e-e5a97da4209d",
  "DurationMs": 0,
  ...
}

Instead, it should be something similar:

✅ Expected format

{
  "category": "ServicePrincipalSignInLogs",
  "correlationId": "ed598e34-c91b-41da-a89e-e5a97da4209d",
  "durationMs": 0,
  ...
}

To properly identify the event dataset and apply the correct routing rules, we need to convert them to lowercase.

Note: the target data stream is responsible for dealing with the capitalized field names. The events data stream's responsibility is to route to the target data stream, if available, or fall back to platform logs.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

How to test this PR locally

cd packages/azure

$ elastic-package test pipeline -v -d events
--- Test results for package: azure - START ---
╭─────────┬─────────────┬───────────┬────────────────────────────────────────────────────────────────┬────────┬──────────────╮
│ PACKAGE │ DATA STREAM │ TEST TYPE │ TEST NAME                                                      │ RESULT │ TIME ELAPSED │
├─────────┼─────────────┼───────────┼────────────────────────────────────────────────────────────────┼────────┼──────────────┤
│ azure   │ events      │ pipeline  │ (ingest pipeline warnings test-invalid-category-field-raw.log) │ PASS   │ 649.352083ms │
│ azure   │ events      │ pipeline  │ test-invalid-category-field-raw.log                            │ PASS   │  40.554834ms │
╰─────────┴─────────────┴───────────┴────────────────────────────────────────────────────────────────┴────────┴──────────────╯
--- Test results for package: azure - END   ---
Done

Related issues

  • TBA

@zmoog zmoog added Integration:azure Azure Logs bugfix Pull request that fixes a bug issue Team:obs-ds-hosted-services Observability Hosted Services team [elastic/obs-ds-hosted-services] labels Jul 3, 2025
@zmoog zmoog changed the title Support invalid log category field name Category [azure logs] Support invalid log category field name Category Jul 3, 2025
Copy link
Contributor

@constanca-m constanca-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much @zmoog ! I thought we had to add Category support for everything, didn't even notice it was possible to just lowercase it.

@zmoog
Copy link
Contributor Author

zmoog commented Jul 3, 2025

can't recall the details, but I skipped tests because I thought the reroute processor "can't be tested" properly, but it turns out it's definitely possible.

We can add a few test documents with the category|Category|CaTeGoRy field and check the data_stream.dataset we get as output.

I added a few tests for the invalid field Category.

@zmoog zmoog changed the title [azure logs] Support invalid log category field name Category [azure logs] Normalize capitalized Category field for proper data stream routing Jul 3, 2025
@zmoog zmoog force-pushed the zmoog/fix/capitalized-log-category branch from 385a639 to c85d42b Compare July 3, 2025 22:15
@zmoog zmoog marked this pull request as ready for review July 3, 2025 22:16
@zmoog zmoog requested review from a team as code owners July 3, 2025 22:16
@elastic-vault-github-plugin-prod
Copy link

elastic-vault-github-plugin-prod bot commented Jul 3, 2025

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

Copy link
Contributor

@constanca-m constanca-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Maurizio!

@zmoog zmoog force-pushed the zmoog/fix/capitalized-log-category branch from 9beea8d to 58393d5 Compare July 9, 2025 13:34
@zmoog
Copy link
Contributor Author

zmoog commented Jul 9, 2025

Added one routing test for each supported log category:

$ elastic-package test pipeline -d events   
Run pipeline tests for the package
--- Test results for package: azure - START ---
╭─────────┬─────────────┬───────────┬────────────────────────────────────────────────────────────────┬────────┬──────────────╮
│ PACKAGE │ DATA STREAM │ TEST TYPE │ TEST NAME                                                      │ RESULT │ TIME ELAPSED │
├─────────┼─────────────┼───────────┼────────────────────────────────────────────────────────────────┼────────┼──────────────┤
│ azure   │ events      │ pipeline  │ (ingest pipeline warnings test-activitylogs-raw.log)           │ PASS   │ 558.513166ms │
│ azure   │ events      │ pipeline  │ (ingest pipeline warnings test-application_gateway-raw.log)    │ PASS   │ 482.429333ms │
│ azure   │ events      │ pipeline  │ (ingest pipeline warnings test-auditlogs-raw.log)              │ PASS   │ 475.755834ms │
│ azure   │ events      │ pipeline  │ (ingest pipeline warnings test-firewall_logs-raw.log)          │ PASS   │ 503.368542ms │
│ azure   │ events      │ pipeline  │ (ingest pipeline warnings test-graphactivitylogs-raw.log)      │ PASS   │ 488.667917ms │
│ azure   │ events      │ pipeline  │ (ingest pipeline warnings test-identity_protection-raw.log)    │ PASS   │ 512.766917ms │
│ azure   │ events      │ pipeline  │ (ingest pipeline warnings test-invalid-category-field-raw.log) │ PASS   │ 530.038041ms │
│ azure   │ events      │ pipeline  │ (ingest pipeline warnings test-provisioning-raw.log)           │ PASS   │ 493.391417ms │
│ azure   │ events      │ pipeline  │ (ingest pipeline warnings test-signinlogs-raw.log)             │ PASS   │ 511.469667ms │
│ azure   │ events      │ pipeline  │ (ingest pipeline warnings test-springcloudlogs-raw.log)        │ PASS   │ 558.499916ms │
│ azure   │ events      │ pipeline  │ test-activitylogs-raw.log                                      │ PASS   │  43.934875ms │
│ azure   │ events      │ pipeline  │ test-application_gateway-raw.log                               │ PASS   │  39.646875ms │
│ azure   │ events      │ pipeline  │ test-auditlogs-raw.log                                         │ PASS   │  38.612042ms │
│ azure   │ events      │ pipeline  │ test-firewall_logs-raw.log                                     │ PASS   │  41.445125ms │
│ azure   │ events      │ pipeline  │ test-graphactivitylogs-raw.log                                 │ PASS   │  38.820708ms │
│ azure   │ events      │ pipeline  │ test-identity_protection-raw.log                               │ PASS   │  38.927917ms │
│ azure   │ events      │ pipeline  │ test-invalid-category-field-raw.log                            │ PASS   │  38.571375ms │
│ azure   │ events      │ pipeline  │ test-provisioning-raw.log                                      │ PASS   │  39.498334ms │
│ azure   │ events      │ pipeline  │ test-signinlogs-raw.log                                        │ PASS   │  39.363542ms │
│ azure   │ events      │ pipeline  │ test-springcloudlogs-raw.log                                   │ PASS   │   40.66325ms │
╰─────────┴─────────────┴───────────┴────────────────────────────────────────────────────────────────┴────────┴──────────────╯
--- Test results for package: azure - END   ---
Done

@zmoog zmoog enabled auto-merge (squash) July 9, 2025 13:48
@zmoog
Copy link
Contributor Author

zmoog commented Jul 9, 2025

/test

@zmoog zmoog merged commit 8348b4d into elastic:main Jul 9, 2025
7 checks passed
@elasticmachine
Copy link

💚 Build Succeeded

History

Copy link

@elastic-vault-github-plugin-prod

Package azure - 1.28.1 containing this change is available at https://epr.elastic.co/package/azure/1.28.1/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix Pull request that fixes a bug issue Integration:azure Azure Logs Team:obs-ds-hosted-services Observability Hosted Services team [elastic/obs-ds-hosted-services]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants