Skip to content

Commit 591e494

Browse files
committed
doc: documented configuration options for incremental data loading
1 parent 2690613 commit 591e494

File tree

1 file changed

+98
-21
lines changed

1 file changed

+98
-21
lines changed

docs/index.asciidoc

Lines changed: 98 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ that will be used in the SOQL query.
4141

4242
==== HTTP proxy
4343

44-
If your infrastructure uses a HTTP proxy, you can set the `SALESFORCE_PROXY_URI` environment variable with the desired URI value (e.g `export SALESFORCE_PROXY_URI="http://proxy.example.com:123"`).
44+
If your infrastructure uses an HTTP proxy, you can set the `SALESFORCE_PROXY_URI` environment variable with the desired URI value (e.g `export SALESFORCE_PROXY_URI="http://proxy.example.com:123"`).
4545

4646
==== Example
4747
This example prints all the Salesforce Opportunities to standard out
@@ -75,6 +75,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
7575
|=======================================================================
7676
|Setting |Input type|Required
7777
| <<plugins-{type}s-{plugin}-api_version>> |<<string,string>>|No
78+
| <<plugins-{type}s-{plugin}-changed_data_filter>> |<<string,string>>|No
7879
| <<plugins-{type}s-{plugin}-client_id>> |<<string,string>>|Yes
7980
| <<plugins-{type}s-{plugin}-client_secret>> |<<password,password>>|Yes
8081
| <<plugins-{type}s-{plugin}-interval>> |<<number,number>>|No
@@ -86,6 +87,8 @@ This plugin supports the following configuration options plus the <<plugins-{typ
8687
| <<plugins-{type}s-{plugin}-sfdc_object_name>> |<<string,string>>|Yes
8788
| <<plugins-{type}s-{plugin}-timeout>> |<<number,number>>|No
8889
| <<plugins-{type}s-{plugin}-to_underscores>> |<<boolean,boolean>>|No
90+
| <<plugins-{type}s-{plugin}-tracking_field>> |<<string,string>>|No
91+
| <<plugins-{type}s-{plugin}-tracking_field_value_file>> |<<string,string>>|No
8992
| <<plugins-{type}s-{plugin}-use_test_sandbox>> |<<boolean,boolean>>|No
9093
| <<plugins-{type}s-{plugin}-use_tooling_api>> |<<boolean,boolean>>|No
9194
| <<plugins-{type}s-{plugin}-username>> |<<string,string>>|Yes
@@ -103,7 +106,29 @@ input plugins.
103106
* There is no default value for this setting.
104107

105108
By default, this uses the default Restforce API version.
106-
To override this, set this to something like "32.0" for example
109+
To override this, set this to something like "32.0" for example.
110+
111+
[id="plugins-{type}s-{plugin}-changed_data_filter"]
112+
===== `changed_data_filter`
113+
114+
* Value type is <<string,string>>
115+
* There is no default value for this setting.
116+
117+
The filter to add to the Salesforce query when a previous tracking field value
118+
was read from the <<plugins-{type}s-{plugin}-tracking_field_value_file>>.
119+
The string can (and should) contain a placeholder `%+{last_tracking_field_value}+` that
120+
will be substituted with the actual value read from the <<plugins-{type}s-{plugin}-tracking_field_value_file>>.
121+
122+
This clause is combined with any <<plugins-{type}s-{plugin}-sfdc_filters>>
123+
clause that is configured using the `AND` operator.
124+
125+
The value should be properly quoted according to the SOQL rules for the field
126+
type.
127+
128+
**Examples:**
129+
130+
"changed_data_filter" => "Number > '%{last_tracking_field_value}'"
131+
"changed_data_filter" => "LastModifiedDate >= %{last_tracking_field_value}"
107132

108133
[id="plugins-{type}s-{plugin}-client_id"]
109134
===== `client_id`
@@ -112,10 +137,10 @@ To override this, set this to something like "32.0" for example
112137
* Value type is <<string,string>>
113138
* There is no default value for this setting.
114139

115-
Consumer Key for authentication. You must set up a new SFDC
116-
connected app with oath to use this output. More information
140+
Consumer Key for authentication. You must set up a new Salesforce
141+
connected app with OAuth enabled to use this plugin. More information
117142
can be found here:
118-
https://help.salesforce.com/apex/HTViewHelpDoc?id=connected_app_create.htm
143+
https://help.salesforce.com/apex/HTViewHelpDoc?id=connected_app_create.htm.
119144

120145
[id="plugins-{type}s-{plugin}-client_secret"]
121146
===== `client_secret`
@@ -124,7 +149,7 @@ https://help.salesforce.com/apex/HTViewHelpDoc?id=connected_app_create.htm
124149
* Value type is <<password,password>>
125150
* There is no default value for this setting.
126151

127-
Consumer Secret from your oauth enabled connected app
152+
Consumer secret from your OAuth enabled connected app.
128153

129154
[id="plugins-{type}s-{plugin}-interval"]
130155
===== `interval`
@@ -150,21 +175,21 @@ If this property is not specified or is set to -1, the plugin will run once and
150175
* Value type is <<password,password>>
151176
* There is no default value for this setting.
152177

153-
The password used to login to sfdc
178+
The password used to log in to Salesforce.
154179

155180
[id="plugins-{type}s-{plugin}-security_token"]
156-
===== `security_token`
181+
===== `security_token`
157182

158-
* This is a required setting.
159-
* Value type is <<password,password>>
160-
* There is no default value for this setting.
183+
* This is a required setting.
184+
* Value type is <<password,password>>
185+
* There is no default value for this setting.
161186

162187
The security token for this account. For more information about
163-
generting a security token, see:
164-
https://help.salesforce.com/apex/HTViewHelpDoc?id=user_security_token.htm
188+
generating a security token, see:
189+
https://help.salesforce.com/apex/HTViewHelpDoc?id=user_security_token.htm.
165190

166191
[id="plugins-{type}s-{plugin}-sfdc_fields"]
167-
===== `sfdc_fields`
192+
===== `sfdc_fields`
168193

169194
* Value type is <<array,array>>
170195
* Default value is `[]`
@@ -178,9 +203,9 @@ If this is empty, all fields are returned.
178203
* Value type is <<string,string>>
179204
* Default value is `""`
180205

181-
These options will be added to the WHERE clause in the
206+
These options will be added to the `WHERE` clause in the
182207
SOQL statement. Additional fields can be filtered on by
183-
adding field1 = value1 AND field2 = value2 AND...
208+
adding `field1 = value1 AND field2 = value2 AND...`.
184209

185210
[id="plugins-{type}s-{plugin}-sfdc_instance_url"]
186211
===== `sfdc_instance_url`
@@ -202,7 +227,7 @@ but not both to configure the url to which the plugin connects to.
202227
* Value type is <<string,string>>
203228
* There is no default value for this setting.
204229

205-
The name of the salesforce object you are creating or updating
230+
The name of the Salesforce object you are creating or updating.
206231

207232
[id="plugins-{type}s-{plugin}-timeout"]
208233
===== `timeout`
@@ -221,7 +246,59 @@ read, an error occurs.
221246
* Value type is <<boolean,boolean>>
222247
* Default value is `false`
223248

224-
Setting this to true will convert SFDC's NamedFields__c to named_fields__c
249+
Setting this to true will convert Salesforce's `++NamedFields__c++` to `++named_fields__c++`.
250+
251+
[id="plugins-{type}s-{plugin}-tracking_field"]
252+
===== `tracking_field`
253+
254+
* Value type is <<string,string>>
255+
* There is no default value for this setting.
256+
257+
The field to track for incremental data loads. This field will
258+
be used in an `ORDER BY ... ASC` clause that is added to the Salesforce query.
259+
This field _should_ also be used in the <<plugins-{type}s-{plugin}-changed_data_filter>> clause
260+
to actually achieve incremental loading of data.
261+
262+
The last value (which is the highest value if the query sorts by this field ascending)
263+
value for this field will be saved to the file at the path configured by
264+
<<plugins-{type}s-{plugin}-tracking_field_value_file>>, if specified.
265+
266+
This field should ideally be strictly ascending for new records. An
267+
autonumber field is ideal for this.
268+
269+
The standard `LastModifiedDate` field can be used, but since it is not _strictly_
270+
ascending (multiple records can have the same `LastModifiedDate`, the
271+
<<plugins-{type}s-{plugin}-changed_data_filter>> should account for this by using the `>=`
272+
operator, and duplicates should be expected.
273+
274+
Note that Salesforce does not guarantee that the standard `Id` field has ascending
275+
values for new records (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_best_practices.htm).
276+
Therefore, using `Id` as tracking field risks missing records and is not recommended.
277+
278+
If this field is not already included in the <<plugins-{type}s-{plugin}-sfdc_fields>>,
279+
it is added.
280+
281+
[id="plugins-{type}s-{plugin}-tracking_field_value_file"]
282+
===== `tracking_field_value_file`
283+
284+
* Value type is <<string,string>>
285+
* There is no default value for this setting.
286+
287+
The full path to the file from which the latest tracking field value from the previous
288+
plugin invocation will be read, and to which the new latest tracking field value will be
289+
written after the current plugin invocation.
290+
291+
This keeps persistent track of the last seen value of the tracking field used for incremental
292+
loading of data.
293+
294+
The file should be readable and writable by the Logstash process.
295+
296+
If the file exists and a <<plugins-{type}s-{plugin}-changed_data_filter>> is configured,
297+
a changed data filter clause is added to the query (and combined with any <<plugins-{type}s-{plugin}-sfdc_filters>>
298+
clause that is configured using the `AND` operator).
299+
300+
If the result set is not empty, the value for `tracking_field` from the last row is
301+
written to the file.
225302

226303
[id="plugins-{type}s-{plugin}-use_test_sandbox"]
227304
===== `use_test_sandbox`
@@ -230,7 +307,7 @@ Setting this to true will convert SFDC's NamedFields__c to named_fields__c
230307
* Default value is `false`
231308

232309
Set this to true to connect to a sandbox sfdc instance
233-
logging in through test.salesforce.com
310+
logging in through test.salesforce.com.
234311

235312
Use either this or the `sfdc_instance_url` configuration option
236313
but not both to configure the url to which the plugin connects to.
@@ -255,9 +332,9 @@ of elements of sfdc flows) and security health check risks.
255332
* Value type is <<string,string>>
256333
* There is no default value for this setting.
257334

258-
A valid salesforce user name, usually your email address.
335+
A valid Salesforce username, usually your email address.
259336
Used for authentication and will be the user all objects
260-
are created or modified by
337+
are created or modified by.
261338

262339

263340

0 commit comments

Comments
 (0)