-
Notifications
You must be signed in to change notification settings - Fork 523
[Kubernetes][audit_logs] Add mapping; map some fields to ECS fields #10138
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
[Kubernetes][audit_logs] Add mapping; map some fields to ECS fields #10138
Conversation
… ingest pipeline Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
| copy_from: kubernetes.audit.user.uid | ||
| ignore_empty_value: true | ||
| - set: | ||
| field: user_agent.original |
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.
Is it the kubernetes.audit.userAgent the unparsed user_agent in the form of "Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1" or just the name?
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.
I've added few examples in this comment - #9046 (comment): kindnetd/v0.0.0 (linux/amd64) kubernetes/$Format, kube-controller-manager/v1.29.1 (linux/amd64) kubernetes/bc401b9/leader-election, kube-probe/1.29
| ignore_empty_value: true | ||
| - convert: | ||
| field: kubernetes.audit.sourceIPs | ||
| target_field: source.ip |
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.
According to #9046 (comment) kubernetes.audit.sourceIPs should be also mapped to client.ip
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.
I though that it might be better to have kubernetes.audit.sourceIPs as ip type and simply copy value with set processor instead of convert twice - e1e6a26
but it introduce the type conflict
I've added set processor to copy source.ip - https://github.com/elastic/integrations/pull/10138/files#diff-ba27e35b988f4118d3605895eccfefce09e39b13df670ba4f1415d0c8f25a94dR59-R62
| - set: | ||
| field: event.action | ||
| copy_from: kubernetes.audit.verb | ||
| ignore_empty_value: true |
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.
What about the following mapping?
kubernetes.audit.annotations.authorization_k8s_io/decision -> event.outcome
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.
I've added it here e1e6a26
note: field value must be one of the following: failure, success, unknown - https://www.elastic.co/guide/en/ecs/current/ecs-event.html#field-event-outcome
…tead of text Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
Co-authored-by: Michael Katsoulis <michaelkatsoulis88@gmail.com>
Co-authored-by: Michael Katsoulis <michaelkatsoulis88@gmail.com>
Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
| dependencies: | ||
| ecs: | ||
| reference: git@v8.0.0 | ||
| reference: git@v8.11.0 |
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.
FYI: reason for this change - container.security_context.privileged field is not available in < 8.10.0
Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
| "type": "logs", | ||
| "dataset": "kubernetes.audit_logs" | ||
| }, | ||
| "host": { |
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.
reason for this: in ecs 8.3 was added pattern attribute to .mac fields - elastic/ecs#1871
after upgrading the ecs from 8.0 to 8.11 static tests are not working - I've removed host object to fix. Note: for some data_streams host object was already omitted:
╭────────────┬─────────────────────────────┬───────────┬──────────────────────────┬────────────────────────────────────────────┬──────────────╮
│ PACKAGE │ DATA STREAM │ TEST TYPE │ TEST NAME │ RESULT │ TIME ELAPSED │
├────────────┼─────────────────────────────┼───────────┼──────────────────────────┼────────────────────────────────────────────┼──────────────┤
│ kubernetes │ apiserver │ static │ Verify sample_event.json │ PASS │ 68.397358ms │
│ kubernetes │ audit_logs │ static │ Verify sample_event.json │ PASS │ 63.505139ms │
│ kubernetes │ container │ static │ Verify sample_event.json │ FAIL: one or more errors found in document │ 67.984205ms │
│ kubernetes │ container_logs │ static │ Verify sample_event.json │ FAIL: one or more errors found in document │ 62.75686ms │
│ kubernetes │ controllermanager │ static │ Verify sample_event.json │ PASS │ 63.080172ms │
│ kubernetes │ event │ static │ Verify sample_event.json │ FAIL: one or more errors found in document │ 58.794828ms │
│ kubernetes │ node │ static │ Verify sample_event.json │ FAIL: one or more errors found in document │ 57.321807ms │
│ kubernetes │ pod │ static │ Verify sample_event.json │ FAIL: one or more errors found in document │ 60.585872ms │
│ kubernetes │ proxy │ static │ Verify sample_event.json │ PASS │ 70.774477ms │
│ kubernetes │ scheduler │ static │ Verify sample_event.json │ PASS │ 60.451825ms │
│ kubernetes │ state_container │ static │ Verify sample_event.json │ FAIL: one or more errors found in document │ 60.242947ms │
│ kubernetes │ state_cronjob │ static │ Verify sample_event.json │ PASS │ 63.243224ms │
│ kubernetes │ state_daemonset │ static │ Verify sample_event.json │ PASS │ 62.284566ms │
│ kubernetes │ state_deployment │ static │ Verify sample_event.json │ PASS │ 61.316046ms │
│ kubernetes │ state_job │ static │ Verify sample_event.json │ PASS │ 66.531294ms │
│ kubernetes │ state_namespace │ static │ Verify sample_event.json │ PASS │ 65.444342ms │
│ kubernetes │ state_node │ static │ Verify sample_event.json │ PASS │ 63.073798ms │
│ kubernetes │ state_persistentvolume │ static │ Verify sample_event.json │ FAIL: one or more errors found in document │ 58.022577ms │
│ kubernetes │ state_persistentvolumeclaim │ static │ Verify sample_event.json │ PASS │ 60.903057ms │
│ kubernetes │ state_pod │ static │ Verify sample_event.json │ FAIL: one or more errors found in document │ 61.11333ms │
│ kubernetes │ state_replicaset │ static │ Verify sample_event.json │ PASS │ 59.230285ms │
│ kubernetes │ state_resourcequota │ static │ Verify sample_event.json │ FAIL: one or more errors found in document │ 61.368662ms │
│ kubernetes │ state_service │ static │ Verify sample_event.json │ FAIL: one or more errors found in document │ 59.198362ms │
│ kubernetes │ state_statefulset │ static │ Verify sample_event.json │ PASS │ 58.916231ms │
│ kubernetes │ state_storageclass │ static │ Verify sample_event.json │ FAIL: one or more errors found in document │ 59.207278ms │
│ kubernetes │ system │ static │ Verify sample_event.json │ FAIL: one or more errors found in document │ 58.320341ms │
│ kubernetes │ volume │ static │ Verify sample_event.json │ FAIL: one or more errors found in document │ 60.318885ms │
╰────────────┴─────────────────────────────┴───────────┴──────────────────────────┴────────────────────────────────────────────┴──────────────╯
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.
You mean that because we have ELASTIC_NETINFO:false and we dont have mac addresses at all, this is why you removed it?
Should not this be then the fact then, just to remove only mac addresses?
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.
You mean that because we have ELASTIC_NETINFO:false and we dont have mac addresses at all, this is why you removed it?
ELASTIC_NETINFO:false - hm, not sure what this field is about and if it is related somehow, but yes - we do not have mac field at all, I can remove host.mac field only - I think it should work, but I thought that host object in general is not relevant to the kubernetes integration itself (it is coming from the add_host_metadata processor as I understand)
Also some datastreams don't have host object (like state_deployment, see the table above - all datastreams with the test result PASS don't have host object in sample_event), so I decided to align all datastreams to follow similar approach. WDYT?
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.
Indeed host comes from the add_host_metadata processor. Neglected that.
So dont worry remove all host
| throw "expected kubernetes.audit.annotations.authorization_k8s_io/decision === allow"; | ||
| } | ||
| } | ||
| target: "kubernetes.audit" |
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.
FYI: there was a bug - elastic/beats#29395 , so the workaroud used before was to use target: "kubernetes_audit" and later rename to "kubernetes.audit" - it was fixed in 8.10 and since the current Kibana restriction is 8.14 - I removed the workaround
|
/test |
Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
🚀 Benchmarks reportTo see the full report comment with |
| - name: rules | ||
| dynamic: true | ||
| type: nested | ||
| - name: roleRef |
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.
This should be grouped with following
| - name: roleRef |
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.
|
Tested this locally and works fine! I would say to add some screenshots for the proof of the fields you added in the PR description: For me the Also |
|
Besides the latest comment about updating with some screenshots and specific questions for seccompProfile.type and kubernetes.audit.userAgent, LGTM! |
Signed-off-by: Tetiana Kravchenko <tetiana.kravchenko@elastic.co>
pod.yaml
I've also added screenshots in description @gizas @MichaelKatsoulis FYI: I also needed to remove mapping to the |
💚 Build Succeeded
History
|
|
|
Package kubernetes - 1.62.0 containing this change is available at https://epr.elastic.co/search?package=kubernetes |









Proposed commit message
Checklist
changelog.ymlfile.Author's Checklist
How to test this PR locally
kind-config.yaml
audit-policy.yaml
Related issues
Screenshots
kubernetes.audit.annotations.authorization_k8s_io/decision -> event.outcomekubernetes.audit.verb -> event.actionkubernetes.audit.sourceIPs -> client.ip & source.ipkubernetes.audit.requestObject.roleRef.namekubernetes.audit.requestObject.spec.containers.imagekubernetes.audit.requestObject.spec.containers.command
kubernetes.audit.requestObject.spec.containers.name
kubernetes.audit.requestObject.spec.containers.securityContext.seccompProfile.type
kubernetes.audit.user.uid -> user.id
kubernetes.audit.user.username -> user.name
kubernetes.audit.userAgent -> user_agent processor