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

New Plugin: Serverless Logs #1691

Merged
merged 7 commits into from
Jul 29, 2016
Merged

New Plugin: Serverless Logs #1691

merged 7 commits into from
Jul 29, 2016

Conversation

eahefnawy
Copy link
Member

@eahefnawy eahefnawy commented Jul 28, 2016

This PR adds a new logging plugin as described in issue #1654 . You can pass any of the following options:

serverless logs --function --stage --region --startTime --duration --tail --pollInterval --filter

@pmuens @flomotlik let me know of any updates you have in mind. 🎯

@eahefnawy eahefnawy added this to the v1.0.0-beta milestone Jul 28, 2016
@eahefnawy eahefnawy self-assigned this Jul 28, 2016
@flomotlik
Copy link
Contributor

@mthenw @nikgraf please also take a look at this to make sure your use cases are covered


## Logs Options

The logs plugin only require the function name you want to fetch the logs for. Other than that there are other options that you can add for extra control:
Copy link
Contributor

Choose a reason for hiding this comment

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

"requires"

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it's a current format but IMHO would be better to list all parameters and mark those which are required. It's easy to miss first line about function name.

@pmuens
Copy link
Contributor

pmuens commented Jul 28, 2016

Really great plugin / great work 👍 !
Looking forward to it 🎉 .

Added some comments!


`Logs` hooks into the [`logs:logs`](/lib/plugins/logs) lifecycle. It will fetch the CloudWatch log group of the provided function and outputs all the log stream events in the terminal.

## Logs Options
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't describe the --function -f option, please add

@eahefnawy
Copy link
Member Author

Thanks for the extra eyes guys! 👀 💃

- `--function` or `-f` The function you want to fetch the logs for. **Required**
- `--stage` or `-s` The stage you want to view the function logs for. If not provided, the plugin will use the default stage listed in `serverless.yml`. If that doesn't exist either it'll just fetch the logs from the `dev` stage.
- `--region` or `-r` The region you want to view the function logs for. If not provided, the plugin will use the default region listed in `serverless.yml`. If that doesn't exist either it'll just fetch the logs from the `us-east-1` region.
- `--startTime` A specific unit in time to start fetching logs from. You can use standard date/time (ie: `2010-10-20` or `1469705761`), or simply a "since string" like `30m` (30 minutes), `2h` (2 hours), `3d` (3 days) and so on. We'll just fetch the logs that happened since then.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are only dates supported by this syntax: 2010-10-20 or could you also do 2010-10-20 14:30? Could you make this a little clearer in the text to make sure people know what and how its supported

Copy link
Member Author

Choose a reason for hiding this comment

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

you can't do 2010-10-20 14:30 because of the space particularly ... it won't work with out CLI as it's not parsed as part of the --startTime option.

Supported strings are basically anything that can be passed to moment.js from the supported ISO 8601 strings, except for strings with spaces (due to the issue mentioned above).

I'm gonna update the docs with this info. Thanks for the heads up 💪

@flomotlik
Copy link
Contributor

@eahefnawy is it possible at the moment to say something like Get 30 minutes of logs, for this function, starting at this start-date? It looks like start-date only allows you to set the date to start getting logs from, but no end-time or way to configure how many logs should be pulled.

This is a bit of an issue once you have larger logs and want to go back a few days but not see everything since then, but only a small part. Imho its fine if we release it like this right now, but we should create another issue to implement an end-time as well (or implement that right away if its easy)

@eahefnawy
Copy link
Member Author

What you described is not currently possible. The 30m string simply means Start at 30 minutes ago. I'm not sure how it would work the way you put it. If we're gonna get 30 minutes of log starting at a certain time, which 30 minutes are we going to get?

Furthermore, AWS doesn't really have an end time support, so we'll have to put this in ourselves. Keep in mind that the filter option makes it easier to navigate through complex logs.

@flomotlik
Copy link
Contributor

flomotlik commented Jul 29, 2016

There seem to be a few bugs with tailing in there,

@flomotlik flomotlik merged commit 6432b9d into v1.0 Jul 29, 2016
@flomotlik flomotlik deleted the logging branch July 29, 2016 13:42
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