Skip to content

Logstash Issues

Troubleshoot Logstash connection, log-parsing, index-creation, and startup issues.

7 min read Updated SS RS

Below are the troubleshooting of Logstash issues:

  • Logstash Connection Error to Elasticsearch
  • Issue with Parsing WebLogic Access Log Fields
  • Logscan Index Creation Issue for APY NPS Application
  • Rsyslog and Filebeat are Unable to Connect to HAProxy
  • WebLogic Access Log Pipeline Fields Format Mismatch
  • Logstash Container Not Starting
  • Rsyslog Date Format Mismatch

For reference:
The following section contains basic Linux commands: Basic Commands

Logstash Connection Error to Elasticsearch#

Users may encounter an issue where Logstash nodes cannot send data to Elasticsearch, resulting in a lack of TXN data in Grafana dashboards.

The error in the Logstash logs is as follows:

Elasticsearch Unreachable: [http://admin:xxxxxx@192.0.2.120:9200/]
[Manticore::ConnectTimeout] connect timed out

RCA: This error indicates that Logstash is attempting to connect to an Elasticsearch instance but is timing out, implying an issue with the network connection or incorrect Elasticsearch details.

The issue stems from incorrect OpenSearch (or Elasticsearch) details in the 60_output_opensearch_index_logstash.conf file. This misconfiguration prevents Logstash from establishing a successful connection with the Elasticsearch cluster.

Solution:

1. Update the 60_output_opensearch_index_logstash.conf file with the correct OpenSearch details.

Ensure that the IP address, port, username, and password (if applicable) are correctly specified.

For Example:

output {
  elasticsearch {
    hosts => ["http://correct-ip:port"]
    user => "correct-username"
          password => "correct-password"
          ...
     }
}

2. After updating the configuration file, restart the OpenSearch (or Elasticsearch) and Logstash services to apply the changes.

Execute the below command to Restart Services:

service opensearch restart
service logstash restart

3. Verify that Logstash can connect successfully to Elasticsearch and that data is flowing into Grafana dashboards.

The Issue with Parsing WebLogic Access Log Fields#

WebLogic access log fields such as URL, method, and response time are not being parsed and displayed correctly in Grafana. Although monitoring is enabled using a Rsyslog agent, and data is being transmitted to HEAL, with the index created in OpenSearch, each log line appears only in the message field, affecting the dashboard display.

RCA:

The issue stems from the data type mismatch in the parsing configuration within Logstash, particularly for the response time field which is being incorrectly processed as an integer rather than a float.

Solution:

1. Modify Parsing Configuration: Update the Logstash pipeline configuration to correct the data type of the response time field. This involves changing the mutate/convert configuration for the response time field from integer to float. The necessary change should be made in the pipeline configuration file, specifically on line 58:

mutate {
convert => { "resp.time" => "float" }
}

2. Restart Logstash: After updating the pipeline file, restart Logstash to apply the changes. It's crucial to understand that simply copying the updated configuration to the pipeline directory does not activate the changes until Logstash is restarted.

3. Manage Existing Data Index: Delete the current date index in OpenSearch before restarting Logstash. This step is essential because the existing index has the response time field defined as an integer, and attempting to insert float values without deleting the index could lead to data type mismatch errors and insertion failures.

Logscan Index Creation Issue for APY NPS Application#

Issue: The Logscan index is not being created for the APY NPS application due to connectivity issues.

Detailed Log Analysis:

Logs from the target server indicate issues with the connection to the Logstash Service:

Log Entry :

ERROR pipeline/output.go:121 Failed to publish events: write tcp
192.0.2.121:33396->192.0.2.35:13792: write: broken pipe

Description : This error suggests that the Logstash service could not maintain a stable connection, possibly due to network issues or misconfiguration of the destination port.

Log Entry :

INFO pipeline/output.go:95 Connecting to
backoff(async(tcp://192.0.2.35:13792))

Description : The system attempted to reconnect to the Logstash service using the problematic port.

Log Entry :

INFO pipeline/output.go:105 Connection to
backoff(async(tcp://192.0.2.35:13792)) established

Description : A connection was temporarily established but was not stable.

Log Entry :

`DEBUG [transport] transport/client.go:218 handle error: write tcp
192.0.2.121:33418->192.0.2.35:137

Rsyslog and Filebeat are Unable to Connect to HAProxy#

Issue: Logstash is getting hung and unable to process logscan data. The services need to be restarted frequently to resume processing, despite both Logstash and logscan agents running.

Error: The following errors were observed in the agents' logs:

a. Solaris Rsyslog Agent Log:

  • Server: UPI 192.0.2.122
  • Observed issue with HAProxy DNS

b. Linux IMPS Filebeat Log:

  • Server: 192.0.2.123
  • Observed issue with connections to HAProxy

Solution:

To resolve the issue, we made adjustments to the HAProxy configuration (`haproxy.cfg `) to fine-tune Rsyslog connections and ensure data is sent to a specific Logstash instance.

The following lines were added to the HAProxy configuration file:

stick-table type integer size 200k expire 30m
stick on src_port
stick on dst

These settings optimize the connection handling by:

1. stick-table type integer size 200k expire 30m: This line creates a stick- table of type integer with a size of 200,000 entries, which expire after 30 minutes. This helps in managing connection states and persistence.

2. stick on src_port : This directive enables stickiness based on the source port, ensuring that connections from the same source port are directed consistently.

3. stick on dst : This directive enables stickiness based on the destination, ensuring consistent traffic routing to the appropriate backend.

After applying these changes, the connections will work, and the log processing issues will be resolved.

WebLogic Access Log Pipeline Fields Format Mismatch#

Issue: WebLogic Access Log Pipeline Date Time Fields Format Mismatch

The WebLogic access logs are being parsed using the Logstash pipeline. However, when viewing the raw data in Grafana, the log data appears to be 5 hours and 30 minutes behind the current time.

Solution:

The discrepancy was due to a mismatch in the time field configuration between the OHS and WebLogic pipelines. To correct this, a time zone field was added to the Logstash pipeline configuration. This adjustment ensures that the data is displayed at the correct current time in both OpenSearch and Grafana.

Follow the below steps to rectify the issue:

1. Identify Time Field Configuration Differences: Compare the time field configurations between the OHS and WebLogic pipelines to identify discrepancies.

2. Modify Logstash Pipeline Configuration: Add the time zone field to the WebLogic pipeline configuration to align it with the correct time zone.

3. Logstash Configuration:

       filter {
         grok {
           match => { "message" => "%{COMMONAPACHELOG}" }
         }
            date {
              match => [ "timestamp", "dd/MMM/yyyy:HH:mm:ss Z" ]
              target => "@timestamp"
       timezone => "Asia/Kolkata"          # Adjust the time zone as
required
            }
       }

4. Verify the Changes:

  • After updating the Logstash configuration, restart the Logstash service to apply the changes.
  • Verify that the log data in OpenSearch and Grafana now shows the correct current time.

By adding the appropriate time zone configuration in the Logstash pipeline, the WebLogic access log data is correctly displayed at the current time in both OpenSearch and Grafana.

Logstash Container Not Starting#

The Logstash container fails to start, and no logs are generated.

RCA: The Logstash image was not loaded with the correct name.

Additionally, there is a configuration mismatch between the DC and DR sites, specifically with the Logstash port setup behind HAProxy.

Solution :

1. Correct the Logstash Image: Ensure that the correct Logstash image is loaded by checking the image repository and tag.

2. Align DC and DR Configuration:

  • In the DC, Logstash is configured behind HAProxy on a non-SSL port, while in the DR site, it is configured for SSL.
  • To maintain consistency, change the Logstash port in the DR site's HAProxy configuration to a non-SSL port to match the DC setup.

3. Restart Services: After modifying the HAProxy configuration file on LOGSTASH 8.

Rsyslog Date Format Mismatch#

Follow the below steps to rectify the Rsyslog data format issue:

Solution :

1. Verify Target Application Logs : Request the end user to provide the target application logs and verify the date format.

2. Update Date Format in Percona :

a. Log in to Percona using the following command:

mysql -h <host_IP> -u <user> -p<pass> -P 3307 --ssl-mode=disabled

b. Select the database:

USE appsone;

c. Retrieve agent details:

SELECT * FROM agent WHERE name="<agent_name>";

d. Check if the date format matches the log level's date format.

If it differs, update the date format by executing the below command:

UPDATE agent SET txn_date_pattern="<new_date_format>" WHERE name="
<agent_name>";

At the DR site, restart both HAProxy and Logstash to apply the changes.