Montag, 23. Juni 2014

TimelineJS for offline usage

I really love TimelineJS as a nice and ease of use tool. But wait: How to use this tool offline? I spent hours crawling github and blogs. None of the mentioned worked for me. So here's the Alex way of using TimelineJS offline - no API loading from the web, no cloud based data hosting.

I used my local Windows 7 64bit and first put Apache 2 on my machine. Find Windows binaries here for download. Just do a straight default install and you're fine. Apache will install as Windows service and by default your htdocs web root will point to


C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs

Note Ensure no other service such as IIS or Tomcat already uses port 80 of your machine.

Then empty your htdocs directory and put content of tl.zip (click for download, MD5 fingerprint: ad715f5e39d903a7f1737b54f62d851c) in. The ZIP archive contains the following files/structures:


build
img
content.json
index.html

That's pretty much it. The build directory contains als necessary CSS and JS files - most important a copy of jQuery. Place your images you want to use in your timeline in the img directory. And your data resides JSON formatted in content.json file.

Now point your favourite web browser to http://localhost/ - you should see your timeline showing up. If not, please check Apache error log (default location C:\Program Files (x86)\Apache Software Foundation\Apache2.2\logs).

Enjoy building your timeline offline and publish to your intranet. Start play around with timeline customization. A good start is index.html timeline_config section.



Sonntag, 8. Juni 2014

High Availability vs. Scalability

Ever wondered about the difference between high availability (HA) and 
scalability? For me, scalability has always something to do with clustering, where HA is a part of by design.

Man - Am I wrong!

Since I'm a visual addicted person, let's draw an example


Joe is using my application, which is clustered for load balancing reasons. So if one node of my cluster fails, automatically another one will do the work.

That's great, because I got a scalable application by simply adding nodes to my cluster. But is Joe happy too?


Nope. Joe browsed my web shop half an hour, when one of my nodes failed. Joe gets angry about, because he lost his shopping basket and needs to start over.

That's why I did lots of research and configuration work by adding inter node communication to my cluster to make Joe happy again. Now Joes non persistent information such as sessions are shared between nodes. And now my cluster has real high availability functionality implemented besides normal scalability features.



Sounds simple? It's not! In particular adding HA features is a bunch of work depending on your applications features and complexity. And it's much more than just running your application on multiple server instances. And we didn't even talk about the database backend your application relies on.

Adding load balancing in best case involves operations staff only. Adding HA definitely involves operations and software developers - the beginning of a premium DevOps project. Read my DevOps blog post (German language only)

Dienstag, 20. Mai 2014

What the ELK can do for you?



Taking a closer look on neccessary log file analysis I stumbled upon the ELK - a stack using Elasticsearch + Logstash + Kibana

The ELK stack: Elasticsearch, Logstash, Kibana
So lets start with an example setup of these tools. Logstash comes with some kind of build in Kibana, but I used the seperate one.

Normally I'm the one who gets stuck with some kind of simple-to-solve-on-linux-system problems. But I got ELK up and running - so you'll do as well!

Elasticsearch acts as indexing data sink
Logstash takes and transforms logs and put them to Easticsearch
Kibana acts as GUI to nicely display results from Elasticsearch

Server
I used Ubuntu 14.04 LTS running as a VMWare or VirtualBox VM. You should have a server in place with network connectivity and SSH access to. That's my prerequisite - all others we're going to build up ourselves.

Take care of your servers disk space since we're dealing with log files. In my case around 14 GB of old logs (~80 mio log lines) to bring to ELK.

Packages
Install JDK and Apache
elk# apt-get update
elk# apt-get install openjdk-7-jdk
elk# apt-get install apache2
elk# apt-get install curl

Well done. That's it for the server configuration. Not kidding!

Logstash
Download Logstash. I choose ZIP version, DEB and RPM are available as well.
elk# curl -O https://download.elasticsearch.org/logstash/logstash/logstash-1.4.1.tar.gz
elk# mv logstash-1.4.1.tar.gz /opt
elk# tar xvfz /opt/logstash-1.4.1.tar.gz

Before starting Logstash we're going to prepare for log import. Assume a log file with the following structure (space delimited):

#api thread timestamp uid method execution_time result exn id

webapi 1462 2014-05-19T00:01:07.297 00000000-0000-0000-0000-000000000001 GetByName() 0 java.util.ArrayList 0 static

Paste this line of log to file /opt/logstash-1.4.1/20140520.log

Create a file /opt/logstash-1.4.1/import.conf with following content:
input {
  file {
         path   => [ "/opt/logstash-1.4.1/*.log" ]
         start_position => "beginning"
         discover_interval => 1
       }
}

filter {
  grok {
         patterns_dir => "/opt/logstash-1.4.1/patterns"
         match => [ "message", "%{DATA:api}%{SPACE}%{NUMBER:thread}%{SPACE}%{TIMESTAMP_ISO8601:logdate}%{SPACE}%{UUID:usr}%{SPACE}%{DATA:method}%{SPACE}%{NUMBER:ms}%{SPACE}%{DATA:result}%{SPACE}%{DATA:exn}%{SPACE}%{DATA:id}" ]
       }
  date {
         match => [ "logdate", "ISO8601" ]
       }
}

output {
  elasticsearch {
    host => localhost
  }
}

Run Logstash using the new created config:
elk# /opt/logstash-1.4.1/bin/logstash -f /opt/logstash-1.4.1/import.conf &

Now Logstash starts importing all files with extension .log from /opt/logstash-1.4.1 directory. You'll get some processing infos to console since Logstash runs in current sessions background.

Elasticsearch
Download and run Elasticsearch.
elk# curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.1.1.tar.gz
elk# mv elasticsearch-1.1.1.tar.gz /opt
elk# tar xvfz /opt/elasticsearch-1.1.1.tar.gz
elk# /opt/elasticsearch-1.1.1/bin/elasticsearch &

Stop hyperventilate! I know about the issues sending processes to the background. But it's fine for a simpel and fast first impression to ELK. Sure, Logstash and Elasticsearch should be configured as services - but not now.

Kibana
Assuming Apache web root location at /var/www we're moving Kibana to this location.

Download and extract Kibana.
elk# curl -O https://download.elasticsearch.org/kibana/kibana/kibana-3.1.0.tar.gz
elk# mv kibana-3.1.0.tar.gz /var/www
elk# tar xvfz /var/www/kibana-3.1.0.tar.gz && mv /var/www/kibana-3.1.0/* /var/www

Adopt /var/www/config.js to point to Elasticsearch API, which runs on same host. Don't use localhost - instead use IP address or full qualified domain name (FQDN) of your host. Find elasticsearch parameter in config.js - Example:

elasticsearch: "http://10.0.0.2:9200"

Where as 10.0.0.2 is the IP address of your Elasticsearch host.

Done with Kibana.

Are you happy?
No! Point your favourite web browser to http://10.0.0.2/. Now you're happy because Kibana shows up. Use the Logstash Dashboard link to watch your index growing.

Now it's our turn. Crawl Logstash docs for more sophisticated log processing which fits your needs. Start with the ELK stack in general at the Elasticsearch page.


Freitag, 2. Mai 2014

Tech Art

Plain log data analysis sometimes turns into some kind of tech art. Visualizing a couple of millions of data rows I just got the shown picture as result.


Donnerstag, 24. April 2014

Configure JBoss EAP with native SSL support

Ever tried to get all information you need to get JBoss EAP up and running using native SSL? No? Here's the Alex way getting EAP 6.1.0 with native SSL support up and running on Windows Server 2008 R2 64bit.

Prerequisite

  • JBoss EAP 6.1.0 GA
  • No usage of welcome-root (otherwise set flag enable-welcome-root to true in standalone.xml)
  • Windows Server 2008 R2 64bit
  • SSL private key file as plain text PEM format (RSA)
  • SSL certificate as plain text PEM format
  • SSL CA bundle as plain text PEM format

Solution

  • Download Windows Server 2008 R2 64bit native libs from here (login required)
  • Unpack and move lib folder including all sub content to your JBoss installation - say C:\jboss-eap-6.1\modules\system\layers\base\org\jboss\as\web\main
  • Add/edit standalone.xml (Example path: C:\jboss-eap-6.1\standalone\configuration) as follows - important: set native attribute to true!
<subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" native="true">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" redirect-port="${jboss.https.port:8443}"/>
<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
  <ssl name="ssl" certificate-key-file="../../cert/ssl-private-key.key" verify-client="false" certificate-file="../../cert/ssl-certificate.crt" ca-certificate-file="../../cert/ssl-cabundle.cabundle"/>
</connector>
<virtual-server name="default-host" enable-welcome-root="false">
  <alias name="localhost"/>
  <alias name="example.com"/>
</virtual-server>
</subsystem>
  • Restart JBoss
  • Check server.log for ERRORs - SSL loading is fine if
[org.apache.coyote.http11] (MSC service thread 1-3) JBWEB003000: Coyote HTTP/1.1 starting on: http-/0.0.0.0:443
  • DONE