You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/06/23 09:57:28 UTC

[GitHub] [airflow] Shadowsong27 opened a new issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Shadowsong27 opened a new issue #9486:
URL: https://github.com/apache/airflow/issues/9486


   <!--
   
   Welcome to Apache Airflow!  For a smooth issue process, try to answer the following questions.
   Don't worry if they're not all applicable; just try to include what you can :-)
   
   If you need to include code snippets or logs, please put them in fenced code
   blocks.  If they're super-long, please use the details tag like
   <details><summary>super-long log</summary> lots of stuff </details>
   
   Please delete these comment blocks before submitting the issue.
   
   -->
   
   <!--
   
   IMPORTANT!!!
   
   PLEASE CHECK "SIMILAR TO X EXISTING ISSUES" OPTION IF VISIBLE
   NEXT TO "SUBMIT NEW ISSUE" BUTTON!!!
   
   PLEASE CHECK IF THIS ISSUE HAS BEEN REPORTED PREVIOUSLY USING SEARCH!!!
   
   Please complete the next sections or the issue will be closed.
   This questions are the first thing we need to know to understand the context.
   
   -->
   
   **Apache Airflow version**:
   
   v1.10.10
   
   **Kubernetes version (if you are using kubernetes)** (use `kubectl version`):
   
   **Environment**:
   
   - **Cloud provider or hardware configuration**: AWS
   - **OS** (e.g. from /etc/os-release): Deployed in ECS Fargate
   - **Install tools**: poetry
   
   **What happened**:
   
   I am trying to display the logs of Fargate Tasks in Airflow UI when using ECSOperator, and it is achieved by providing the following Task argument according to the docs. 
   1. `awslogs_group`
   2. `awslogs_region`
   3. `awslogs_stream_prefix`
   
   However, it failed to work with an error msg 
   ```
   An error occurred (ResourceNotFoundException) when calling the GetLogEvents operation: The specified log stream does not exist
   ```
   
   I went on and examine the source code and realise the log stream in the [source code](https://github.com/apache/airflow/blob/a00e188ded01028409e041130d1e4f02e4e3a109/airflow/providers/amazon/aws/operators/ecs.py#L208) was constructed using this 
   ```
   stream_name = "{}/{}".format(self.awslogs_stream_prefix, task_id)
   ```
   
   where in the [official AWS docs](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html), it states
   
   ```
   The awslogs-stream-prefix option allows you to associate a log stream with the specified prefix, the container name, and the ID of the Amazon ECS task to which the container belongs. If you specify a prefix with this option, then the log stream takes the following format:
   
   prefix-name/container-name/ecs-task-id
   ```
   
   And after I manually patch my container name into the Airflow Task argument `awslogs_stream_prefix` it works (my current workaround).
   
   Personally I am not sure whether this issue arises due to the specific configuration in Fargate i have, or it is generic enough to be considered as a bug.
    
   
   
   
   <!-- (please include exact error messages if you can) -->
   
   **What you expected to happen**: Logs displaying in Airflow Log UI
   
   <!-- What do you think went wrong? --> 
   
   log stream prefix is not dynamically constructed properly
   
   **How to reproduce it**: 
   
   Running any ECS Fargate task with ECS Operator with default awslog configuration should be able to reproduce this.
   
   <!---
   
   As minimally and precisely as possible. Keep in mind we do not have access to your cluster or dags.
   
   If you are using kubernetes, please attempt to recreate the issue using minikube or kind.
   
   ## Install minikube/kind
   
   - Minikube https://minikube.sigs.k8s.io/docs/start/
   - Kind https://kind.sigs.k8s.io/docs/user/quick-start/
   
   If this is a UI bug, please provide a screenshot of the bug or a link to a youtube video of the bug in action
   
   You can include images using the .md sytle of
   ![alt text](http://url/to/img.png)
   
   To record a screencast, mac users can use QuickTime and then create an unlisted youtube video with the resulting .mov file.
   
   --->
   
   
   **Anything else we need to know**:
   
   <!--
   
   How often does this problem occur? Once? Every time etc?
   
   Any relevant logs to include? Put them here in side a detail tag:
   <details><summary>x.log</summary> lots of stuff </details>
   
   -->
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] amirhmk commented on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
amirhmk commented on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-807148449


   > @amirhmk did you able to solve it?
   
   Yes! In my case it was actually a small typo! Make sure the `awslogs_group` exists (maybe?)
   and more importantly `awslogs_steam_prefix` is prefixed with the `task_name` and the `container_name`. 
   
   Also make sure your region is set properly 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] amirrezaJC removed a comment on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
amirrezaJC removed a comment on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-763132502


   I had the same issue and I just removed `awslogs_stream_prefix` and only kept `awslogs_group`
   
   Could you please elaborate more on your solution and why do we need both? I couldn't quite follow how you have fixed it.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] satyarthn edited a comment on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
satyarthn edited a comment on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-919600135


   Per the Documentation
   
   `If you don't specify a prefix with this option, then the log stream is named after the container ID that is assigned by the Docker daemon on the container instance. Because it is difficult to trace logs back to the container that sent them with just the Docker container ID (which is only available on the container instance), we recommend that you specify a prefix with this option.`
   
   I see that in my ECS Task definition, I have the correct settings.
   
   <img width="884" alt="Screen Shot 2021-06-10 at 10 08 10 PM" src="https://user-images.githubusercontent.com/85149961/133350773-677b77c5-3214-422a-8e92-47817c5e78f1.png">
   
   So shouldn't the log stream be generated with the ECS Task ID and not the Docker Runtime Container Id? What could I be missing?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] satyarthn edited a comment on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
satyarthn edited a comment on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-919635087


   Another take on trying to figure out what is happening.
   
   My ECS console shows task_id as this
   
   <img width="1444" alt="Screen Shot 2021-09-14 at 6 53 05 PM" src="https://user-images.githubusercontent.com/85149961/133357721-2580ad0a-9510-4973-bc89-bcc856d3da8e.png">
   
   
   
   But the ECSOperator logs task id as something else
   
   `[2021-09-15 01:46:33,311] {{ecs.py:257}} INFO - ECS Task started: {'tasks': [{'attachments': [{'id': 'e216354d-f05c-465c-967a-50efd86d7e0e', 'type': 'ElasticNetworkInterface', 'status': 'PRECREATED', 'details': `
   
   
   Again, not sure why this is happening. Is it ECSOperator bug or is it me doing something wrong in the way I have defined ECSOperator or ECS Task Definition
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] rmonge-basetis edited a comment on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
rmonge-basetis edited a comment on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-717395686


   Having the same issue here too, thanks to the explanation the fix was easy.
   I think the confusion arises comparing how the _awslogs\_stream\_prefix_ is used in the operator and in AWS. The operator should  take the container-name together with the task-id to build the complete log-stream name, as it is done in AWS.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] satyarthn commented on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
satyarthn commented on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-919597341


   Folks,
   
   I went through this entire thread, but not able to troubleshoot the issue. I am having the same issue.
   
   So I can see CloudWatch has my logs
   
   ```
   CloudWatch
   Log groups
   /ecs/airflow-aws-gcp
   ecs/airflow-aws-gcp/ad93daaa94db48f0bd278c780e946f64
   ```
   
   Note the Stream Name is `ecs/airflow-aws-gcp/ad93daaa94db48f0bd278c780e946f64`
   
   In my AirFlow ECSOperator Definition, I am providing
   
   ```
   ECS_AWSLOGS_GROUP = '/ecs/airflow-aws-gcp'
   ECS_AWSLOGS_STREAM_PREFIX = 'ecs/airflow-aws-gcp'
   ```
   
   In the AirFlow logs, I see
   
   [2021-09-14 23:46:03,310] {{ecs.py:257}} INFO - ECS Task started: {'tasks': [{'attachments': [{'id': '8fdb6419-df5f-4f61-a5d8-9388bb523695', 'type': 'ElasticNetworkInterface', 'status': 'PRECREATED', ......'containers': [{'containerArn': 'arn:aws:ecs:us-east-1:{ACCOUNT_ID}:container/airflow-ecs/ad93daaa94db48f0bd278c780e946f64/02114c6b-5925-45dd-a595-b9608157bdb6 ....
   
   Am I reading it right that,
   
   1. ECS Task id is `8fdb6419-df5f-4f61-a5d8-9388bb523695`
   2. But Log Stream that is generated has the name `ecs/airflow-aws-gcp/ad93daaa94db48f0bd278c780e946f64`
   
   Why the discrepancy? I am assuming that the `ad93daaa94db48f0bd278c780e946f64` is the container instance id and not really the ECS Task Id. Am I configuring my ECS Task definition wrong?
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] satyarthn commented on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
satyarthn commented on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-919635087


   Another take on trying to figure out what is happening.
   
   My ECS console shows task_id as this
   
   <img width="503" alt="Screen Shot 2021-09-14 at 5 21 49 PM" src="https://user-images.githubusercontent.com/85149961/133357508-80b15b22-57fb-4868-8dc2-c7a9ae6ddce4.png">
   
   
   But the ECSOperator logs task id as something else
   
   `[2021-09-15 01:46:33,311] {{ecs.py:257}} INFO - ECS Task started: {'tasks': [{'attachments': [{'id': 'e216354d-f05c-465c-967a-50efd86d7e0e', 'type': 'ElasticNetworkInterface', 'status': 'PRECREATED', 'details': `
   
   
   Again, not sure why this is happening. Is it ECSOperator bug or is it me doing something wrong in the way I have defined ECSOperator or ECS Task Definition
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] nkumar15 commented on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
nkumar15 commented on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-806664472


   @amirhmk did you able to solve it?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] rmonge-basetis commented on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
rmonge-basetis commented on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-717395686


   Having the same issue here too, thanks to the explanation the fix was easy.
   I think the confusion arises comparing how the _awslogs\_stream\_prefix_ is used in the operator and in AWS. The operator should  take the container-name together with the task-id to build the complete log-stream name.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] amirrezaJC commented on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
amirrezaJC commented on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-763132502


   I had the same issue and I just removed `awslogs_stream_prefix` and only kept `awslogs_group`
   
   Could you please elaborate more on your solution and why do we need both? I couldn't quite follow how you have fixed it.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] nkumar15 edited a comment on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
nkumar15 edited a comment on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-808065297


   Thanks @amirhmk for your response.
   Not sure what I am doing wrong.
   
   in cloud watch I see log entries
   log group as /ecs/hello-world
   logstream as /ecs/hello-world/<unique uuid value>
   
   in ecs fargate
   my task name and container name are both hello-world
   and container log configuration is
   
   awslogs-group = /ecs/hello-world
   awslogs-region =ap-southeast-1
   awslogs-stream-prefix = ecs
   
   
   and in airflowecsoperator
    task_id="hello-world"
   awslogs_group="/ecs/hello-world"
   
   I tried with 
   
   awslogs_stream_prefix="/ecs/hello-world"                      -->existing prefix which I can see in cloudwatch
   awslogs_stream_prefix="/hello-world/hello-world"         --> task-name/containername
   
   but in both cases its not working with error
   botocore.errorfactory.ResourceNotFoundException: An error occurred (ResourceNotFoundException) when calling the GetLogEvents operation: The specified log stream does not exist.
   
   Sorry, I understand I am asking too specific here, however just hoping in case anybody can help.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] zdenulo commented on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
zdenulo commented on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-810915867


   I was having similar problems (displaying logs from Fargate to Airflow UI) so I wrote a short article explaining. Not sure if it works in all cases but I solved my issues, hopefully, it could help others as well. [Displaying ECS Fargate logs in Airflow UI](https://www.the-swamp.info/blog/displaying-ecs-fargate-logs-airflow-ui/)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] boring-cyborg[bot] commented on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-648039392


   Thanks for opening your first issue here! Be sure to follow the issue template!
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] amirrezaJC removed a comment on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
amirrezaJC removed a comment on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-763132502


   I had the same issue and I just removed `awslogs_stream_prefix` and only kept `awslogs_group`
   
   Could you please elaborate more on your solution and why do we need both? I couldn't quite follow how you have fixed it.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] nkumar15 commented on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
nkumar15 commented on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-808065297


   Thanks @amirhmk for your response.
   Not sure what I am doing wrong.
   
   in cloud watch I see log entries
   log group as /ecs/hello-world
   logstream as /ecs/hello-world/<unique uuid value>
   
   in ecs fargate
   my task name and container name are both hello-world
   and container log configuration is
   
   awslogs-group = /ecs/hello-world
   awslogs-region =ap-southeast-1
   awslogs-stream-prefix = ecs
   
   
   and in airflowecsoperator
    task_id="hello-world"
   awslogs_group="/ecs/hello-world"
   
   I tried with 
   
   awslogs_stream_prefix="/ecs/hello-world"
   awslogs_stream_prefix="/hello-world/hello-world"
   
   but in both cases its not working. Looking at ECS Operator code it seems it expects prefix as /ecs/hello-world.
   
   Sorry, I understand I am asking too specific here, however just hoping in case anybody can help.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] nkumar15 commented on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
nkumar15 commented on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-811507955


   Thanks @zdenulo finally after reading your article I realized that in awslogs_stream_prefix configuration it should not have leading / in it.
   
   So instead of  /ecs/hello-world  it should be ecs/hello-world".
   
   It worked. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] amirhmk commented on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
amirhmk commented on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-780158534


   I've just started facing this issue as well, as I'm trying to use the `ECSOperator` and have assigned it the correct `awslogs_group` and `awslogs_steam_prefix` (Same as the ones that get created when services create jobs). However, the logs don't seem to get created in CloudWatch, and only the ones that ECS generates itself seems to be created. 
   
   `awslogs_stream_prefix` does NOT need to contain the `task_id` right? 
   
   Currently my `awslogs_group` is something like `/ecs/clustr_a` 
   and `awslogs_steam_prefix` is something like `task_name/container_name`


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] satyarthn edited a comment on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
satyarthn edited a comment on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-919600135


   Per the Documentation
   
   `If you don't specify a prefix with this option, then the log stream is named after the container ID that is assigned by the Docker daemon on the container instance. Because it is difficult to trace logs back to the container that sent them with just the Docker container ID (which is only available on the container instance), we recommend that you specify a prefix with this option.`
   
   I see that in my ECS Task definition, I have the correct settings.
   
   <img width="503" alt="Screen Shot 2021-09-14 at 5 21 49 PM" src="https://user-images.githubusercontent.com/85149961/133356787-88977a80-978b-4a99-a00c-17cbc1c0c432.png">
   
   
   So shouldn't the log stream be generated with the ECS Task ID and not the Docker Runtime Container Id? What could I be missing?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] satyarthn commented on issue #9486: ECSOperator failed to display logs from Cloudwatch after providing log configurations

Posted by GitBox <gi...@apache.org>.
satyarthn commented on issue #9486:
URL: https://github.com/apache/airflow/issues/9486#issuecomment-919600135


   Ok. I believe the problem I am seeing is not with the ECSOperator, but with the AWS's ECS Task Definition UI. When I check the `Auto-configure CloudWatch Logs` , it does not persist. And hence the log stream is not getting generated as expected.
   
   Per the Documentation
   
   `If you don't specify a prefix with this option, then the log stream is named after the container ID that is assigned by the Docker daemon on the container instance. Because it is difficult to trace logs back to the container that sent them with just the Docker container ID (which is only available on the container instance), we recommend that you specify a prefix with this option.`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org