Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First attempt: Simple API #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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.

None yet

1 participant