Skip to content

Jenkins plugin to ship the console log off to Logstash

License

Notifications You must be signed in to change notification settings

GaryShen2008/logstash-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jenkins Logstash Plugin

Travis: Build Status Jenkins: Build Status

This plugin adds support for sending a job's console log to Logstash indexers such as Elastic Search, Logstash, RabbitMQ, Redis or to Syslog.

  • see Jenkins wiki for detailed feature descriptions
  • use JIRA to report issues / feature requests

Install

  • Generate the hpi file with the command: mvn package

  • Put the hpi file in the directory $JENKINS_HOME/plugins

  • Restart jenkins

Configure

Currently supported methods of input/output:

  • ElasticSearch {REST API}
  • Logstash TCP input
  • Redis {format => 'json_event'}
  • RabbitMQ {mechanism => PLAIN}
  • Syslog {format => cee/json (RFC-5424,RFC-3164), protocol => UDP}

Pipeline

Logstash plugin can be used as a publisher in pipeline jobs to send the whole log as a single document.

 node('master') {
        sh'''
        echo 'Hello, world!'
        '''
        logstashSend failBuild: true, maxLines: 1000
 }

It can be used as a wrapper step to send each log line separately.

Note: when you combine with timestamps step, you should make the timestamps the outer most block. Otherwise you get the timestamps as part of the log lines, basically duplicating the timestamp information.

timestamps {
  logstash {
    node('somelabel') {
      sh'''
      echo 'Hello, World!'
      '''
    }
  }
}

License

The Logstash Plugin is licensed under the MIT License.

Contributing

  • Fork the project on Github
  • Make your feature addition or bug fix, write tests, commit.
  • Send me a pull request. Bonus points for topic branches.

Adding support for new indexers

  • Implement the extension point jenkins.plugins.logstash.configuration.LogstashIndexer that will take your configuration.
  • Implement equals() and hashCode()so the plugin can compare new configuration with existing configuration.
  • Create a configure-advanced.jelly for the UI part of your configuration.
  • Create a help.jelly with more details about indexer.
  • Create a new class that extends jenkins.plugins.logstash.persistence.AbstractLogstashIndexerDao or jenkins.plugins.logstash.persistence.HostBasedLogstashIndexer. This class will do the actual work of pushing the logs to the indexer.

About

Jenkins plugin to ship the console log off to Logstash

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 98.5%
  • HTML 1.5%