GithubHelp home page GithubHelp logo

sumo-2's Introduction

sumo-search

Gem Version Build Status Code Climate Dependency Status

This gem interfaces with the Sumo Logic Search Job API. It may be used through native Ruby, or via a CLI that has been provided.

Installation

From the command line:

$ [sudo] gem install sumo-search

From your application's Gemfile:

gem 'sumo-search'

After installing the gem, you can require it using:

require 'sumo'

Configuration

Your credentials go into the YAML file ~/.sumo_creds. An example YAML file is listed below:

Note: Sumo Logic deprecated username/password login in favor of access IDs and access keys.

backend:
  access_id: your_access_id
  access_key: your_access_key
default:
  access_id: your_other_access_id
  access_key: your_access_key

The credentials in the default namespace are loaded by default. To change this, set ENV['SUMO_CREDENTIAL'] to the credential that you would like to load.

Ruby Usage

To create a search job from ruby, the Sumo.search method is provided. For example, the following creates a search job for everything from the 2014-01-01:

search = Sumo.search(
  :query => '*',
  :from => '2014-01-01T00:00:00',
  :to => '2014-01-01T23:59:59',
  :time_zone => 'UTC'
)

To iterate through the messages returned by the API, use the #messages method on the object returned by Sumo.search.

search.messages.each { |message| puts message }

Similarly, iterating through the records can be acheived through the #records method.

search.records.each { |record| puts record }

Note that the two above methods lazily grab the results in chunks, so iterating through these will take some time. The difference between records and messages is described at the bottom of this section of the api docs.

CLI Usage

The executable packaged with this gem is called sumo.

Option Required Description
-q --query true The query to send to the API
-f --from true The start date of the query (iso8601)
-t --to true The end date of the query (iso8601)
-z --time-zone true The time zone of the start and end dates
-e --extract-key false Extract the given key from the returned message
-r --records false Print out the records, not messages
-v --version false Print the version and exit
-h --help false Print the help message and exit.

Examples:

# Search for everything from 2014-01-01.
sumo --query '*' --from '2014-01-01T00:00:00' --to '2014-01-01T23:59:59' --time-zone 'UTC'

# Search for everything containing 'StagingFitness' in 2013, extracting the 'message' key from the response.
sumo --query 'StagingFitness' --from '2013-01-01T00:00:00' --to '2014-01-01T00:00:00' --time-zone 'UTC' --extract-key 'message'

sumo-2's People

Contributors

nahiluhmot avatar maupalantir avatar tlunter avatar scytherswings avatar adamjt 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.