Git Product home page Git Product logo

cnexporter's Introduction

cnexporter

Prometheus exporter for certain Docker container metadata metrics

CodeQL build Github All Releases staticcheck

cnexporter uses Go Docker SDK to poll Docker API for a handful of container data.

What it does

The exporter publishes several custom metrics via its /metrics endpoint:

  • cnexporter_containers_total: Gauge, total number of containers existing on the reporting system;

  • cnexporter_containers_running Gauge, number of Docker containers with state running;

  • cnexporter_containers_created Gauge, number of containers with state created;

  • cnexporter_containers_exited Gauge, number of containers with state exited;

  • cnexporter_containers_metadata Gauge, always reports 0. This metric contains the following labels:

    • id
    • image: name of the registry image
    • name: name of the container itself
    • status: e.g. Up 10 days (healthy) (taken directly from the API)
    • state: running, exited, etc.

Also, all metrics expose the nodename label that is set to the reporting system's hostname. This is done to allow matching with node_uname_info metric provided by https://github.com/prometheus/node_exporter, and for other people like me who need this way of querying Prometheus per-node.

Rationale

I was frustrated with https://github.com/google/cadvisor, how convoluted and bloated it is (I failed to get some of the simple container metadata from it). Also, sadly, https://github.com/prometheus-net/docker_exporter (which provided certain useful container metadata) was decommissioned.

So I decided to write a dead-simple and lightweight tool that would give me the specific overview metrics that I need in my work.

Installation

Grab a binary from the Releases page (Linux x86_64/amd64 only).

Alternatively, compile the exporter yourself (you will need at least Go 1.18).

make install

This will put cnexporter under /usr/bin by default (customizable via the PREFIX environment variable).

Or manually call go build main.go, compiling for whatever platform you want.

Deployment

Just run it in whatever persistent way you prefer. If you want to go the systemd way, there's an example .service file in the repo.

Arguments

As of now, there are but two options that you can set via CLI (aside from --version):

--port: set a port for publishing the Prometheus exporter metrics (default: 9200);

--timeout: how often the tool will poll Docker API for information, in seconds (default: 15).

cnexporter's People

Contributors

corvus-migratorius avatar corvus-sapiens avatar renovate[bot] avatar

Stargazers

Will Kleinhenz avatar

Watchers

Danila Danilkin avatar  avatar

cnexporter's Issues

Container status duration in seconds

Transform the Docker's unwieldy "Up 10 days" status string into an integer (seconds), facilitating downstream analysis, visualization (e.g. Grafana) and alerting.

Container exit code

Report container exit code (if any) as a separate label, for ease of processing and alerting.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/codeql.yml
  • actions/checkout v4
  • github/codeql-action v2
  • github/codeql-action v2
  • github/codeql-action v2
.github/workflows/go.yml
  • actions/checkout v4
  • actions/setup-go v4
.github/workflows/staticcheck.yaml
  • actions/checkout v4
  • WillAbides/setup-go-faster v1.12.0
gomod
go.mod
  • go 1.18
  • github.com/akamensky/argparse v1.4.0
  • github.com/docker/docker v24.0.6+incompatible
  • github.com/prometheus/client_golang v1.16.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.