发现进程
查找.process
用于在本地Linux OS上发现运行中的进程。
注意
要使用查找.process
组件,您必须以root权限运行Alloy并在host PID命名空间内。
用法
discovery.process "LABEL" {
}
参数
以下参数被支持
名称 | 类型 | 描述 | 默认 | 必需 |
---|---|---|---|---|
join | list(map(string)) | Join external targets to discovered processes targets based on __container_id__ label. | no | |
refresh_interval | duration | How often to sync targets. | “60s” | no |
Targets joining
If join
is specified, 查找.process
will join the discovered processes based on the __container_id__
label.
例如,如果join
指定如下:
[
{
"pod": "pod-1",
"__container_id__": "container-1"
},
{
"pod": "pod-2",
"__container_id__": "container-2"
}
]
并且发现的进程是:
[
{
"__process_pid__": "1",
"__container_id__": "container-1"
},
{
"__process_pid__": "2"
}
]
生成的目标是
[
{
"__container_id__": "container-1",
"__process_pid__": "1",
"pod": "pod-1"
},
{
"__process_pid__": "2"
},
{
"__container_id__": "container-1",
"pod": "pod-1"
},
{
"__container_id__": "container-2",
"pod": "pod-2"
}
]
块
在查找.process
定义内部支持以下块:
层次结构 | 块 | 描述 | 必需 |
---|---|---|---|
discover_config | discover_config | Configure which process metadata to discover. | no |
discover_config block
The discover_config
block describes which process metadata to discover.
以下参数被支持
名称 | 类型 | 描述 | 默认 | 必需 |
---|---|---|---|---|
exe | bool | A flag to enable discovering __meta_process_exe label. | true | no |
cwd | bool | A flag to enable discovering __meta_process_cwd label. | true | no |
commandline | bool | A flag to enable discovering __meta_process_commandline label. | true | no |
uid | bool | A flag to enable discovering __meta_process_uid : label. | true | no |
username | bool | A flag to enable discovering __meta_process_username : label. | true | no |
container_id | bool | A flag to enable discovering __container_id__ label. | true | no |
导出字段
The following fields are exported and can be referenced by other components
名称 | 类型 | 描述 |
---|---|---|
targets | list(map(string)) | The set of processes discovered on the local Linux OS. |
每个目标包含以下标签
__process_pid__
: The process PID.__meta_process_exe
:进程可执行文件路径。从/proc/<pid>/exe
获取。__meta_process_cwd
:进程当前工作目录。从/proc/<pid>/cwd
获取。__meta_process_commandline
:进程命令行。从/proc/<pid>/cmdline
获取。__meta_process_uid
:进程UID。从/proc/<pid>/status
获取。__meta_process_username
:进程用户名。从__meta_process_uid
和os/user/LookupID
获取。__container_id__
:容器ID。从/proc/<pid>/cgroup
获取。如果进程未在容器中运行,则此标签未设置。
组件健康
discovery.process
仅在提供无效配置时报告为不健康。在这种情况下,导出的字段将保持其最后健康的值。
调试信息
discovery.process
不暴露任何特定组件的调试信息。
调试指标
discovery.process
不暴露任何特定组件的调试指标。
示例
示例在本地主机上发现进程
discovery.process "all" {
refresh_interval = "60s"
discover_config {
cwd = true
exe = true
commandline = true
username = true
uid = true
container_id = true
}
}
示例在本地主机上发现进程并与discovery.kubernetes
连接
discovery.kubernetes "pyroscope_kubernetes" {
selectors {
field = "spec.nodeName=" + env("HOSTNAME")
role = "pod"
}
role = "pod"
}
discovery.process "all" {
join = discovery.kubernetes.pyroscope_kubernetes.targets
refresh_interval = "60s"
discover_config {
cwd = true
exe = true
commandline = true
username = true
uid = true
container_id = true
}
}
兼容组件
discovery.process
可以接受以下组件的参数
- 导出目标的组件
discovery.process
的导出可以被以下组件消费
- 消费目标的组件
注意
连接某些组件可能没有意义,或者组件可能需要进一步配置才能正确连接。有关更多详细信息,请参阅链接文档。