boundless-lifeguard-61788
10/07/2024, 8:43 PMLogs
No logs found
jolly-florist-66728
10/07/2024, 8:43 PMvalues.yaml
file used for your Flyte Helm installation.
1. Configure Logging Links: Update your values.yaml
file to include the log provider and template URIs. For example, to use Grafana Loki, you can add the following configuration:
task_logs:
plugins:
logs:
kubernetes-enabled: true
cloudwatch-enabled: false
stackdriver-enabled: false
templates:
- displayName: Grafana Loki
templateUris:
- 'http://grafana-loki.loki.svc.cluster.local:3100/loki/api/v1/query_range?start={{.podUnixStartTime}}&end={{.podUnixFinishTime}}&query={namespace="{{.namespace}}"}'
messageFormat: 2
scheme: TaskExecution
2. Ensure Proper Configuration: Make sure the configuration is correctly applied and that the log provider (e.g., Grafana Loki) is accessible from your Flyte deployment.
3. Logging in Tasks: Use the Flytekit logger in your Python tasks to log messages. For example:
import logging
def my_task():
logging.info("This is an info message")
logging.warning("This is a warning message")
logging.error("This is an error message")
For more details, refer to the Flyte documentation on configuring logging links.
Would you like more detail on any specific part of this process?
Sources:
- Flyte Documentation on Configuring Logging Links
- Flyte Community Discussion on Logging 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.boundless-lifeguard-61788
10/07/2024, 8:45 PMjolly-florist-66728
10/07/2024, 8:45 PMfrom flytekit import task, workflow
@task
def my_task():
print("This is a print statement")
print("Another log message")
@workflow
def my_workflow():
my_task()
if __name__ == "__main__":
my_workflow()
2. Environment Configuration: Ensure that the environment variable PYTHONUNBUFFERED
is set to 1
to make sure that the print statements are flushed immediately. This can be done in the Dockerfile or directly in the task definition.
Example in Dockerfile:
ENV PYTHONUNBUFFERED=1
Example in task definition:
import os
os.environ["PYTHONUNBUFFERED"] = "1"
3. Local Execution: When running locally, you can set the FLYTE_SDK_LOGGING_LEVEL
to 10
to see more detailed logs.
import os
os.environ["FLYTE_SDK_LOGGING_LEVEL"] = "10"
For more details, refer to the Flyte community discussion on local logging.
Would you like more detail on any specific part of this process?
Sources:
- Flyte Community Discussion on Local Logging
- Flyte Community Discussion on Print Statements 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.