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

Add methods to retrieve logs from logs-queries/list API endpoint #292

Merged
merged 5 commits into from
Jan 7, 2020

Conversation

sendqueery
Copy link
Contributor

The datadog web interface only allows a user to export up to 5k log lines at a time. Sometimes, you just need more than that. This PR adds functionality that allows a user to hit the logs-queries/list API and retrieve any number of logs, along with the corresponding tags and attributes for each.

As this particular API only returns up to 1000 lines at a time, GetLogsListPages() handles the pagination and can retrieve all results.

This has appropriate tests and mock JSON response data, and has been successfully tested for use in a small scraper tool I'm writing for internal use at work.

@sendqueery
Copy link
Contributor Author

Whoops, I should probably link to the API doc: https://docs.datadoghq.com/api/?lang=bash#get-a-list-of-logs

@irabinovitch
Copy link

@sendqueery Thank you for the PR. We have a few folks at Datadog reviewing.

Copy link

@xvello xvello left a comment

Choose a reason for hiding this comment

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

Hello @sendqueery and thank you for the PR!

I am with the Logs Management team and here are my comments on the business-logic side. Please don't hesitate to @ me if you have questions on my comments.

I'll get someone more familiar with the repo to also review the testing, documentation and code style.

log_lists.go Outdated Show resolved Hide resolved
log_lists.go Outdated Show resolved Hide resolved
log_lists_test.go Show resolved Hide resolved
log_lists.go Outdated Show resolved Hide resolved
log_lists.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@bkabrda bkabrda left a comment

Choose a reason for hiding this comment

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

Hey, thanks for taking your time to open a PR. Overall it looks great, I just left couple minor points throughout the code to improve some bits.

log_lists.go Outdated Show resolved Hide resolved
log_lists.go Outdated Show resolved Hide resolved
log_lists.go Outdated Show resolved Hide resolved
log_lists.go Outdated Show resolved Hide resolved
@sendqueery
Copy link
Contributor Author

sendqueery commented Jan 7, 2020

@bkabrda I also changed the naming of QueryTime and Attributes to keep things consistent.

Copy link
Collaborator

@bkabrda bkabrda left a comment

Choose a reason for hiding this comment

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

LGTM now, thanks for addressing all the comments. Merging.

@bkabrda bkabrda merged commit f1bd9ee into zorkian:master Jan 7, 2020
@sendqueery sendqueery deleted the log-queries-list branch January 7, 2020 18:56
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.

4 participants