Skip to content

Commit ed060d9

Browse files
fransflippofransf-wtax
authored andcommitted
doc: documented configuration options for incremental data loading
1 parent 283ad19 commit ed060d9

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
@@ -79,6 +79,9 @@ This plugin supports the following configuration options plus the <<plugins-{typ
7979
| <<plugins-{type}s-{plugin}-client_secret>> |<<password,password>>|Yes
8080
| <<plugins-{type}s-{plugin}-interval>> |<<number,number>>|No
8181
| <<plugins-{type}s-{plugin}-password>> |<<password,password>>|Yes
82+
| <<plugins-{type}s-{plugin}-range_field>> |<<string,string>>|No
83+
| <<plugins-{type}s-{plugin}-range_filter>> |<<string,string>>|No
84+
| <<plugins-{type}s-{plugin}-range_field_value_file>> |<<string,string>>|No
8285
| <<plugins-{type}s-{plugin}-security_token>> |<<password,password>>|Yes
8386
| <<plugins-{type}s-{plugin}-sfdc_fields>> |<<array,array>>|No
8487
| <<plugins-{type}s-{plugin}-sfdc_filters>> |<<string,string>>|No
@@ -103,7 +106,7 @@ 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.
107110

108111
[id="plugins-{type}s-{plugin}-client_id"]
109112
===== `client_id`
@@ -112,10 +115,10 @@ To override this, set this to something like "32.0" for example
112115
* Value type is <<string,string>>
113116
* There is no default value for this setting.
114117

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

120123
[id="plugins-{type}s-{plugin}-client_secret"]
121124
===== `client_secret`
@@ -124,7 +127,7 @@ https://help.salesforce.com/apex/HTViewHelpDoc?id=connected_app_create.htm
124127
* Value type is <<password,password>>
125128
* There is no default value for this setting.
126129

127-
Consumer Secret from your oauth enabled connected app
130+
Consumer secret from your OAuth enabled connected app.
128131

129132
[id="plugins-{type}s-{plugin}-interval"]
130133
===== `interval`
@@ -150,21 +153,95 @@ If this property is not specified or is set to -1, the plugin will run once and
150153
* Value type is <<password,password>>
151154
* There is no default value for this setting.
152155

153-
The password used to login to sfdc
156+
The password used to log in to Salesforce.
154157

155-
[id="plugins-{type}s-{plugin}-security_token"]
156-
===== `security_token`
158+
[id="plugins-{type}s-{plugin}-range_field"]
159+
===== `range_field`
157160

158-
* This is a required setting.
159-
* Value type is <<password,password>>
161+
* Value type is <<string,string>>
162+
* There is no default value for this setting.
163+
164+
The field to track for incremental data loads. This field will
165+
be used in an `ORDER BY ... ASC` clause that is added to the Salesforce query.
166+
This field _should_ also be used in the <<plugins-{type}s-{plugin}-range_filter>> clause
167+
to actually achieve incremental loading of data.
168+
169+
The last value (which is the highest value if the query sorts by this field ascending)
170+
value for this field will be saved to the file at the path configured by
171+
<<plugins-{type}s-{plugin}-range_field_value_file>>, if specified.
172+
173+
This field should ideally be strictly ascending for new records. An
174+
autonumber field is ideal for this.
175+
176+
The standard `LastModifiedDate` field can be used, but since it is not _strictly_
177+
ascending (multiple records can have the same `LastModifiedDate`, the
178+
<<plugins-{type}s-{plugin}-range_filter>> should account for this by using the `>=`
179+
operator, and duplicates should be expected.
180+
181+
Note that Salesforce does not guarantee that the standard `Id` field has ascending
182+
values for new records (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_best_practices.htm).
183+
Therefore, using `Id` as range field risks missing records and is not recommended.
184+
185+
If this field is not already included in the <<plugins-{type}s-{plugin}-sfdc_fields>>,
186+
it is added.
187+
188+
[id="plugins-{type}s-{plugin}-range_field_value_file"]
189+
===== `range_field_value_file`
190+
191+
* Value type is <<string,string>>
192+
* There is no default value for this setting.
193+
194+
The full path to the file from which the latest range field value from the previous
195+
plugin invocation will be read, and to which the new latest range field value will be
196+
written after the current plugin invocation.
197+
198+
This keeps persistent track of the last seen value of the range field used for incremental
199+
loading of data.
200+
201+
The file should be readable and writable by the Logstash process.
202+
203+
If the file exists and a <<plugins-{type}s-{plugin}-range_filter>> is configured,
204+
a range filter clause is added to the query (and combined with any <<plugins-{type}s-{plugin}-sfdc_filters>>
205+
clause that is configured using the `AND` operator).
206+
207+
If the result set is not empty, the value for `range_field` from the last row is
208+
written to the file.
209+
210+
[id="plugins-{type}s-{plugin}-range_filter"]
211+
===== `range_filter`
212+
213+
* Value type is <<string,string>>
160214
* There is no default value for this setting.
161215

216+
The filter to add to the Salesforce query when a previous range field value
217+
was read from the <<plugins-{type}s-{plugin}-range_field_value_file>>.
218+
The string can (and should) contain a placeholder `%+{range_field_value}+` that
219+
will be substituted with the actual value read from the <<plugins-{type}s-{plugin}-range_field_value_file>>.
220+
221+
This clause is combined with any <<plugins-{type}s-{plugin}-sfdc_filters>>
222+
clause that is configured using the `AND` operator.
223+
224+
The value should be properly quoted according to the SOQL rules for the field
225+
type.
226+
227+
**Examples:**
228+
229+
"range_filter" => "Number > '%{range_field_value}'"
230+
"range_filter" => "LastModifiedDate >= %{range_field_value}"
231+
232+
[id="plugins-{type}s-{plugin}-security_token"]
233+
===== `security_token`
234+
235+
* This is a required setting.
236+
* Value type is <<password,password>>
237+
* There is no default value for this setting.
238+
162239
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
240+
generating a security token, see:
241+
https://help.salesforce.com/apex/HTViewHelpDoc?id=user_security_token.htm.
165242

166243
[id="plugins-{type}s-{plugin}-sfdc_fields"]
167-
===== `sfdc_fields`
244+
===== `sfdc_fields`
168245

169246
* Value type is <<array,array>>
170247
* Default value is `[]`
@@ -178,9 +255,9 @@ If this is empty, all fields are returned.
178255
* Value type is <<string,string>>
179256
* Default value is `""`
180257

181-
These options will be added to the WHERE clause in the
258+
These options will be added to the `WHERE` clause in the
182259
SOQL statement. Additional fields can be filtered on by
183-
adding field1 = value1 AND field2 = value2 AND...
260+
adding `field1 = value1 AND field2 = value2 AND...`.
184261

185262
[id="plugins-{type}s-{plugin}-sfdc_instance_url"]
186263
===== `sfdc_instance_url`
@@ -202,7 +279,7 @@ but not both to configure the url to which the plugin connects to.
202279
* Value type is <<string,string>>
203280
* There is no default value for this setting.
204281

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

207284
[id="plugins-{type}s-{plugin}-timeout"]
208285
===== `timeout`
@@ -221,7 +298,7 @@ read, an error occurs.
221298
* Value type is <<boolean,boolean>>
222299
* Default value is `false`
223300

224-
Setting this to true will convert SFDC's NamedFields__c to named_fields__c
301+
Setting this to true will convert Salesforce's `++NamedFields__c++` to `++named_fields__c++`.
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)