Giter Site home page Giter Site logo

sumoanema / sumologic-publisher-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jenkinsci/sumologic-publisher-plugin

0.0 0.0 0.0 1.22 MB

Jenkins Plugin to send information to Sumo Logic.

License: Apache License 2.0

Java 99.49% Groovy 0.51%

sumologic-publisher-plugin's Introduction

SumoLogic ICON

sumologic-publisher

Build Status Jenkins Plugin GitHub release Jenkins Plugin Installs

Features

Plugin can be installed and used with global configuration. Below are set of features that can be used individually.

  1. SumoUpload - The function provides an ability to upload data from Files directly to Sumo Logic. Data is sent to the HTTP Source URL mentioned in the Global Configuration.

Prerequisite

  • Sumologic-publisher need Pipeline Rest API, GIT, metrics, subversion and junit. If not present, Sumologic-publisher will install these plugins as a part of internal dependency.
  • Hosted Collector and HTTP source on SumoLogic server.

Installation

In manage plugins, search for sumologic-publisher version 2.0 and install the plugin.

Tested with Jenkins version 2.100 - 2.178. Later version will be supported. In case of any issue, please raise a issue

Configuration

configuration

  • SumoLogic Portal Name - Eg- service.sumologic.com (where hosted collector resides).

  • Metric Data Prefix - Can be the name of the Jenkins Master on which plugin is installed or name with you can distinguish Jenkins Master.

  • HTTP Source URL - URL of the HTTP Logs and Metrics Sumo Logic source.

  • Source Category - Source Category defined for the source provided in the Http Source URL.

  • Keep Old Configuration for Jobs

    • Enable to send old configuration for jobs.
  • Types of Logs

    • Metric Data - To send metric information.
    • Audit Logs - To send audit information like login, Logout, Login Failure, configuration changes to jobs, changes to jenkins.
    • Periodic Logs - To send periodic information like Node information, Master information, Shutdown events, Jenkins system logs.
    • SCM Logs - To send Source control Management logs related to builds.
  • Enable Job Status for All Jobs

    • Select to send status for all jobs
  • Enable Console Logs for All Jobs

    • Select to send console logs for all jobs.

In case of specific Jobs

  • For Freestyle and maven Project

    • Go To Job Configuration

      • In the Post build Actions, select Sumo Logic Build Logger

      freestyle

  • For Pipeline Jobs

    • Go To Job Configuration

      • In the pipeline configuration, for normal script make below as the top level.

        SumoPipelineLogCollection { // your script }

      pipeline_Normal

      • In the pipeline configuration, for declarative pipeline script update the option.

        options { SumoPipelineLogCollection() }

      pipeline_Dec

Groovy script to configure the Plugin

Groovy configuration script for Jenkins post-initialisation

The purpose of this script is to automate the global configuration of plugin when Jenkins starts, so that no manual intervention is required via UI afterwards. This example of Groovy script file should have .groovy extension and be placed in the directory $JENKINS_HOME/init.groovy.d/.

Download the SumoLogicPublisherConfiguration.groovy file.

  • Make sure you are adjusting the values for fields according to your need.

Developer Version

  • Environment

    The following build environment is required to build the plugin

    • Java 1.8 and Maven 3.6.x.
  • Build

    Run mvn clean install or mvn package.

    Commands will create a sumologic-publisher.hpi in target folder.

  • Deploy

    Upload the sumologic-publisher.hpi in advanced section of manage plugin in Jenkins.

    uploadPlugin.png

SumoUpload

The Function can be used in Jenkins Pipelines to send files data to Sumo Logic. Function allow below properties:-

  1. file - Provide a file path or a directory path. If the value is a directory then data from all files within the directory will be sent to Sumo Logic.
  2. includePathPattern - Provide a pattern to include file names or extension. For eg:- *.json will include all json files only.
  3. excludePathPattern - Provide a pattern to exclude file names or extension. For eg:- *.json will exclude all json files only.
  4. text - Provide any string that will be sent to Sumo Logic.
  5. keyValueMap - Provide a key value map that will be converted to JSON and sent to Sumo Logic.
  6. workingDir - Provides the path of the directory where files are present. The path will be searched in the node where the Pipeline Step is executed.
  7. fields - Provide a key value map that will be sent as X-Sumo-Fields to Sumo Logic.

Below are some example uses of the Step Function :-

  • Upload a file/folder from the workspace (or a String) to Sumo Logic.
SumoUpload(file:'file.txt')
SumoUpload(file:'someFolder')
  • Upload with include/exclude patterns. The option accepts a comma-separated list of patterns.
SumoUpload(includePathPattern:'**/*', excludePathPattern:'**/*.log,**/*.json')
  • Upload file from master directory when Pipeline Stage is running on a agent. Below will send File.txt file present in Archive Folder of the job pipeline on master system.
node('master')
{
  SumoUpload(file: "File.txt", workingDir: "$JENKINS_HOME/jobs/$JOB_NAME/builds/$BUILD_NUMBER/archive")
}
  • Upload a text to Sumo Logic with Fields.
    script{
      fields = [
        jenkins_master: "test_master",
        result: currentBuild.currentResult
        ]
    }
    SumoUpload(text: "This is test String", fields: fields)
  • Upload a Key Value map as JSON to Sumo Logic.
    script{
      deploy_event = [
        event_name: STAGE_NAME,
        result: currentBuild.currentResult
        ]
    }
    SumoUpload(keyValueMap: deploy_event)

Change Log

For Full Change Log, Visit.

License

The sumologic-publisher is licensed under the apache v2.0 license.

Contributing

  • Fork the project on Github.
  • Make your feature addition or fix bug, write tests and commit.
  • Create a pull request with one of maintainer's as Reviewers.

sumologic-publisher-plugin's People

Contributors

devennorton avatar lchodar avatar sumosourabh avatar mccartney avatar sumo-apps-team avatar himanshu219 avatar jakozaur avatar rvmiller89 avatar sumoanema avatar cddude229 avatar daniel-beck-bot avatar duchatran avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.