Actions72
- Image Actions
- Network Actions
- Node Actions
- Registry Actions
- Secret Actions
- Service Actions
- Stack Actions
- Team Actions
- Template Actions
- User Actions
- Volume Actions
- Webhook Actions
- Config Actions
- Container Actions
- Edge Group Actions
- Edge Stack Actions
Overview
This node integrates with the Portainer API to manage Docker Swarm services. Specifically, the Service - Get Logs operation retrieves logs from a specified Docker Swarm service running in a given environment (endpoint). This is useful for monitoring and debugging services by accessing their output logs directly through n8n workflows.
Typical use cases include:
- Fetching recent logs of a service to analyze its behavior or troubleshoot issues.
- Automating log retrieval for auditing or alerting purposes.
- Integrating service logs into centralized logging or monitoring systems.
For example, you can configure this node to get the last 100 lines of logs including both stdout and stderr from a service identified by its ID in a specific Docker environment managed by Portainer.
Properties
| Name | Meaning |
|---|---|
| Environment ID | The ID of the Portainer environment/endpoint where the Docker service is running. |
| Service ID | The unique identifier of the Docker Swarm service whose logs you want to retrieve. |
| Include Stdout | Whether to include standard output (stdout) logs. Defaults to true. |
| Include Stderr | Whether to include standard error (stderr) logs. Defaults to true. |
| Tail Lines | Number of lines from the end of the logs to retrieve, or "all" to get the entire log. |
| Timestamps | Whether to include timestamps in the returned logs. Defaults to false. |
Output
The node outputs the logs as JSON data under the json field. The logs are returned as a plain text string containing the combined output based on the selected options (stdout, stderr, tail lines, timestamps).
- The output does not include binary data.
- The logs reflect the raw textual output streamed or stored by the Docker service.
Example output structure:
{
"logs": "<string containing the requested logs>"
}
Dependencies
- Requires access to a Portainer instance with API enabled.
- Needs an API key credential configured in n8n to authenticate requests to the Portainer API.
- The node uses the Portainer API endpoint
/endpoints/{environmentId}/docker/services/{serviceId}/logswith query parameters to fetch logs.
Troubleshooting
- Invalid Environment ID or Service ID: If the IDs provided do not exist or are incorrect, the API will return errors indicating resource not found. Verify the IDs in your Portainer dashboard.
- Authentication Errors: Ensure the API key credential is valid and has sufficient permissions to access the environment and service logs.
- Empty Logs: If no logs are returned, check if the service is running and producing output. Also verify the
includeStdoutandincludeStderrflags. - Timeouts or Network Issues: Confirm that n8n can reach the Portainer API URL and that there are no firewall or network restrictions.
- Large Log Data: Requesting all logs (
tailLinesset to "all") for very large services may cause performance issues. Use tailing with a limited number of lines when possible.