sumologic-python-sdk
sumologic-python-sdk copied to clipboard
First attempt: Simple API
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