GithubHelp home page GithubHelp logo

isabella232 / puppetlabs-common_events Goto Github PK

View Code? Open in Web Editor NEW

This project forked from puppetlabs/puppetlabs-pe_event_forwarding

0.0 0.0 0.0 140 KB

This Gem contains the prototype common events library that supports Splunk/Servicenow

License: Other

Ruby 87.40% Shell 12.60%

puppetlabs-common_events's Introduction

puppetlabs-common_events

The Common Integration Events module collates different PuppetEnterprise API data sources into a common reporting Gem.

PROTOTYPE!

Table of Contents

  1. Intro
  2. Usage
  3. Pre-reqs
  4. Setup

Intro

The common events library is a module makes it easier to gather events from Puppet API end points and send them to other platforms. Once the module is installed in your environment, you can create classes that wrap the API calls for you to gather the events you need.

Usage

Getting Orchestrator Jobs

require 'common_events_library'
orchestrator  = Orchestrator.new(pe_console_url, username: pe_username, password: pe_password, ssl_verify: false)

# Get the last ten orchestrator jobs
response = orchestrator.get_all_jobs(offset: 0, limit: 10)

The code above will create an orchestrator client that can get all available jobs from the /jobs API endpoint. The pe username and password parameters are used in the init method of the class to automatically create an API token for use when authenticating to the API calls.

Getting Activity Service API Events

require 'common_events_library'
events = Events.new(pe_console_url, username: pe_username, password: pe_password, ssl_verify: false)
# Alternatively, if you wish to authenticate with a token:
events = Events.new(pe_console_url, token: pe_token, ssl_verify: false)

# Get the last ten rbac service events
response = events.get_all_events(service: 'rbac', limit: 10)

The code above will create an Activity Service API client that can get events from the activity-api/v1/events end point. The service parameter is the name of an Activity API service_id which can be any of classifier, rbac, pe-console or code-manager. If you provide a username, password, and token, the token will be used.

Create a General Purpose HTTP Client for Sending Data

require 'common_events_library'
splunk_client = CommonEventsHttp.new('https://splunk_instance.com', port: 8088, ssl_verify: false)

# Send an event to the splunk instance. Set the `use_raw_body` parameter if the
# body data (event_json) is already a json string. If you have a ruby object that
# response to `.to_json`, you can also use that as the post body leaving the `use_raw_body`
# parameter off in this method and the client will convert it for you
splunk_client.post_request('/services/collector', event_json, {Authorization: "Splunk #{token}"}, use_raw_body: true)

Pre-reqs

  • Puppet Enterprise version 2019.8.1 (LTS) or newer

Setup

  1. Install the puppetlabs-common_events module on your Puppet server.
    • github ref in your puppetfile
      mod 'common_events',
      :git => 'https://github.com/puppetlabs/puppetlabs-common_events'
      
    Once the module is installed the ruby code for the classes in the common_events_library gem are on the load path in Puppet code. You can then call require 'common_events_library' and ruby should load the classes.

puppetlabs-common_events's People

Contributors

randomnoun7 avatar gregohardy avatar gsparks 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.