From 7a9e4497ecbedb4a15bcf5ae5606ce9ea6e1a8e5 Mon Sep 17 00:00:00 2001 From: Mahendra Paipuri Date: Tue, 3 Dec 2024 11:53:08 +0100 Subject: [PATCH] docs: Add an example on how to use cgroup path Disable cgroup_path meta data by default --- .../components/discovery/discovery.process.md | 28 +++++++++++++++++++ internal/component/discovery/process/args.go | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/docs/sources/reference/components/discovery/discovery.process.md b/docs/sources/reference/components/discovery/discovery.process.md index b120708647..ea247ba98d 100644 --- a/docs/sources/reference/components/discovery/discovery.process.md +++ b/docs/sources/reference/components/discovery/discovery.process.md @@ -190,6 +190,34 @@ discovery.process "all" { } } +### Example discovering processes on the local host based on `cgroups` path + +To discover processes running under systemd services on the local host. + +```alloy +discovery.process "all" { + refresh_interval = "60s" + discover_config { + cwd = true + exe = true + commandline = true + username = true + uid = true + cgroup_path = true + container_id = true + } +} + +discovery.relabel "systemd_services" { + targets = discovery.process.all.targets + // Only keep the targets that correspond to systemd services + rule { + action = "keep" + regex = "^.*/([a-zA-Z0-9-_]+).service(?:.*$)" + source_labels = ["__meta_cgroup_id"] + } +} + ``` diff --git a/internal/component/discovery/process/args.go b/internal/component/discovery/process/args.go index 2b794625ea..84256541c8 100644 --- a/internal/component/discovery/process/args.go +++ b/internal/component/discovery/process/args.go @@ -30,7 +30,7 @@ var DefaultConfig = Arguments{ Exe: true, Commandline: true, ContainerID: true, - CgroupPath: true, + CgroupPath: false, }, }