Use the Logstash collector feature in Liberty to collect log and other events from your
Liberty servers and send them to a remote Logstash server. The collected events can be used for log
analysis and troubleshooting purposes.
Procedure
- Set up Logstash V2.x following the instructions from Elasticsearch.
- Create or acquire certificate and key pair files for SSL for Logstash. The following example is
the command for openSSL that can be used for generating a certificate and key pair. Customize the
number of days the keys are valid as required.
openssl req -x509 -newkey rsa:2048 -keyout logstash.key -out logstash.crt -days 365 -nodes
- For Logstash V2.x and Elasticsearch users, copy the sample into a
liberty_logstash_template.json file. See sample logstash index template. Customize the
_ttl defaults as required to indicate the number of milliseconds to keep records of
each event type.
- For Logstash V2.x and Elasticsearch users, copy the sample into a
liberty_logstash.conf file. See sample logstash filters. Customize lumberjack
ssl_certificate path, ssl_key path, and port number as
required. Customize Elasticsearch hosts and template path as required.
- Complete the following steps for each of the Liberty servers that you want to collect events
from:
- Acquire or create a keystore for the Liberty server. To create a self-signed certificate, use
the following command. Customize the server name, password, and subject as required.
d:\wlp\bin\securityUtility createSSLCertificate --server=myServerName --password="Liberty" --subject=CN=myHostname,OU=defaultServer,O=ibm,C=us
- Import the logstash.crt file from step 2 into the
trust.jks file in your server. Customize the
wlp_install_dir and server name as required. When prompted for a password, use
the certificate password from step 5a.
d:\java\bin\keytool -import -noprompt -alias logstash -file logstash.crt -keystore wlp_install_dir\usr\servers\myServerName\resources\security\trust.jks -storepass Liberty
- Configure Logstash collector in the server.xml file in Liberty by adding
the following content. Customize the logstashCollector list of sources, host name, and port as
required.
<featureManager>
<feature>logstashCollector-1.0</feature>
</featureManager>
<keyStore id="defaultKeyStore" password="Liberty" />
<keyStore id="defaultTrustStore" location="trust.jks" password="Liberty" />
<ssl id="mySSLConfig" trustStoreRef="defaultTrustStore" keyStoreRef="defaultKeyStore" />
<logstashCollector
source="message,trace,garbageCollection,ffdc,accessLog"
hostName="localhost"
port="5043"
sslRef="mySSLConfig">
</logstashCollector>
Note: Trace and access logs are high volume logs and require more network, CPU, and storage
resources to collect.
- For users of Elasticsearch and Kibana V4.x, import the Kibana dashboard as follows:
- Save the Kibana dashboard JSON to a file on your local file system. See Sample Kibana dashboard for Elasticsearch and Kibana V4.x
users.
- In Kibana, configure the index pattern by clicking . Choose the Index name as logstash-* and
Time-field name as datetime.
- Click to import the dashboard into Kibana. When prompted, provide the path to the file you
saved in the previous step.
- Save the dashboard by using the save (disk) icon. Enter Liberty in the
text box that is provided and click the save icon next to the text box. The next time that you go to
Kibana from any browser, you can reload this dashboard by using the load icon, and clicking
Liberty.
Results
You configured your Liberty servers to send events to your Logstash server and can now view your
events in the Liberty dashboard by using Kibana.
If you enable Logstash collector to
acquire garbage collection events, late attach might not enable properly for IBM® tools against the z/OS®
Java™ virtual machine (JVM). To fix the problem, add the system
property and value -Dcom.ibm.tools.attach.enable=yes for the JVM invocation. Either
add it directly as part of the Java execution or within a
jvm.options file.