Skip to content

Commit b7acdc2

Browse files
[github] audit: prefer @timestamp over created_at in agent cursor logic (elastic#16097)
Although the query parameter is `created`, listings are ordered by `@timestamp`. The `created_at` field often has older times, and it's absent from some even types, such as git events[1]. We keep `created_at` as a fallback, because some events don't have `@timestamp` according to the documentation[2] (although that hasn't been verified in the live API). [1]: https://docs.github.com/en/enterprise-cloud@latest/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/audit-log-events-for-your-enterprise#git [2]: https://docs.github.com/en/enterprise-cloud@latest/admin/monitoring-activity-in-your-enterprise/reviewing-audit-logs-for-your-enterprise/audit-log-events-for-your-enterprise#code_scanning
1 parent 6c0b0df commit b7acdc2

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

packages/github/_dev/deploy/docker/files/config.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ rules:
3535
"@timestamp": 1605719148837,
3636
"action": "repo.destroy",
3737
"actor": "monalisa",
38-
"created_at": 1605719148837,
3938
"_document_id": "LwW2vpJZCDS-WUmo9Z-ifw",
4039
"org": "mona-org",
4140
"repo": "mona-org/mona-test-repo",
@@ -70,7 +69,6 @@ rules:
7069
"_document_id": "Vqvg6kZ4MYqwWRKFDzlMoQ",
7170
"org": "octocat-test-org"
7271
},{
73-
"@timestamp": 1605719148837,
7472
"action": "repo.destroy",
7573
"actor": "monalisa",
7674
"created_at": 1605719148837,
@@ -112,7 +110,6 @@ rules:
112110
"_document_id": "Vqvg6kZ4MYqwWRKFDzlMoQ",
113111
"org": "octocat-test-org"
114112
},{
115-
"@timestamp": 1605719148837,
116113
"action": "repo.destroy",
117114
"actor": "monalisa",
118115
"created_at": 1605719148837,
@@ -153,7 +150,6 @@ rules:
153150
"@timestamp": 1605719148837,
154151
"action": "repo.destroy",
155152
"actor": "monalisa",
156-
"created_at": 1605719148837,
157153
"_document_id": "LwW2vpJZCDS-WUmo9Z-ifw",
158154
"org": "mona-org",
159155
"repo": "mona-org/mona-test-repo",

packages/github/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# newer versions go on top
2+
- version: "2.17.3"
3+
changes:
4+
- description: Fix HTTPJSON cursor logic for audit data stream.
5+
type: bugfix
6+
link: https://github.com/elastic/integrations/pull/16097
27
- version: "2.17.2"
38
changes:
49
- description: Remove updated_at field from latest issues transform unique keys.

packages/github/data_stream/audit/agent/stream/httpjson.yml.hbs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ response.pagination:
5555

5656
cursor:
5757
last_timestamp:
58-
value: '[[ .last_event.created_at ]]'
58+
value: >-
59+
[[- if index .last_event "@timestamp" -]]
60+
[[- .last_event.Get "@timestamp" -]]
61+
[[- else -]]
62+
[[- .last_event.created_at -]]
63+
[[- end -]]
5964
fail_on_template_error: true
6065

6166
{{#if tags.length}}
@@ -76,4 +81,4 @@ publisher_pipeline.disable_host: true
7681
{{#if processors}}
7782
processors:
7883
{{processors}}
79-
{{/if}}
84+
{{/if}}

packages/github/manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: github
22
title: GitHub
3-
version: "2.17.2"
3+
version: "2.17.3"
44
description: Collect logs from GitHub with Elastic Agent.
55
type: integration
66
format_version: "3.4.0"

0 commit comments

Comments
 (0)