Salesforce (im_salesforce)
This module can be used to collect event monitoring data from Salesforce applications. It uses Salesforce Lightning Platform SOAP API and REST API v54 with username-password authorization to retrieve log data.
| To examine the supported platforms, see the list of installation packages. |
Prerequisites
To connect to the API and access Salesforce logs, you must first create and configure a Connected App to retrieve its Consumer Key and Consumer Secret.
Permissions
The Salesforce Connected App must be configured with the required Oauth tokens and scopes to collect the information you request. The following examples offer an initial guidance, but your set of tokens and scopes is ultimately defined by your use case.
-
While doing initial tests or debugging in a controlled environment, you may benefit from having access to nearly all data Salesforce can provide. The following example provides a wide access to data, however, it should be avoided as a permanent solution because of security concerns.
Access the identity URL service (id, profile, email, address, phone) Manage user data via APIs (api) Manage user data via Web browsers (web) Full access (full) Access Connect REST API resources (chatter_api) Access Visualforce applications (visualforce) Perform requests at any time (refresh_token, offline_access) Access unique user identifiers (openid) Access custom permissions (custom_permissions) Access Analytics REST API resources (wave_api) Access Analytics REST API Charts Geodata resources (eclair_api) Manage Pardot services (pardot_api) Access Lightning applications (lightning) Access content resources (content) Manage Data Cloud Ingestion API data (cdp_ingest_api) Manage Data Cloud profile data (cdp_profile_api) Perform ANSI SQL queries on Data Cloud data (cdp_query_api) Access chatbot services (chatbot_api) Perform segmentation on Data Cloud data (cdp_segment_api) Manage Data Cloud Identity Resolution (cdp_identityresolution_api) Access Headless Forgot Password API (forgot_password) Manage Data Cloud Calculated Insight data (cdp_calculated_insight_api) -
For a more restricted example, the following list supports typical information requests for security analysis, using Salesforce data for reporting, monitoring, or investigation. This could be used by a SIEM ingesting sign-in history and API activity, a compliance team running scheduled reports on user permissions and data access, or a security analytics platform correlating Salesforce user identities with activity logs from other systems.
Manage user data via APIs (api) Perform requests at any time (refresh_token, offline_access) Access the identity URL service (id, profile, email, address, phone) Access unique user identifiers (openid) Access Connect REST API resources (chatter_api)
Configuration
The im_salesforce module accepts the following directives in addition to the common module directives.
Required directives
The following directives are required to authenticate with the REST API.
This mandatory directive specifies the consumer key of your Salesforce Connected App. |
|
This mandatory directive specifies the consumer secret of your Salesforce Connected App. |
|
An optional directive to specify a different domain for OAuth application authorization.
By default, |
|
This mandatory directive specifies the username of your Salesforce org account, e.g., |
|
This mandatory directive specifies the password of your Salesforce org account. |
HTTPS directives
The following directives configure secure data transfer via HTTPS.
Set this directive to |
|
Set this directive to |
|
Set this directive to the path of a directory containing Certificate Authority (CA) certificates.
The module uses these certificates to verify the certificate presented by the remote host.
Name the certificate files using the OpenSSL hashed format: the hash of the certificate followed by
For example, if the certificate hash is To trust a remote host’s self-signed certificate, include a copy of it in this directory. If this directive isn’t specified, NXLog Agent falls back to the default operating system root certificate store.
Unix-like operating systems commonly store root certificates in In addition, Microsoft’s PKI repository contains root certificates for Microsoft services. |
|
Set this directive to the path of the Certificate Authority (CA) certificate used to verify the certificate presented by the remote host. To trust a remote host’s self-signed certificate, specify the remote host’s certificate itself. For certificates signed by an intermediate CA, the specified certificate must contain the complete certificate chain (certificate bundle). |
|
Set this directive to the path of the certificate file to present to the remote host during the HTTPS handshake. |
|
Set this directive to the path of the private key file corresponding to the certificate specified by HTTPSCertFile. |
Optional directives
Set this directive to a custom header to add to each HTTP request. Specify this directive multiple times to add more than one header. |
|||||||||||||||||||||||||||||||||||||
Set this directive to enable HTTP compression for outgoing HTTP messages.
The accepted values are Some HTTP servers may not accept compressed HTTP requests.
If the server doesn’t support the specified compression method, it may return |
|||||||||||||||||||||||||||||||||||||
Set this directive to the HTTP basic authentication password. This directive requires you to also set the HTTPBasicAuthUser directive to use HTTP authentication. |
|||||||||||||||||||||||||||||||||||||
Set this directive to the HTTP basic authentication username. If the HTTPBasicAuthPassword directive is not set, the module attempts HTTP Basic authentication using an empty password. |
|||||||||||||||||||||||||||||||||||||
Set this directive to route outgoing requests through an HTTP or SOCKS proxy host.
The format is |
|||||||||||||||||||||||||||||||||||||
This optional directive sets the reconnect interval in seconds. If it is set, the module attempts to reconnect in every defined second. If it is not set, the reconnect interval will start at 1 second and double with every attempt. In the latter case, when the system decides that the reconnection is successful, the reconnect interval is immediately reset to 1 sec.
|
|||||||||||||||||||||||||||||||||||||
This optional directive defines the behavior when the connection with the remote host is lost.
When set to |
|||||||||||||||||||||||||||||||||||||
This optional directive specifies the used Salesforce REST API version.
It can be in |
|||||||||||||||||||||||||||||||||||||
This is an optional group directive to include or exclude event types from being collected. If this directive is not specified, the module will collect all events. It has the following sub-directives that can be defined multiple times:
|
|||||||||||||||||||||||||||||||||||||
This optional directive specifies how frequently the module will check for new events in seconds. If this directive is not specified, it defaults to 60 seconds. |
|||||||||||||||||||||||||||||||||||||
This boolean directive instructs the module on where to start reading events from the log source when NXLog Agent starts. When When The default is The following matrix shows the outcome of this directive in conjunction with the SavePos directive:
If the NoCache directive is |
|||||||||||||||||||||||||||||||||||||
Set this directive to The default is If the NoCache directive is |
|||||||||||||||||||||||||||||||||||||
This optional directive specifies the time in RFC 3339 format of the first event to pull. If this directive is not set, the module reads events according to the ReadFromLast directive. |
Examples
This configuration collects event monitoring logs from a Salesforce organization. im_salesforce receives records from the Salesforce API in CSV format, which it then parses into structured data and writes each record as a list of key-value pairs.
<Input salesforce>
Module im_salesforce
LoginDomain login.salesforce.com
Login USER@email.com
Password USERPASSWORD
ConsumerKey APP_KEY
ConsumerSecret APP_SECRET
<EventFilter>
Accept Login,Logout (1)
Accept OneCommerceUsage
# Exclude Search,SearchClick (2)
# Exclude Sandbox
</EventFilter>
StartFrom 2022-07-19T16:39:57-08:00 (3)
PollInterval 120 (4)
</Input>
| 1 | The event filter specifies the list of event types to collect in the Accept sub-directives. |
| 2 | The filter can also be configured to collect all log types except those specified by the Exclude sub-directives. |
| 3 | The StartFrom directive specifies to start collecting events from the specified date onward. |
| 4 | The PollInterval directive specifies to check for new events every 120 seconds. The default is 60 seconds. |
The following is a Salesforce event monitoring record after it was processed by NXLog Agent.
2022-07-15 12:03:11 nxlog-server INFO EVENT_TYPE="OneCommerceUsage" TIMESTAMP="20220602110049.842" REQUEST_ID="4jHvZvFIY-2Rl-l1cKNLKV" ORGANIZATION_ID="00D5f000003Hhp1" USER_ID="0055f0000030qMF" RUN_TIME="14443623" CPU_TIME="6876485" SERVICE_NAME="CommerceLicenseUsageMetrics" OPERATION="B2BMetricsCombinationJob" OPERATION_STAGE="combineNumberOfStores" COUNT="0" OPERATION_STATUS="Success" CONTEXT_MAP="{\"cc\":0,\"lb2b\":0}" B2B_EDITION="LB2B" TIMESTAMP_DERIVED="2022-06-02T11:00:49.842Z" USER_ID_DERIVED="0055f0000030qMFAAY"