Polarity v4 Admin Guide
Polarity v5 Admin Guide
  • Sever Requirements
    • Deployment Methods
      • Deploying Polarity Server on AWS with RDS and Elasticache
      • Deploying Polarity Server Virtual Machine on Azure
      • Deploying via OVA
      • Deploying via RPM
      • Polarity Server BYOL AMI
  • Guides
    • Installing License
    • Authentication
      • SAML
        • Azure ADFS
        • Okta
        • SAML Troublshooting
      • LDAP Troubleshooting
    • Installing Private Certificate Authority
    • Installing SSL Certificate
      • Installing LetsEncrypt SSL Certificate on Polarity Server
    • Configuring a Proxy
    • Migrating Polarity Servers
      • Upgrade PostgreSQL to v13
    • Enabling SMTP
    • Server Environment Variables
    • File System Layout
    • Configuring a FQDN
    • Enabling Source Analytics
      • Elasticsearch
        • Configuring Source Analytics on Elasticsearch
        • Source Analytics Integration with Elasticsearch
    • v5 Server Pre-Flight Upgrade Check
  • Integrations
    • Auto Subscribe CLI Tool
    • Installation
    • Install Multiple Copies of an Integration
    • Modifying Integration Name & Acronym
    • Add Custom Entity Types
Powered by GitBook
On this page
  • Enable Source Analytics
  • Create a Polarity Agent Policy
  • Configure the Agent Policy
  • Configure a Data View
  • View your Data
  1. Guides
  2. Enabling Source Analytics
  3. Elasticsearch

Configuring Source Analytics on Elasticsearch

The following guide walks through how to collect source analytic logs from your server using Elasticsearch.

PreviousElasticsearchNextSource Analytics Integration with Elasticsearch

Last updated 1 year ago

Enable Source Analytics

Prior to setting up collection of your source analytic (PSA) logs, please enable the logging on your server.

Create a Polarity Agent Policy

Once, source analytic are being collected on your Polarity Server you can configure Elasticsearch to receive those logs.

Login to your Elasticsearch Kibana instance.

Navigate to the "Management" -> "Fleet" page

Click on "Agent Policies"

Click on "Create agent policy"

Name the policy. For example "polarity-source-analytics"

Name
polarity-source-analytics

Decide if you would also like to collect system logs and metrics (note that this is not required for Source Analytics collection)

The default "Advanced options" will work but you may want to make changes depending on your organization.

For example, you might want to add an optional description or modify the "Default namespace".

Click on "Create agent policy"

Your new policy will be created but still needs to be configured.

Configure the Agent Policy

Your new policy will show up in the Fleet list under "Agent Policies". Click on it to view the details:

Click on "Add integration"

Search for the "Custom Logs" integration and click on it:

Click on the "Add Custom Logs" button.

Under the Custom Logs configuration, set the Integration name:

Integration name
psa-collection

Set the description.

Description
Collects polarity source analytic (PSA) logs

Ensure "Custom log file" is checked and then expand the "Change defaults" section:

Set the "Log file path"

Log file path
/app/polarity-server/logs/polarity-server.log

Click on "Advanced Options"

Set the "Dataset name"

Dataset name
psa

In the "Processors" section paste the following configuration:

Processors
- decode_json_fields:
    fields: ["message"]
    target: polarity
    process_array: true      
- drop_event:
    when:
      not:       
        equals:
          polarity.msgType: "integration-lookup"         
- drop_fields:
    fields: ["polarity.req.session.passport.user.integrations", "polarity.req.session.passport.user.settings", "polarity.meta", "polarity.errors", "polarity.req.query", "polarity.error", "polarity.debug"]
    ignore_missing: true
- timestamp:
    field: polarity.timestamp
    layouts:
      - '2006-01-02T15:04:05Z'
      - '2006-01-02T15:04:05.999Z'
      - '2006-01-02T15:04:05.999-07:00'
    test:
      - '2019-06-22T16:33:51Z'
      - '2019-11-18T04:59:51.123Z'
      - '2020-08-03T07:10:20.123456+02:00'

Click on "Save and continue"

When prompted click on "Add Elastic Agent to your hosts"

Leave the default settings. Copy the "Linux Tar" command and run it on your Polarity server to install the fleet agent.

After the fleet agent is installed it should automatically connect to your fleet agent console and appear as healthy.

If you used the default namespace and dataset name your logs will be collected under the datastream logs-psa-default. To find this data stream navigate to "Stack Management" -> "Index Management" -> "Data Streams":

Configure a Data View

If you do not see the data stream and your Agent is reporting as "Healthy", ensure you have PSA enabled on the server and that a search has been run since you enabled it.

To make your data stream searchable you have to create a "Data View". Navigate to "Kibana" -> "Data Views" and click on "Create data view".

Give the data view a name:

Name
Polarity Source Analytics

and then set the "Index Pattern":

Index pattern
logs-psa-default

You can leave the Timestamp field with the default setting of "@timestamp".

Click on "Save data view to Kibana"

View your Data

You can view the raw source analytics by navigating to "Analytics" -> "Discover"

In the top left, filter to only show data from your newly created "Polarity Source Analytics" data view.

You should now see your Source Analytics Data available in Kibana. To view the Source Analytics specific data you can click on a log file and then filter fields by the term "Polarity"

From here you can design Dashboards or install the Polarity Source Analytics for Elasticsearch integration.

If you don't see any data, try adjusting your search time window and click on "Refresh"

Enabling Source Analytics
Look for your agent policy on the Fleet "Agents" page