Portainer icon

Portainer

Trabalhe com dados da API do Portainer para gerenciar Docker

Overview

This node integrates with the Portainer API to manage Docker containers and related resources. Specifically, the Container - Get Logs operation retrieves logs from a specified Docker container managed by Portainer. It allows users to fetch stdout and/or stderr logs, control how many lines to retrieve from the end of the log, and optionally include timestamps.

This operation is useful for monitoring container behavior, debugging issues, or auditing container activity. For example, a DevOps engineer can use this node to automatically collect logs from a container after deployment or during runtime to analyze errors or performance.

Properties

Name Meaning
Environment ID The ID of the Portainer environment/endpoint where the container is running.
Container ID The unique identifier of the Docker container whose logs are to be retrieved.
Include Stdout Whether to include standard output (stdout) logs in the response.
Include Stderr Whether to include standard error (stderr) logs in the response.
Tail Lines Number of lines to return from the end of the logs. Can be a number or "all" for all lines.
Timestamps Whether to include timestamps in each log line.

Output

The node outputs the logs as JSON data in the json field of the output item. The logs represent the combined content of stdout and/or stderr streams from the container, depending on the selected options. The logs are returned as plain text lines concatenated into a single string.

No binary data output is produced by this operation.

Dependencies

  • Requires an active Portainer instance accessible via its API.
  • Requires an API key credential configured in n8n to authenticate requests to the Portainer API.
  • The node uses the Portainer API endpoint /endpoints/{environmentId}/docker/containers/{containerId}/logs with query parameters controlling the log retrieval.

Troubleshooting

  • Invalid Environment or Container ID: If the environment ID or container ID is incorrect or does not exist, the API will return an error. Verify that the IDs correspond to valid resources in your Portainer setup.
  • Authentication Errors: Ensure the API key credential is correctly set up and has sufficient permissions to access container logs.
  • Empty Logs: If no logs are returned, check if the container has generated any logs or if the filters (stdout/stderr inclusion, tail lines) exclude all content.
  • Timeouts or Network Issues: Connectivity problems between n8n and the Portainer API may cause request failures. Confirm network accessibility and API availability.

Links and References


This summary is based solely on static analysis of the provided source code and property definitions.

Discussion