Skip to content

Conversation

@akdor1154
Copy link

@akdor1154 akdor1154 commented Jul 8, 2019

This is an attempt at a high-level simple API for the Sumo library. (see #32)

Usage:

fields, messages, records = sumo.simple.search("""
  _sourceCategory=nginx/prod
  error
""", startTime=timedelta(minutes=-60), endTime=None)

for m in messages:
  print(m['_raw'])

query is a string representing a Sumo query
startTime and endTime can be a datetime, a timedelta ( => now() + timedelta ), or the default None ( => now() )

messages and records are generators, the actual items are not retrieved until they are iterated. Each is just the dict of each messages/record as returned by the Sumo API.

There are a few caveats in the current implementation:

  • requires Python 3.6 due to using type hints
  • timezone handling could use some thought

However before looking at minutiae like that I wanted some feedback about the API, as that's the thing that should get nailed down first. Does this look halfway acceptable?

Cheers
Jarrad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant