# Problem with cloudwatch logs

**URL:** <https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840>\
**Category:** Serverless Framework\
**Created:** [June 22, 2018, 8:36am UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840 "2018-06-22T08:36:42Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefanodotit](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@stefanodotit](https://forum.serverless.com/u/stefanodotit)\
**Post date:** [June 22, 2018, 8:36am UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840/1 "2018-06-22T08:36:42Z")

</div>

Hi  
I used a lot of console.log in my js app but I can’t see it on cloudwatch. No log is present  
here’s my config:

> functions:  
> app:  
> handler: index.handler  
> events:  
> - http:  
> path: /  
> method: get  
> - cloudwatchLog:  
> logGroup: ‘/aws/lambda/a’  
> filter: ‘appFilter’  
> resources:  
> Resources:  
> AuthAccessLogs:  
> Type: AWS::Logs::LogGroup  
> Properties:  
> LogGroupName: ‘/aws/lambda/a’

---

<div class="post-metadata">

**Author:** ![jeremydaly](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jeremydaly/32/2104_2.png) [@jeremydaly](https://forum.serverless.com/u/jeremydaly)\
**Post date:** [June 22, 2018, 2:47pm UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840/2 "2018-06-22T14:47:27Z")

</div>

The `cloudwatchLog` property is monitoring **EVENTS** from `/aws/lambda/a`, not writing to it. When something gets written to that log, anything that matches `appFilter` should get sent in as an event to this function.

`console.log` statements write to the the default log group created by Serverless. This is in the form of `/aws/lambda/your-function-name`.

---

<div class="post-metadata">

**Author:** ![stefanodotit](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@stefanodotit](https://forum.serverless.com/u/stefanodotit)\
**Post date:** [June 23, 2018, 8:53am UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840/3 "2018-06-23T08:53:51Z")

</div>

Thank u for your answer  
I don’t use EVENTS so I removed the all resources and cloudwatchLog  
I uploaded again my functions but I still continue to don’t see any logs in cloudwatch, no stream log, nothing

---

<div class="post-metadata">

**Author:** ![jeremydaly](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jeremydaly/32/2104_2.png) [@jeremydaly](https://forum.serverless.com/u/jeremydaly)\
**Post date:** [June 23, 2018, 7:47pm UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840/4 "2018-06-23T19:47:22Z")

</div>

Have you tried executing your function from the Lambda dashboard? That will show you want you are logging and will link you directly to the correct CloudWatch log group.

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [June 24, 2018, 12:04am UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840/5 "2018-06-24T00:04:16Z")

</div>

The log groups should be visible immediately after deployment. The log streams won’t be visible until after your Lambda has executed.

1. Go to _CloudWatch_ in the AWS Console then _Logs_. If you don’t see the log groups then check you’re looking in the same region you deployed your Lambda to.
2. If you are certain you’re in the right region then go to _Lambda_ in the AWS Console. Click on one of the Lambda you have executed recently. Go to the _Monitoring_ tab and confirm the Lambda was executed. If your Lambda hasn’t been executed then you need to figure that out first. Click on _Jump to Logs_ to see log entries. You might not see log entries (sometimes it happens when viewing all streams) but if you go back to the log group using the breadcrumbs you will see all of the log streams. Clicking on the most recent log stream will show you the entries.

If everything else fails - is it possible you deleted the log groups manually? Try completely removing the project using `sls remove` then deploying using `sls deploy`. Repeat the checks.

---

<div class="post-metadata">

**Author:** ![stefanodotit](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@stefanodotit](https://forum.serverless.com/u/stefanodotit)\
**Post date:** [June 25, 2018, 4:49pm UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840/6 "2018-06-25T16:49:48Z")

</div>

I think maybe I’ve another type of problem:  
now my serverless.yml is so simple:

```
functions:
    auth:
        handler: index.auth
        cors: true
    app:
        handler: index.handler
        events:
            - http: 
                path: /
                method: get
                authorizer: auth
                cors: true
            - http: 
                path: asd
                method: get
                authorizer: auth
                cors: true

```

and my auth function is:

```
exports.auth = (event, context, callback) => {
s.auth = (event, context, callback) => {
console.log("abc")
return callback('Unauthorized - no access token')
}

```

I cannot see the log but also in graphics I don’t see execution time and execution count, still 0!  
when I’ll try to access at my lambda from the url continue to say:  
`{"message":"Unauthorized"}`

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [June 25, 2018, 10:47pm UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840/7 "2018-06-25T22:47:28Z")

</div>

The `cors: true` on the `auth` handler won’t do anything.

Are you using Node 6.19 or 8.10?

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [June 25, 2018, 10:48pm UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840/8 "2018-06-25T22:48:23Z")

</div>

Also, can you try triggering the Lambda from the console?

---

<div class="post-metadata">

**Author:** ![stefanodotit](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@stefanodotit](https://forum.serverless.com/u/stefanodotit)\
**Post date:** [June 27, 2018, 4:50pm UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840/9 "2018-06-27T16:50:07Z")

</div>

i’m using 8.10 and i’ll tried also to remove cors:true, no changes

how can I try to trigger lambda from the console?

---

<div class="post-metadata">

**Author:** ![jeremydaly](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jeremydaly/32/2104_2.png) [@jeremydaly](https://forum.serverless.com/u/jeremydaly)\
**Post date:** [June 27, 2018, 6:55pm UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840/10 "2018-06-27T18:55:34Z")

</div>

Log in to the AWS Console and go to the Lambda service console. Then click on the function you want to test. This will open up the details of the function. At the top there is an option to “TEST” the function. Click test and then create a sample event. You can use the default or select a preconfigured one from the drop down. Save it, and then click “TEST” again. It will run the function and show you the output and logs with a link to the CloudWatch log group.

---

<div class="post-metadata">

**Author:** ![stefanodotit](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@stefanodotit](https://forum.serverless.com/u/stefanodotit)\
**Post date:** [June 27, 2018, 8:16pm UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840/11 "2018-06-27T20:16:31Z")

</div>

perfect!  
yes if I’ll try to test it on lambda console it works, the log appear and the right message appear too!

Why my auth function doesn’t executed when I call my url endpoint? what’s wrong?

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [June 28, 2018, 4:43am UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840/12 "2018-06-28T04:43:29Z")

</div>

It sounds like you’re using the wrong URL for the endpoint.

Also, it should be

```javascript
return callback(new Error('Unauthorized - no access token'));

```

---

<div class="post-metadata">

**Author:** ![stefanodotit](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@stefanodotit](https://forum.serverless.com/u/stefanodotit)\
**Post date:** [June 28, 2018, 7:26am UTC](https://forum.serverless.com/t/problem-with-cloudwatch-logs/4840/13 "2018-06-28T07:26:12Z")

</div>

I’m currently using the URLs given by serverless deploy console

> endpoints:  
> GET - https:/blablabla.execute-api.eu-west-1.amazonaws.com/staging/
