Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Liferay Netherlands User Group: Elasticsearch a...

Avatar for Abdon Pijpelink Abdon Pijpelink
May 23, 2016
160

Liferay Netherlands User Group: Elasticsearch and the Elastic Stack

An introduction to Elasticsearch, Liferay 7's new default search engine, and the Elastic Stack. Including a demo on how to setup a Liferay open source monitoring dashboard with Elasticsearch, Logstash and Kibana.

Avatar for Abdon Pijpelink

Abdon Pijpelink

May 23, 2016
Tweet

Transcript

  1. Elasticsearch and the Elastic Stack An introduction to Liferay 7's

    new default search engine Abdon Pijpelink Education Engineer, Elastic Insert User 
 Group Logo Here
  2. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY What is Elasticsearch? • Data storage and

    retrieval engine • Distributed and highly available • Open source (Apache license) • Simple RESTful API • Versatile - many popular use cases • Log data analysis • Event data • Metrics • Full text search • Geospatial search • Analytics & aggregations • Suggestion engine • Data visualisation w/ Kibana • Packet data / performance monitoring Insert User Group Logo (please resize)
  3. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Liferay 6 and Elasticsearch • Liferay 6.2

    uses Lucene (out of the box) or Solr (official plugin) as its search engine • Open source Elasticsearch plugin available: "ElasticRay"
 https://github.com/R-Knowsys/elasticray and Liferay Marketplace • Support for latest version of Elasticsearch:
  4. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Liferay 7 and Elasticsearch • Liferay 7

    ships with embedded Elasticsearch as default search engine • All content and entities automatically indexed and available through search portlets • Liferay and Elastic are OEM partners
 Support packages available via Liferay Benelux • Embedded Elasticsearch not supported for Production 
 Run Elasticsearch on its own server • No security out of the box
 All data accessible through REST API at port 9200 (default) Insert User Group Logo (please resize)
  5. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY The Elastic Stack Insert User Group Logo

    (please resize) Elastic Cloud Security Monitoring Alerting Graph X-Pack Kibana User Interface Elasticsearch Store, Index,
 & Analyze Ingest Logstash Beats +
  6. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Logstash Insert User Group Logo (please resize)

    Input
 (log files) Filters
 (grok, geoip, ...) Output
 (Elasticsearch)
  7. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Demo: monitor Liferay user sessions Insert User

    Group Logo (please resize) 1. Expose Liferay user sessions as a service
 2. Poll Liferay service from Logstash and write to Elasticsearch
 3. Visualize number of users in Kibana
  8. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Demo: Liferay service public int getNumberOfLiveUsers() {

    try { Class<?> liveUsers = PortalClassLoaderUtil.getClassLoader() .loadClass("com.liferay.portal.liveusers.LiveUsers"); Method getSessionUsers = liveUsers.getDeclaredMethod( "getSessionUsers", long.class); Map<String, UserTracker> map = (Map<String, UserTracker>) getSessionUsers .invoke(null, CompanyThreadLocal.getCompanyId()); return map.size(); } catch (Exception e) { e.printStackTrace(); return -1; } } Insert User Group Logo (please resize)
  9. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Demo: Logstash configuration input { http_poller {

    urls => { liferay_live_users => "http://localhost:8080/api/jsonws/live-users-service-portlet.liveusers/ get-number-of-live-users" } request_timeout => 10 interval => 20 codec => "plain" metadata_target => "http_poller_metadata" } } filter { grok { match => { "message" => '%{NUMBER:number_of_users:int}' } } } output { stdout { codec => dots } elasticsearch { index => "liferay-%{+YYYY.MM.dd}" } } Insert User Group Logo (please resize)
  10. WWW.LIFERAY.COM WWW.FACEBOOK.COOM/LIFERAY @LIFERAY Learn more https://www.elastic.co (Website) https://www.elastic.co/learn (Learning Resources)

    https://www.elastic.co/community/meetups (Meetups) https://www.elastic.co/community/newsletter (News) https://discuss.elastic.co/ (Discussion Forum) https://github.com/elastic/ (Github) https://training.elastic.co/ (Training) https://www.elastic.co/services (Support/Consulting) IRC: #elasticsearch, #logstash, #kibana on freenode Insert User Group Logo (please resize)