lifailon/logporter

By lifailon

Updated 11 months ago

A simple alternative to cAdvisor for getting basic Docker container and custom metrics.

Image
Integration & delivery
Developer tools
Monitoring & observability
1

50K+

lifailon/logporter repository overview

logporter

A simple and lightweight alternative to cAdvisor for getting all basic metrics from Docker containers with support metrics by logs.

Note

On average, CPU consumption is 20 times lower and memory consumption is 10 times lower in the basic metrics mode (including IOps and uptime) compared to `cAdvisor`.

Why collect log counts?

  • Monitor the frequency and number of errors in logs using a custom query.
  • Compare the load increase with the number of logged messages. If the application does not consume many resources, the number of logged messages will reflect the load increase.
  • Speed ​​up log analysis by displaying at what point in time the most messages were received from the standard and error stream.

Warning

Receiving metrics data directly affects performance and CPU load may become higher than `cAdvisor`, this directly depends on the number of running containers, so it is recommended to use it with a small number of running containers or for one in log parsing mode.

Install

  • Run the exporter in a container using an image from Docker Hub:
docker run -d --name logporter \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -p 9333:9333 \
  --restart=unless-stopped \
  lifailon/logporter:latest

Or download the docker-compose file:

mkdir logporter && cd logporter
curl -sSL https://raw.githubusercontent.com/Lifailon/logporter/refs/heads/main/docker-compose.yml -o docker-compose.yml
docker-compose up -d

Use environment variables to apply custom metrics:

LableTypeDefaultDescription
DOCKER_LOG_METRICSbooleanfalseGetting the number of messages in logs from all streams
DOCKER_LOG_CUSTOM_METRICSbooleanfalseEnable getting custom metrics
DOCKER_LOG_CUSTOM_QUERYstring\"(err|error|ERR|ERROR)\"Custom filter query in regex format (default example is equivalent to error level in json format)
  • Connect the new target in the prometheus.yml configuration:
scrape_configs:
  - job_name: logporter
    scrape_interval: 5s
    scrape_timeout: 1s
    static_configs:
      - targets:
        - localhost:9333

Note

If you are using custom metrics to get log counts, change the polling interval and response timeout settings in Prometheus based on the requests processing time in the exporter logs.

Tag summary

Content type

Image

Digest

sha256:c776dabc1

Size

9.3 MB

Last updated

11 months ago

docker pull lifailon/logporter