Skip to content

Commit 28b5fae

Browse files
authored
[Salesforce] Add pagination support for login_rest and logout_rest data streams (#4866)
* Add pagination support for login_rest and logout_rest * Add Changelog entry
1 parent 842939c commit 28b5fae

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

packages/salesforce/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# newer versions go on top
22

3+
- version: 0.2.1
4+
changes:
5+
- description: Add pagination support for "login_rest" and "logout_rest".
6+
link: https://github.com/elastic/integrations/pull/4866
7+
type: bugfix
38
- version: 0.2.0
49
changes:
510
- description: Salesforce integration package with "logout_rest" data stream.

packages/salesforce/data_stream/login_rest/agent/stream/httpjson.yml.hbs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ request.transforms:
1414
target: url.params.q
1515
value: "SELECT Id,CreatedDate,LogDate,LogFile FROM EventLogFile WHERE Interval = 'Hourly' AND EventType = 'Login' AND LogDate > [[.cursor.last_published_login]] ORDER BY LogDate ASC NULLS FIRST"
1616
default: "SELECT Id,CreatedDate,LogDate,LogFile FROM EventLogFile WHERE Interval = 'Hourly' AND EventType = 'Login' ORDER BY LogDate ASC NULLS FIRST"
17-
response.split:
18-
target: body.records
17+
response.pagination:
18+
- set:
19+
target: url.value
20+
value: '[[if (ne .last_response.body.done true)]]{{instance_url}}[[.last_response.body.nextRecordsUrl]][[end]]'
21+
fail_on_template_error: true
1922
chain:
2023
- step:
2124
request.url: {{instance_url}}/services/data/v54.0/sobjects/EventLogFile/$.records[:].Id/LogFile
2225
request.method: GET
2326
replace: $.records[:].Id
2427
cursor:
2528
last_published_login:
26-
value: '[[.last_event.LogDate]]'
29+
value: '[[(formatDate ((parseDate .last_event.TIMESTAMP_DERIVED "RFC3339").Add (parseDuration "-1h")))]]'
2730
tags:
2831
{{#if preserve_original_event}}
2932
- preserve_original_event

packages/salesforce/data_stream/logout_rest/agent/stream/httpjson.yml.hbs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ request.transforms:
1414
target: url.params.q
1515
value: "SELECT Id,CreatedDate,LogDate,LogFile FROM EventLogFile WHERE Interval = 'Hourly' AND EventType = 'Logout' AND LogDate > [[.cursor.last_published_logout]] ORDER BY CreatedDate ASC NULLS FIRST"
1616
default: "SELECT Id,CreatedDate,LogDate,LogFile FROM EventLogFile WHERE Interval = 'Hourly' AND EventType = 'Logout' ORDER BY LogDate ASC NULLS FIRST"
17-
response.split:
18-
target: body.records
17+
response.pagination:
18+
- set:
19+
target: url.value
20+
value: '[[if (ne .last_response.body.done true)]]{{instance_url}}[[.last_response.body.nextRecordsUrl]][[end]]'
21+
fail_on_template_error: true
1922
chain:
2023
- step:
2124
request.url: {{instance_url}}/services/data/v54.0/sobjects/EventLogFile/$.records[:].Id/LogFile
2225
request.method: GET
2326
replace: $.records[:].Id
2427
cursor:
2528
last_published_logout:
26-
value: '[[.last_event.LogDate]]'
29+
value: '[[(formatDate ((parseDate .last_event.TIMESTAMP_DERIVED "RFC3339").Add (parseDuration "-1h")))]]'
2730
tags:
2831
{{#if preserve_original_event}}
2932
- preserve_original_event

packages/salesforce/manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
format_version: 1.0.0
22
name: salesforce
33
title: Salesforce
4-
version: 0.2.0
4+
version: 0.2.1
55
license: basic
66
description: Collect logs from Salesforce with Elastic Agent.
77
type: integration

0 commit comments

Comments
 (0)