Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
- name: setup Go
uses: actions/setup-go@v2
with:
go-version: '1.23.8'
go-version: '1.25.6'

- uses: actions/checkout@v4
with:
Expand Down
41 changes: 19 additions & 22 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,43 @@ on:
jobs:
image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: setup buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
- name: Checkout repository
uses: actions/checkout@v4

- name: login to docker hub
- name: Log in to the GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: generate docker metadata
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
ncabatoff/process-exporter
# generate Docker tags based on the following events/attributes
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=tag
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=sha

- name: build docker image and, if not PR, push
uses: docker/build-push-action@v5
- name: Build Docker image and push if it's not PR
uses: docker/build-push-action@v6
with:
file: ./Dockerfile
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.23.8'
go-version: '1.25.6'

- run: make test

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> 1.25"
args: release --rm-dist
version: "~> 2.13"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 4 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: 2
builds:
- main: cmd/process-exporter/main.go
binary: process-exporter
Expand Down Expand Up @@ -27,8 +28,8 @@ archives:
checksum:
name_template: checksums.txt
nfpms:
- homepage: https://github.com/ncabatoff/process-exporter
maintainer: nick.cabatoff+procexp@gmail.com
- homepage: https://github.com/selectel/process-exporter
maintainer: selectel
description: Prometheus exporter to report on processes running
license: MIT
formats:
Expand All @@ -51,7 +52,7 @@ nfpms:
preremove: "packaging/scripts/preremove.sh"
release:
github:
owner: ncabatoff
owner: selectel
name: process-exporter
draft: false
prerelease: true
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM --platform=$BUILDPLATFORM golang:1.23.8 AS build
FROM --platform=$BUILDPLATFORM golang:1.25.6 AS build
ARG TARGETARCH
ARG BUILDPLATFORM
WORKDIR /go/src/github.com/ncabatoff/process-exporter
WORKDIR /go/src/github.com/selectel/process-exporter
ADD . .

# Build the process-exporter command inside the container.
RUN CGO_ENABLED=0 GOARCH=$TARGETARCH make build

FROM scratch

COPY --from=build /go/src/github.com/ncabatoff/process-exporter/process-exporter /bin/process-exporter
COPY --from=build /go/src/github.com/selectel/process-exporter/process-exporter /bin/process-exporter

# Run the process-exporter command by default when the container starts.
ENTRYPOINT ["/bin/process-exporter"]
Expand Down
4 changes: 0 additions & 4 deletions Dockerfile.cloudbuild

This file was deleted.

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pkgs = $(shell go list ./...)

PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
DOCKER_IMAGE_NAME ?= ncabatoff/process-exporter
DOCKER_IMAGE_NAME ?= selectel/process-exporter

BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILDDATE ?= $(shell date --iso-8601=seconds)
Expand Down Expand Up @@ -64,10 +64,10 @@ docker:
docker run --rm --volumes-from configs "$(DOCKER_IMAGE_NAME):$(TAG_VERSION)" $(SMOKE_TEST)

dockertest:
docker run --rm -it -v `pwd`:/go/src/github.com/ncabatoff/process-exporter golang:1.23.8 make -C /go/src/github.com/ncabatoff/process-exporter test
docker run --rm -it -v `pwd`:/go/src/github.com/selectel/process-exporter golang:1.25.6 make -C /go/src/github.com/selectel/process-exporter test

dockerinteg:
docker run --rm -it -v `pwd`:/go/src/github.com/ncabatoff/process-exporter golang:1.23.8 make -C /go/src/github.com/ncabatoff/process-exporter build integ
docker run --rm -it -v `pwd`:/go/src/github.com/selectel/process-exporter golang:1.25.6 make -C /go/src/github.com/selectel/process-exporter build integ

.PHONY: update-go-deps
update-go-deps:
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# process-exporter
Prometheus exporter that mines /proc to report on selected processes.

[release]: https://github.com/ncabatoff/process-exporter/releases/latest
[release]: https://github.com/selectel/process-exporter/releases/latest

[![Release](https://img.shields.io/github/release/ncabatoff/process-exporter.svg?style=flat-square")][release]
[![Release](https://img.shields.io/github/release/selectel/process-exporter.svg?style=flat-square")][release]
[![Powered By: GoReleaser](https://img.shields.io/badge/powered%20by-goreleaser-green.svg?branch=master)](https://github.com/goreleaser)
![Build](https://github.com/ncabatoff/process-exporter/actions/workflows/build.yml/badge.svg)
![Build](https://github.com/selectel/process-exporter/actions/workflows/build.yml/badge.svg)

Some apps are impractical to instrument directly, either because you
don't control the code or they're written in a language that isn't easy to
Expand All @@ -14,7 +14,7 @@ instrument with Prometheus. We must instead resort to mining /proc.
## Installation

Either grab a package for your OS from the [Releases][release] page, or
install via [docker](https://hub.docker.com/r/ncabatoff/process-exporter/).
install via Docker from GitHub Container Registry.

## Running

Expand All @@ -27,7 +27,7 @@ Usage:
or via docker:

```
docker run -d --rm -p 9256:9256 --privileged -v /proc:/host/proc -v `pwd`:/config ncabatoff/process-exporter --procfs /host/proc -config.path /config/filename.yml
docker run -d --rm -p 9256:9256 --privileged -v /proc:/host/proc -v `pwd`:/config ghcr.io/selectel/process-exporter --procfs /host/proc -config.path /config/filename.yml

```

Expand Down Expand Up @@ -421,3 +421,9 @@ process_open_fds 10
```

For further information about TLS configuration, please visit: [exporter-toolkit](https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md)

## Profiling with pprof

HTTP server with pprof **disable** by default.
For enable profiling use `--profiling.enabled` option.
The address and port are specified using the options `--profiling.host` (default:`localhost`) and `--profiling.port` (default:`6060`)
49 changes: 0 additions & 49 deletions cloudbuild.release.yaml

This file was deleted.

32 changes: 0 additions & 32 deletions cloudbuild.yaml

This file was deleted.

44 changes: 37 additions & 7 deletions cmd/process-exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,31 @@ package main

import (
"context"
"errors"
"flag"
"fmt"
"log"
"net"
"net/http"
_ "net/http/pprof"
"net/http/pprof"
"os"
"os/signal"
"regexp"
"strconv"
"strings"
"syscall"
"time"

"github.com/ncabatoff/fakescraper"
common "github.com/ncabatoff/process-exporter"
"github.com/ncabatoff/process-exporter/collector"
"github.com/ncabatoff/process-exporter/config"
"github.com/prometheus/client_golang/prometheus"
verCollector "github.com/prometheus/client_golang/prometheus/collectors/version"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/promlog"
"github.com/prometheus/common/promslog"
promVersion "github.com/prometheus/common/version"
"github.com/prometheus/exporter-toolkit/web"
common "github.com/selectel/process-exporter"
"github.com/selectel/process-exporter/collector"
"github.com/selectel/process-exporter/config"
)

// Version is set at build time use ldflags.
Expand Down Expand Up @@ -183,11 +186,14 @@ func main() {
showVersion = flag.Bool("version", false,
"print version information and exit")
removeEmptyGroups = flag.Bool("remove-empty-groups", false, "forget process groups with no processes")
profilingEnabled = flag.Bool("profiling.enabled", false, "enable profiling via web interface host:port/debug/pprof/")
profilingPort = flag.Int("profiling.port", 6060, "port to listen profiling server")
profilingHost = flag.String("profiling.host", "localhost", "host to listen profiling server")
)
flag.Parse()

promlogConfig := &promlog.Config{}
logger := promlog.New(promlogConfig)
promlogConfig := &promslog.Config{}
logger := promslog.New(promlogConfig)

if *showVersion {
fmt.Printf("%s\n", promVersion.Print("process-exporter"))
Expand Down Expand Up @@ -275,6 +281,25 @@ func main() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGTERM, syscall.SIGINT)

pprofMux := http.NewServeMux()
pprofMux.HandleFunc("/debug/pprof/", pprof.Index)
pprofMux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
pprofMux.HandleFunc("/debug/pprof/profile", pprof.Profile)
pprofMux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
pprofMux.HandleFunc("/debug/pprof/trace", pprof.Trace)

pprofListenAddr := net.JoinHostPort(*profilingHost, strconv.Itoa(*profilingPort))
pprofServer := &http.Server{Addr: pprofListenAddr, Handler: pprofMux}

if *profilingEnabled {
go func() {
logger.Info("Listening profile server on", "address", pprofListenAddr)
if err := pprofServer.ListenAndServe(); !errors.Is(err, http.ErrServerClosed) {
log.Fatalf("Failed to start the profiling server: %v", err)
}
}()
}

http.Handle(*metricsPath, promhttp.Handler())

http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -298,6 +323,11 @@ func main() {
if err := server.Shutdown(ctx); err != nil {
log.Fatalf("Server Shutdown Failed: %v", err)
}
if *profilingEnabled {
if err := pprofServer.Shutdown(ctx); err != nil {
log.Fatalf("Profiling server shutdown failed: %v", err)
}
}
}()

if err := web.ListenAndServe(server, &web.FlagConfig{
Expand Down
Loading