Skip to content

updated missing api endpoint argument #43

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions scripts/search-job-messages-trend-antimalware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Submits search job, waits for completion, then prints and emails _messages_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script seems specific, so would be great to explain what it does more explicitly.

# (as opposed to records). Pass the query via stdin.
#
# python search-job-messages.py <accessId> <accessKey> <fromDate> <toDate> <timeZone> <byReceiptTime>
#
# Note: fromDate and toDate must be either ISO 8601 date-times or epoch
# milliseconds
#
# Example:
#
# cat python search-job-messages.py <accessId> <accessKey> 1408643380441 1408649380441 PST false

import json
import sys
import time

from sumologic import SumoLogic

# limit may not be necessary (Ciaran)
LIMIT = 1000000

args = sys.argv
sumo = SumoLogic(args[1], args[2], args[3])
fromTime = args[4]
toTime = args[5]
timeZone = args[6]
byReceiptTime = args[7]

delay = 5

q = '_sourceCategory = zeus/trend | where signature_id >= 4000000 AND signature_id <= 4999999 | timeslice 30m | count _timeslice, Action | transpose row _timeslice column Action'

sj = sumo.search_job(q, fromTime, toTime, timeZone, byReceiptTime)

status = sumo.search_job_status(sj)
while status['state'] != 'DONE GATHERING RESULTS':
if status['state'] == 'CANCELLED':
break
time.sleep(delay)
status = sumo.search_job_status(sj)

print(status['state'])

if status['state'] == 'DONE GATHERING RESULTS':
count = status['messageCount']
limit = count if count < LIMIT and count != 0 else LIMIT # may not be necessary (Ciaran)
r = sumo.search_job_messages(sj, limit=limit)
print(r)
18 changes: 8 additions & 10 deletions scripts/search-job-messages.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
# Submits search job, waits for completion, then prints and emails _messages_
# (as opposed to records). Pass the query via stdin.
#
# cat query.sumoql | python search-job-messages.py <accessId> <accessKey> \
# <fromDate> <toDate> <timeZone> <byReceiptTime>
# cat query.sumoql | python search-job-messages.py <accessId> <accessKey> <fromDate> <toDate> <timeZone> <byReceiptTime>
#
# Note: fromDate and toDate must be either ISO 8601 date-times or epoch
# milliseconds
#
# Example:
#
# cat query.sumoql | python search-job-messages.py <accessId> <accessKey> \
# 1408643380441 1408649380441 PST false
# cat query.sumoql | python search-job-messages.py <accessId> <accessKey> 1408643380441 1408649380441 PST false

import json
import sys
import time

from sumologic import SumoLogic

LIMIT = 42
LIMIT = 1000000

args = sys.argv
sumo = SumoLogic(args[1], args[2])
fromTime = args[3]
toTime = args[4]
timeZone = args[5]
byReceiptTime = args[6]
sumo = SumoLogic(args[1], args[2], args[3])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you require the endpoint here?

fromTime = args[4]
toTime = args[5]
timeZone = args[6]
byReceiptTime = args[7]

delay = 5
q = ' '.join(sys.stdin.readlines())
Expand Down
8 changes: 3 additions & 5 deletions scripts/search-job.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Submits search job, waits for completion, then prints and emails results.
# Pass the query via stdin.
#
# cat query.sumoql | python search-job.py <accessId> <accessKey> \
# <endpoint> <fromDate> <toDate> <timeZone> <byReceiptTime>
# cat query.sumoql | python search-job.py <accessId> <accessKey> <endpoint> <fromDate> <toDate> <timeZone> <byReceiptTime>
#
# Note: fromDate and toDate must be either ISO 8601 date-times or epoch
# milliseconds
#
# Example:
#
# cat query.sumoql | python search-job.py <accessId> <accessKey> \
# https://api.us2.sumologic.com/api/v1 1408643380441 1408649380441 PST false
# cat query.sumoql | python search-job.py <accessId> <accessKey> https://api.us2.sumologic.com/api/v1 1408643380441 1408649380441 PST false

import json
import sys
Expand All @@ -21,7 +19,7 @@

from sumologic import SumoLogic

LIMIT = 42
LIMIT = 1000000

args = sys.argv
sumo = SumoLogic(args[1], args[2], args[3])
Expand Down