-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support checkpointing and reading old logs with docker_logs
source
#7358
Comments
Related to #7336 |
Thanks @pgassmann . I agree this would be good to do. I updated it to an enhancement as I believe the current behavior is intentional (albeit undocumented) given the documentation also doesn't document the inverse, that it will pick up logs from before it started. |
docker_logs
source
@jszwedko how are the plans to implement checkpointing and history for docker logs? We are currently experiencing issues with vector sending logs from docker to loki and because of this missing feature we are losing hours of logs. |
@pgassmann unfortunately no movement on this yet. You could consider eschewing the |
The latest release of loki/promtail has support for docker service discovery, which seems to combine service discovery through the api and reading logs from the json files. Supporting checkpointing. That's a major selling point to move back to promtail, as currently with vector we cannot guarantee that all docker logs are transported to loki. |
Checkpointing should be quite trivial to implement by using the vector/src/sources/docker_logs.rs Lines 271 to 275 in b9f661b
The After a restart of vector, it should query for the logs of all saved container checkpoints. even if they are no longer running. (e.g. stopped after vector was stopped) but the remaining logs can still be queried from docker api. cc @bruceg |
Ouch, that sucks. I'm sorry to hear that you last some logs. Your suggestion for the checkpointing strategy makes sense to me. Unfortunately I don't know when exactly we would get to it, but we'd be happy to help support a PR if you (or anyone else) is motivated. |
There hasn't been progress on that for two years now. Our Devs are getting frustrated, because we lose logs during maintenance windows where we reboot the hosts. |
We now switched to promtail for collecting docker container logs. Here's our promtail configuration. scrape_configs:
- job_name: docker
docker_sd_configs:
- host: unix:///var/run/docker.sock
refresh_interval: 5s
# filters:
# - name: name
# values: [test-container]
relabel_configs:
- source_labels: ['__meta_docker_container_label_com_docker_compose_container_number']
target_label: 'compose_container_number'
action: 'replace'
replacement: '${1}'
- source_labels: ['__meta_docker_container_label_com_docker_compose_project']
target_label: 'compose_project'
action: 'replace'
replacement: '${1}'
- source_labels: ['__meta_docker_container_label_com_docker_compose_project_working_dir']
target_label: 'compose_project_working_dir'
action: 'replace'
replacement: '${1}'
- source_labels: ['__meta_docker_container_label_com_docker_compose_oneoff']
target_label: 'compose_oneoff'
action: 'replace'
replacement: '${1}'
- source_labels: ['__meta_docker_container_label_com_docker_compose_service']
target_label: 'compose_service'
action: 'replace'
replacement: '${1}'
- source_labels: ['__meta_docker_container_id']
target_label: 'container_id'
action: 'replace'
- source_labels: ['__meta_docker_container_name']
target_label: 'container_name'
regex: '/(.*)'
action: 'replace'
- source_labels: ['__meta_docker_container_log_stream']
target_label: 'stream'
action: 'replace'
- source_labels: ['__meta_docker_container_log_stream']
target_label: 'source'
action: 'replace'
- source_labels: ['__meta_docker_container_log_stream']
target_label: 'source_type'
action: 'replace'
- target_label: 'category'
replacement: 'dockerlogs'
- target_label: 'job'
replacement: 'docker'
## Map all labels
# - action: labelmap
# regex: '__meta_docker_container_label_(.+)'
# replacement: 'container_labels_${1}'
pipeline_stages:
# combine multiline messages like stacktraces to one message,
# needs configuration in application to prefix logs with [zero-width-space char.](https://unicode-explorer.com/c/200B)
- multiline:
firstline: '^\x{200B}'
max_wait_time: 1s
- drop:
older_than: 4h
drop_counter_reason: "line_too_old" |
Vector Version
Expected Behavior
Docker source has checkpointing and does not miss logs.
When starting, Vector reads all available logs and all new logs. if vector is stopped and started, the logs in the stopped time are read and sent to the configured sink.
Actual Behavior
Logs are only read from the moment when vector is started.
when restarting vector, logs from the containers are missing.
when rebooting and the docker containers are started before vector, the startup logs are missing.
Example Data
Additional Context
docker logs
ordocker-compose logs
and the API provide options to read previous logs.Kubernetes source has checkpointing implemented: https://vector.dev/docs/reference/configuration/sources/kubernetes_logs/#checkpointing
In #1107 in the description, there is this point:
@jszwedko This is not explicitly mentioned in the docker source documentation. https://vector.dev/docs/reference/configuration/sources/docker_logs/#how-it-works
References
Vector Configuration File
The text was updated successfully, but these errors were encountered: