Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
136ffc5
Add flag for print version
MemberIT Nov 15, 2024
500c894
Add installation of specific version
MemberIT Nov 15, 2024
2658190
ebpf: improve protocol identification accuracy
def Jan 6, 2025
67a13bb
Merge pull request #166 from coroot/protocol_detection_accuracy
def Jan 6, 2025
c8449aa
instance metadata: add support for Alibaba Cloud
def Jan 7, 2025
4f95b6b
Merge pull request #167 from coroot/alibaba_metadata
def Jan 7, 2025
75b0def
Merge pull request #141 from tribunadigital/feat_version_flag
apetruhin Jan 14, 2025
a73919b
add support for hybrid cgroup mode with both V1 and V2 enabled
def Jan 21, 2025
77f223d
Merge pull request #169 from coroot/cgroup_hybrid_mode
def Jan 21, 2025
eb347a3
instance metadata: add support for Scaleway
def Jan 21, 2025
91cd15d
Merge pull request #170 from coroot/scaleway_metadata
def Jan 21, 2025
71f2633
image: add container image labels
apetruhin Jan 23, 2025
7ab7a68
application types: add OpenSearch and VictoriaMetrics
def Jan 31, 2025
ff54f40
Merge pull request #173 from coroot/more_app_types
def Jan 31, 2025
0789560
containers: invalidate ignored containers cache
apetruhin Feb 4, 2025
b64d949
Merge pull request #174 from coroot/invalidate_ingnored_containers_cache
apetruhin Feb 4, 2025
e223b38
CI: pin the ubuntu version
apetruhin Feb 4, 2025
4a2859b
release: pin the ubuntu version
apetruhin Feb 4, 2025
f14f9a1
group connections to AWS services by FQDN instead of IPs
def Feb 11, 2025
96a31bf
Merge pull request #176 from coroot/collapse_aws_services_external_ips
def Feb 11, 2025
50caf2c
application types: add Coroot
apetruhin Feb 12, 2025
2e749e9
Merge pull request #177 from coroot/app_types_coroot
apetruhin Feb 12, 2025
1260e7f
enhance accuracy of cgroup2 base path detection
def Feb 14, 2025
5306dcd
Merge pull request #179 from coroot/fix_cgroup2_path
def Feb 14, 2025
aa5f2cd
tls: avoid reading the entire `.text` section to reduce memory alloca…
apetruhin Mar 3, 2025
8c3e98d
Merge pull request #181 from coroot/tls_go_memory_allocations_optimiz…
apetruhin Mar 3, 2025
9b7636b
fix detection of actual destination for TCP connections
def Mar 12, 2025
8830bf5
Merge pull request #182 from coroot/fix_actual_dest
def Mar 12, 2025
ecbf82e
using FQDNs as destinations when they are resolved into a list of pub…
def Mar 12, 2025
e1d84fb
Merge pull request #183 from coroot/per_conn_metric_optimization
def Mar 13, 2025
42ae641
skip reporting `ip_to_fqdn` for collapsed addresses
def Mar 13, 2025
1a61557
Merge pull request #184 from coroot/per_conn_metric_optimization
def Mar 13, 2025
d9e2797
Update README.md
def Mar 24, 2025
7b32be0
add `app_id`, `az`, and `region` labels to container metrics
def Mar 28, 2025
dd5620f
Merge pull request #186 from coroot/additional_metric_labels
def Mar 28, 2025
f77ec01
logparser v1.1.8
apetruhin Apr 9, 2025
117ada7
Merge pull request #187 from coroot/logparser_1.1.8
apetruhin Apr 9, 2025
8981388
bump cilium version (fix #188)
def Apr 9, 2025
f46e230
Merge pull request #190 from coroot/bump_cilium_version
def Apr 9, 2025
38728eb
Bump github.com/opencontainers/runc from 1.1.12 to 1.2.0
dependabot[bot] Apr 9, 2025
7bf070a
Merge pull request #191 from coroot/dependabot/go_modules/github.com/…
def Apr 9, 2025
1d18580
Bump github.com/Azure/azure-sdk-for-go/sdk/azidentity
dependabot[bot] Apr 9, 2025
c1a383d
Merge pull request #192 from coroot/dependabot/go_modules/github.com/…
def Apr 9, 2025
6b5a975
Bump github.com/containerd/containerd from 1.6.26 to 1.6.38
dependabot[bot] Apr 9, 2025
7f1b0df
Merge pull request #193 from coroot/dependabot/go_modules/github.com/…
def Apr 9, 2025
9cb326e
python: restrict uprobe/uretprobe to the specified PID only
def Apr 11, 2025
77b71dc
Merge pull request #194 from coroot/fix_python_metrics
def Apr 11, 2025
33afce4
build(deps): bump github.com/ClickHouse/ch-go from 0.62.0 to 0.65.0
dependabot[bot] Apr 12, 2025
6092ea6
profiling: add support for perf map files
def Apr 18, 2025
e140b32
profiling: enable full python file names
def Apr 18, 2025
f0260bf
Merge pull request #196 from coroot/profiler_improvements
def Apr 18, 2025
bff74b8
logparser v1.1.9 (coroot/coroot#540)
apetruhin Apr 18, 2025
5aa1664
Merge pull request #197 from coroot/logparser_1.1.9
apetruhin Apr 18, 2025
635abc6
Merge pull request #129 from nudgebee/dependabot/go_modules/github.co…
mayankpande88 Apr 19, 2025
16b5af7
build(deps): bump golang.org/x/net from 0.36.0 to 0.38.0
dependabot[bot] Apr 19, 2025
1c219ae
better application type detection
def Apr 23, 2025
52e0cd8
Merge pull request #198 from coroot/app_types
def Apr 23, 2025
2c71422
fix NsPid parsing (fixes #199)
def Apr 24, 2025
d4f8cbb
Merge pull request #200 from coroot/fix_199
def Apr 24, 2025
a0da66a
allow excluding specific HTTP paths from metrics (e.g, health checks)
def Apr 28, 2025
6455c18
Merge pull request #202 from coroot/http_metrics_filter
def Apr 28, 2025
93fd1c1
infra: dev registry change
blue4209211 Apr 28, 2025
2011fb5
Merge pull request #132 from nudgebee/infra_change
saiprasadpotdar Apr 29, 2025
7914ec6
mprove cgroup detection logic for mixed v1 and v2
def Apr 29, 2025
8b7e5a6
Merge pull request #203 from coroot/fix_hybrid_cgroups
def Apr 29, 2025
68e454e
allow excluding specific HTTP requests from metrics and traces (e.g, …
def Apr 29, 2025
7d230fe
Merge pull request #204 from coroot/http_request_filtration
def Apr 29, 2025
eda7bbf
Merge pull request #130 from nudgebee/dependabot/go_modules/golang.or…
mayankpande88 May 13, 2025
f511d98
add support for container allow and deny lists
def May 19, 2025
9b2f589
Merge pull request #206 from coroot/container_filters
def May 19, 2025
a330c8c
metadata: add support for IBM cloud
def May 21, 2025
d01561f
Merge pull request #208 from coroot/cloud_metadata_ibm
def May 21, 2025
1e4f796
metrics: add config option for max label value length
def May 21, 2025
f814092
Merge pull request #209 from coroot/max_label_length
def May 21, 2025
0e74da3
fix handling of cloud metadata overrides
def May 21, 2025
d48cf26
Merge pull request #210 from coroot/fix_cloud_metadata_overrides
def May 21, 2025
e410668
fix memory leak in HTTP/2 parser
def May 23, 2025
f56d905
Merge pull request #211 from coroot/http2_parser_fix
def May 23, 2025
6f5d688
improve error handling in ClickHouse protocol parser
def May 23, 2025
accc203
Merge pull request #212 from coroot/error_handling_in_ch_protocol_par…
def May 23, 2025
1b88273
Merge remote-tracking branch 'upstream/main' into rebase-23-5
mayankpande88 May 23, 2025
3c997dd
Merge pull request #133 from nudgebee/rebase-23-5
mayankpande88 May 23, 2025
ccd35cc
build(deps): bump github.com/cilium/cilium from 1.17.2 to 1.17.3
dependabot[bot] May 23, 2025
1ea6a19
Merge pull request #134 from nudgebee/dependabot/go_modules/github.co…
mayankpande88 May 23, 2025
5181a8e
remove usage of Prometheus WAL
def May 27, 2025
d1c8216
Merge pull request #213 from coroot/remove_prometheus_wal
def May 27, 2025
65b2bf6
add GPU metrics
def May 30, 2025
7a43425
Merge pull request #216 from coroot/gpu_metrics
def Jun 2, 2025
a632481
metrics: log successful exports
apetruhin Jun 2, 2025
564d0ad
prometheus: avoid retaining compression buffer between iterations
def Jun 3, 2025
6d71571
Merge pull request #217 from coroot/fix_mem_leak
def Jun 3, 2025
e094f1c
Merge remote-tracking branch 'upstream/main' into rebase-23-5
mayankpande88 Jun 3, 2025
bd59e93
Merge remote-tracking branch 'origin/main' into rebase-23-5
mayankpande88 Jun 3, 2025
5f6b5bd
fix: fix for docker build
mayankpande88 Jun 4, 2025
89d6941
fix: fix for build
mayankpande88 Jun 4, 2025
21192f5
Merge pull request #137 from nudgebee/rebase-23-5
mayankpande88 Jun 9, 2025
45e39cb
chore: added az/region metric for bytes transferred
mayankpande88 Jun 10, 2025
8d1ae57
Merge pull request #140 from nudgebee/fix-pattern-detection
mayankpande88 Jun 10, 2025
508dda9
Merge pull request #139 from nudgebee/fix-az-metric
blue4209211 Jun 11, 2025
a4646ff
chore: fix for ci (#142)
mayankpande88 Jun 11, 2025
952bed6
chore: fix for high cves (#143)
mayankpande88 Jun 11, 2025
d4e025f
chore: fix for high cves
mayankpande88 Jun 11, 2025
943ac41
Merge pull request #144 from nudgebee/fix-high-cves
blue4209211 Jun 11, 2025
c3d7e2f
Merge pull request #141 from nudgebee/main
mayankpande88 Jun 11, 2025
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
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ on:

jobs:
GO:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- run: sudo apt install -y libsystemd-dev
go-version: '1.23.8'
- name: Install systemd headers
run: |
sudo apt-get update
sudo apt-get install -y libsystemd-dev
- name: gofmt -l .
run: files=$(gofmt -l .); if [[ -n "$files" ]]; then echo "$files"; exit 1; fi
- name: goimports -l .
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dev-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
with:
platforms: linux/amd64,linux/arm64
context: .
file: 'Dockerfile.alpine'
file: 'Dockerfile'
push: true
tags: |
280501305789.dkr.ecr.us-east-1.amazonaws.com/nudgebee-node-agent:${{ env.tag }}
864186153326.dkr.ecr.us-east-1.amazonaws.com/nudgebee-node-agent:${{ env.tag }}
2 changes: 1 addition & 1 deletion .github/workflows/prod-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
with:
context: .
platforms: linux/amd64,linux/arm64
file: 'Dockerfile.alpine'
file: 'Dockerfile'
push: true
tags: |
740395098545.dkr.ecr.us-east-1.amazonaws.com/nudgebee-node-agent:${{ env.tag }}
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ env:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
permissions:
contents: write
packages: write
Expand All @@ -36,7 +36,7 @@ jobs:
type=ref,event=pr
type=semver,pattern={{version}}

- uses: docker/build-push-action@v5
- uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
Expand Down
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
FROM golang:1.23-bullseye AS builder
RUN apt update && apt install -y libsystemd-dev
FROM golang:1.23.10-bullseye AS builder

RUN apt-get update \
&& apt-get install -y --no-install-recommends libsystemd-dev \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /tmp/src
COPY go.mod .
COPY go.sum .
RUN go mod download
COPY . .
ARG VERSION=unknown
RUN CGO_ENABLED=1 go build -mod=readonly -ldflags "-X main.version=$VERSION" -o coroot-node-agent .
RUN CGO_ENABLED=1 go build -mod=readonly -ldflags "-extldflags='-Wl,-z,lazy' -X 'github.com/coroot/coroot-node-agent/flags.Version=${VERSION}'" -o coroot-node-agent .

FROM registry.access.redhat.com/ubi9/ubi
FROM registry.access.redhat.com/ubi9/ubi-minimal AS runtime

ARG VERSION=unknown

COPY --from=builder /tmp/src/coroot-node-agent /usr/bin/coroot-node-agent
ENTRYPOINT ["coroot-node-agent"]

ENTRYPOINT ["coroot-node-agent"]
48 changes: 25 additions & 23 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
FROM golang:1.23-alpine as build-stage
# Set destination for COPY
WORKDIR /app
RUN apk add --no-cache --update go gcc g++ bash git
RUN echo "unicode=\"YES\"" >> /etc/rc.conf && \
apk add --no-cache --virtual .build_deps \
autoconf file libc-dev make pkgconf python3 py3-pip ninja \
util-linux pciutils usbutils coreutils binutils findutils grep \
build-base abuild binutils binutils-doc gcc-doc gperf libcap libcap-dev \
valgrind-dev libmount && pip3 install meson --break-system-packages

RUN cd /tmp && git clone https://github.com/systemd/systemd
# Build stage
FROM golang:1.23.8-alpine AS builder

# RUN cd /tmp/systemd && \
# meson build && \
# ninja build
# Install build tools
RUN apk add --no-cache build-base

RUN apk add elogind-dev
# Set up workspace
WORKDIR /app

COPY go.mod go.sum ./
# Copy go mod files and download dependencies
COPY go.mod .
COPY go.sum .
RUN go mod download

RUN go mod download
# Copy the rest of the code
COPY . .

COPY ./ ./
# Build statically linked binary
ARG VERSION=unknown
RUN CGO_ENABLED=1 go build -mod=readonly -ldflags "-X main.version=$VERSION" -o coroot-node-agent .
RUN CGO_ENABLED=1 go build -mod=readonly -ldflags "-extldflags='-Wl,-z,lazy' -X 'github.com/coroot/coroot-node-agent/flags.Version=${VERSION}'" -o coroot-node-agent .

# Runtime stage
FROM alpine:3.22 AS release-stage

FROM alpine:3.19 AS release-stage
WORKDIR /app
COPY --from=build-stage /app/coroot-node-agent /usr/bin/coroot-node-agent

# Copy the statically linked binary
COPY --from=builder /app/coroot-node-agent /usr/bin/coroot-node-agent

# Ensure it’s executable
RUN chmod +x /usr/bin/coroot-node-agent
CMD ["coroot-node-agent"]

# Run it
CMD ["/usr/bin/coroot-node-agent"]
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ To learn more about automated log clustering, check out the blog post "[Mining m
identify situations where a container is experiencing a lack of CPU time or waiting for I/O.

The agent gathers per-process counters through [Netlink](https://man7.org/linux/man-pages/man7/netlink.7.html) and aggregates them into per-container metrics:
* [container_resources_cpu_delay_seconds_total](https://coroot.com/docs/metrics/node-agent#container_resources_cpu_delay_seconds_total)
* [container_resources_disk_delay_seconds_total](https://coroot.com/docs/metrics/node-agent#container_resources_disk_delay_seconds_total)
* [container_resources_cpu_delay_seconds_total](https://docs.coroot.com/metrics/node-agent#container_resources_cpu_delay_seconds_total)
* [container_resources_disk_delay_seconds_total](https://docs.coroot.com/metrics/node-agent#container_resources_disk_delay_seconds_total)


<img src="https://coroot.com/static/img/blog/delay_accounting_aggregation.svg" width="800" />
Expand All @@ -59,7 +59,7 @@ Related blog posts:

### Out-of-memory events tracing

The [container_oom_kills_total](https://coroot.com/docs/metrics/node-agent#container_oom_kills_total) metric shows that a container has been terminated by the OOM killer.
The [container_oom_kills_total](https://docs.coroot.com/metrics/node-agent#container_oom_kills_total) metric shows that a container has been terminated by the OOM killer.

### Instance meta information

Expand All @@ -82,17 +82,17 @@ Related blog posts:

## Installation

The documentation is available at [coroot.com/docs/metric-exporters/node-agent](https://coroot.com/docs/metric-exporters/node-agent/installation).
Follow the Coroot [documentation](https://docs.coroot.com/)

## Metrics

The collected metrics are described [here](https://coroot.com/docs/metrics/node-agent).
The collected metrics are described [here](https://docs.coroot.com/metrics/node-agent).

## Coroot

The best way to turn metrics to answers about app issues is to use [Coroot](https://github.com/coroot/coroot) - a zero-instrumentation observability tool for microservice architectures.

A live demo of Coroot is available at [community-demo.coroot.com](https://community-demo.coroot.com)
A live demo of Coroot is available at [demo.coroot.com](https://demo.coroot.com)

## Contributing
To start contributing, check out our [Contributing Guide](https://github.com/coroot/coroot-node-agent/blob/main/CONTRIBUTING.md).
Expand Down
70 changes: 47 additions & 23 deletions cgroup/cgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,19 @@ import (
)

var (
cgRoot = *flags.CgroupRoot
cgRoot = *flags.CgroupRoot
cg2Root = *flags.CgroupRoot
Comment thread
mayankpande88 marked this conversation as resolved.

baseCgroupPath = ""

dockerIdRegexp = regexp.MustCompile(`([a-z0-9]{64})`)
crioIdRegexp = regexp.MustCompile(`crio-([a-z0-9]{64})`)
containerdIdRegexp = regexp.MustCompile(`cri-containerd[-:]([a-z0-9]{64})`)
lxcIdRegexp = regexp.MustCompile(`/lxc/([^/]+)`)
systemSliceIdRegexp = regexp.MustCompile(`(/(system|runtime)\.slice/([^/]+))`)
systemSliceIdRegexp = regexp.MustCompile(`(/(system|runtime|reserved)\.slice/([^/]+))`)
talosIdRegexp = regexp.MustCompile(`/(system|podruntime)/([^/]+)`)
)

type Version uint8

const (
V1 Version = iota
V2
)

type ContainerType uint8

const (
Expand Down Expand Up @@ -68,17 +62,48 @@ func (t ContainerType) String() string {

type Cgroup struct {
Id string
Version Version
ContainerType ContainerType
ContainerId string

subsystems map[string]string
}

func (cg *Cgroup) getId() string {
v2 := cg.subsystems[""]
cpu := cg.subsystems["cpu"]
mem := cg.subsystems["memory"]
name := cg.subsystems["name=systemd"]

id := v2
if strings.HasPrefix(cpu, "/kubepods") {
return cpu
}
if strings.HasPrefix(mem, "/kubepods") {
return mem
}
if id == "" {
id = cpu
}
if id == "" {
id = mem
}
if id == "" {
return name
}
return id
}

func (cg *Cgroup) CreatedAt() time.Time {
p := path.Join(cgRoot, cg.subsystems[""]) //v2
if cg.Version == V1 {
p = path.Join(cgRoot, "cpu", cg.subsystems["cpu"])
var p string
if sp := cg.subsystems[""]; sp != "" { //v2
p = path.Join(cg2Root, sp)
} else if sp = cg.subsystems["cpu"]; sp != "" {
p = path.Join(cgRoot, "cpu", sp)
} else if sp = cg.subsystems["memory"]; sp != "" {
p = path.Join(cgRoot, "memory", sp)
}
Comment thread
mayankpande88 marked this conversation as resolved.
if p == "" {
return time.Time{}
}
fi, err := os.Stat(p)
if err != nil {
Expand All @@ -104,17 +129,16 @@ func NewFromProcessCgroupFile(filePath string) (*Cgroup, error) {
continue
}
for _, cgType := range strings.Split(parts[1], ",") {
cg.subsystems[cgType] = path.Join(baseCgroupPath, parts[2])
p := path.Join(baseCgroupPath, parts[2])
switch p {
case "/", "/init.scope":
continue
}
cg.subsystems[cgType] = p
}
}
if cg.Id = cg.subsystems[""]; cg.Id != "" {
cg.Version = V2
} else if cg.Id = cg.subsystems["cpu"]; cg.Id != "" {
cg.Version = V1
}
if (cg.Id == "" || cg.Id == "/") && cg.subsystems["name=systemd"] != "/" {
cg.Id = cg.subsystems["name=systemd"]
}

cg.Id = cg.getId()
if cg.ContainerType, cg.ContainerId, err = containerByCgroup(cg.Id); err != nil {
return nil, err
}
Expand Down Expand Up @@ -175,7 +199,7 @@ func containerByCgroup(cgroupPath string) (ContainerType, string, error) {
}
return ContainerTypeTalosRuntime, path.Join("/talos/", matches[2]), nil
}
if prefix == "system.slice" || prefix == "runtime.slice" {
if prefix == "system.slice" || prefix == "runtime.slice" || prefix == "reserved.slice" {
matches := systemSliceIdRegexp.FindStringSubmatch(cgroupPath)
if matches == nil {
return ContainerTypeUnknown, "", fmt.Errorf("invalid systemd cgroup %s", cgroupPath)
Expand Down
45 changes: 28 additions & 17 deletions cgroup/cgroup_linux.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package cgroup

import (
"os"
"path"
"runtime"
"strings"

"github.com/vishvananda/netns"
"golang.org/x/sys/unix"
"k8s.io/klog/v2"
)

func Init() error {
Expand All @@ -18,25 +22,32 @@ func Init() error {
return err
}
defer hostNs.Close()
if selfNs.Equal(hostNs) {
return nil
}
if !selfNs.Equal(hostNs) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err := unix.Setns(int(hostNs), unix.CLONE_NEWCGROUP); err != nil {
return err
}
cg, err := NewFromProcessCgroupFile("/proc/self/cgroup")
if err != nil {
return err
}
baseCgroupPath = cg.Id

runtime.LockOSThread()
defer runtime.UnlockOSThread()
if err := unix.Setns(int(hostNs), unix.CLONE_NEWCGROUP); err != nil {
return err
if err := unix.Setns(int(selfNs), unix.CLONE_NEWCGROUP); err != nil {
return err
}
}

cg, err := NewFromProcessCgroupFile("/proc/self/cgroup")
if err != nil {
return err
if _, err := os.Stat(path.Join(cgRoot, "unified")); err == nil {
if data, err := os.ReadFile("/proc/self/mounts"); err == nil {
for _, line := range strings.Split(string(data), "\n") {
if strings.Contains(line, "cgroup/unified") {
cg2Root = path.Join(cgRoot, "unified")
break
}
}
}
}
Comment thread
mayankpande88 marked this conversation as resolved.
baseCgroupPath = cg.Id

if err := unix.Setns(int(selfNs), unix.CLONE_NEWCGROUP); err != nil {
return err
}

klog.Infoln("cgroup v2 root is", cg2Root)
return nil
}
Loading