Skip to content

Add support for dynamic fields#171

Merged
mtojek merged 13 commits intoelastic:masterfrom
mtojek:169-ignore-fields
Nov 16, 2020
Merged

Add support for dynamic fields#171
mtojek merged 13 commits intoelastic:masterfrom
mtojek:169-ignore-fields

Conversation

@mtojek
Copy link
Copy Markdown
Contributor

@mtojek mtojek commented Nov 10, 2020

Resolves: #169

This PR modifies pipeline test runner to verify dynamic fields.

I'm opening this as draft as I need changes in elastic/package-spec#82 .

@mtojek mtojek requested a review from ycombinator November 10, 2020 15:48
@mtojek mtojek self-assigned this Nov 10, 2020
@elasticmachine
Copy link
Copy Markdown
Collaborator

elasticmachine commented Nov 10, 2020

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #171 updated]

  • Start Time: 2020-11-16T09:32:57.627+0000

  • Duration: 12 min 8 sec

Test stats 🧪

Test Results
Failed 0
Passed 5
Skipped 0
Total 5

@mtojek mtojek marked this pull request as draft November 12, 2020 10:36
@mtojek
Copy link
Copy Markdown
Contributor Author

mtojek commented Nov 12, 2020

A couple of updates here:

  1. Updated dependency on the package-spec (support for dynamic fields).
  2. Pipeline tests: expected results in .json files don't contain dynamic fields (as they take variable values).
  3. Pipeline tests: once static parts of results are compared (diff), there is another check for dynamic fields with patterns.
  4. Pipeline tests: pattern matching for dynamic fields works only for string based values (in other cases it's skipped).
  5. Issue's title and description have been updated.

Sample failing output:

➜  nginx git:(169-ignore-fields) ✗ elastic-package test pipeline -v
2020/11/12 20:44:08 DEBUG Enable verbose logging
Run pipeline tests for the package
--- Test results for package: nginx - START ---
╭─────────┬────────────────────┬───────────┬────────────────────────┬─────────────────────────────────────────────────────────────────────────────────────┬──────────────╮
│ PACKAGE │ DATA STREAM        │ TEST TYPE │ TEST NAME              │ RESULT                                                                              │ TIME ELAPSED │
├─────────┼────────────────────┼───────────┼────────────────────────┼─────────────────────────────────────────────────────────────────────────────────────┼──────────────┤
│ nginx   │ access             │ pipeline  │ test-access-event.json │ PASS                                                                                │ 132.061159ms │
│ nginx   │ access             │ pipeline  │ test-access-raw.log    │ FAIL: test case failed: one or more problems with dynamic fields found in documents │ 127.889974ms │
│ nginx   │ access             │ pipeline  │ test-access-single.log │ PASS                                                                                │ 123.057553ms │
│ nginx   │ error              │ pipeline  │ test-error-raw.log     │ PASS                                                                                │ 120.399112ms │
│ nginx   │ ingress_controller │ pipeline  │ test-ingest-raw.log    │ PASS                                                                                │  127.86579ms │
╰─────────┴────────────────────┴───────────┴────────────────────────┴─────────────────────────────────────────────────────────────────────────────────────┴──────────────╯

FAILURE DETAILS:

nginx/access test-access-raw.log:
[0] dynamic field "url.original" doesn't match the pattern (^fake.*$): /
[1] dynamic field "url.original" doesn't match the pattern (^fake.*$): /adsasd
[2] dynamic field "url.original" doesn't match the pattern (^fake.*$): /favicon.ico
[3] dynamic field "url.original" doesn't match the pattern (^fake.*$): /taga
[4] dynamic field "url.original" doesn't match the pattern (^fake.*$): /test
[5] dynamic field "url.original" doesn't match the pattern (^fake.*$): /test1
--- Test results for package: nginx - END   ---
Done
Error: one or more test cases failed

@mtojek mtojek changed the title Add support for ignored fields Add support for dynamic fields Nov 12, 2020
@mtojek mtojek marked this pull request as ready for review November 12, 2020 19:50
},
"ignored_fields": [
"event.ingested"
]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this section needs to be updated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, thanks! Fixed

@ycombinator
Copy link
Copy Markdown
Contributor

Issue: #169

Consider using Resolves: #169 or similar so we don't end up with dangling open issues even after they have actually been resolved.

@mtojek mtojek requested a review from ycombinator November 16, 2020 09:45

The `fields` section allows for customizing extra fields to be added to every read log entry (e.g. `@timestamp`, `ecs`). Use this property to extend your logs with data that can't be extracted from log content, but it's fine to have same field values for every record (e.g. timezone, hostname).

The `dynamic_fields` section allows for marking fields as dynamic (every time they have different non-static values), so that pattern matching instead of strict value check is applied.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❤️

Copy link
Copy Markdown
Contributor

@ycombinator ycombinator left a comment

Choose a reason for hiding this comment

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

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Pipeline tests] Add the ability to ignore fields with dynamic values

3 participants