-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(grafana-agent,ebpf): do not use undocumented features, used disc…
…overy.process (#2972)
- Loading branch information
1 parent
ba9d6e7
commit 35d451f
Showing
7 changed files
with
204 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
discovery.docker "all" { | ||
host = "unix:///var/run/docker.sock" | ||
} | ||
|
||
discovery.relabel "pyroscope" { | ||
targets = discovery.docker.all.targets | ||
// Filter needed containers based on docker labels | ||
// See more info at reference doc https://grafana.com/docs/agent/next/flow/reference/components/discovery.docker/ | ||
rule { | ||
source_labels = ["__meta_docker_container_name"] | ||
regex = ".*pyroscope.*" | ||
action = "keep" | ||
} | ||
// provide arbitrary service_name label, otherwise it will default to value of __meta_docker_container_name | ||
rule { | ||
source_labels = ["__meta_docker_container_name"] | ||
regex = ".*pyroscope.*" | ||
action = "replace" | ||
target_label = "service_name" | ||
replacement = "ebpf/docker/pyroscope" | ||
} | ||
} | ||
|
||
|
||
pyroscope.ebpf "instance" { | ||
forward_to = [pyroscope.write.endpoint.receiver] | ||
targets = discovery.relabel.pyroscope.output | ||
} | ||
|
||
pyroscope.write "endpoint" { | ||
endpoint { | ||
url = "http://pyroscope:4040" | ||
// url = "<Grafana Cloud URL>" | ||
// basic_auth { | ||
// username = "<Grafana Cloud User>" | ||
// password = "<Grafana Cloud Password>" | ||
// } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
version: '3.9' | ||
services: | ||
pyroscope: | ||
image: grafana/pyroscope | ||
ports: | ||
- '4040:4040' | ||
|
||
grafana-agent: | ||
image: 'grafana/agent:main' | ||
user: root | ||
privileged: true | ||
pid: 'host' | ||
environment: | ||
- AGENT_MODE=flow | ||
volumes: | ||
- '/var/run/docker.sock:/var/run/docker.sock' | ||
- ./config.river:/config.river | ||
ports: | ||
- '12345:12345' | ||
command: | ||
- 'run' | ||
- '/config.river' | ||
- '--storage.path=/tmp/agent' | ||
- '--server.http.listen-addr=0.0.0.0:12345' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// This is an example grafana agent config to set up eBPF profiling in kubernetes. | ||
// for more info see https://grafana.com/docs/pyroscope/latest/configure-client/grafana-agent/ebpf/setup-kubernetes/ | ||
|
||
discovery.kubernetes "local_pods" { | ||
selectors { | ||
field = "spec.nodeName=" + env("HOSTNAME") // Note: this assume HOSTNAME is set to the node name | ||
role = "pod" | ||
} | ||
role = "pod" | ||
} | ||
|
||
discovery.relabel "specific_pods" { | ||
targets = discovery.kubernetes.all_pods.targets | ||
rule { | ||
action = "drop" | ||
regex = "Succeeded|Failed|Completed" | ||
source_labels = ["__meta_kubernetes_pod_phase"] | ||
} | ||
rule { | ||
action = "replace" | ||
source_labels = ["__meta_kubernetes_namespace"] | ||
target_label = "namespace" | ||
} | ||
rule { | ||
action = "replace" | ||
source_labels = ["__meta_kubernetes_pod_name"] | ||
target_label = "pod" | ||
} | ||
rule { | ||
action = "replace" | ||
source_labels = ["__meta_kubernetes_pod_node_name"] | ||
target_label = "node" | ||
} | ||
rule { | ||
action = "replace" | ||
source_labels = ["__meta_kubernetes_pod_container_name"] | ||
target_label = "container" | ||
} | ||
// provide arbitrary service_name label, otherwise it will be set to {__meta_kubernetes_namespace}/{__meta_kubernetes_pod_container_name} | ||
rule { | ||
action = "replace" | ||
regex = "(.*)@(.*)" | ||
replacement = "ebpf/k8s/${1}/${2}" | ||
separator = "@" | ||
source_labels = ["__meta_kubernetes_namespace", "__meta_kubernetes_pod_container_name"] | ||
target_label = "service_name" | ||
} | ||
// Filter specific targets to profile | ||
rule { | ||
source_labels = ["service_name"] | ||
regex = "(ebpf/grafana-agent/agent|ebpf/pyroscope/pyroscope)" | ||
action = "keep" | ||
} | ||
} | ||
|
||
pyroscope.ebpf "instance" { | ||
forward_to = [pyroscope.write.endpoint.receiver] | ||
targets = discovery.relabel.specific_pods.targets | ||
} | ||
|
||
pyroscope.write "endpoint" { | ||
url = "http://pyroscope:4040" | ||
// url = "<Grafana Cloud URL>" | ||
// basic_auth { | ||
// username = "<Grafana Cloud User>" | ||
// password = "<Grafana Cloud Password>" | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
// discovery.process produces targets with the following labels:` | ||
// "__process_pid__" | ||
// "__meta_process_exe" | ||
// "__meta_process_cwd" | ||
// "__meta_process_commandline" | ||
// "__meta_process_username" | ||
// "__meta_process_uid" | ||
// "__container_id__" | ||
// See reference doc for more info https://grafana.com/docs/agent/next/flow/reference/components/discovery.process/ | ||
|
||
discovery.process "all" { | ||
|
||
} | ||
|
||
discovery.relabel "agent" { | ||
targets = discovery.process.all.targets | ||
// Filter needed processes | ||
rule { | ||
source_labels = ["__meta_process_exe"] | ||
regex = ".*/grafana-agent" | ||
action = "keep" | ||
} | ||
// provide arbitrary service_name label, otherwise it will be "unspecified" | ||
rule { | ||
source_labels = ["__meta_process_exe"] | ||
target_label = "service_name" | ||
regex = ".*/grafana-agent" | ||
action = "replace" | ||
replacement = "ebpf/local/grafana-agent" | ||
} | ||
} | ||
|
||
|
||
pyroscope.ebpf "instance" { | ||
forward_to = [pyroscope.write.endpoint.receiver] | ||
targets = concat( | ||
discovery.relabel.agent.output, | ||
[{"__process_pid__" = "1", "service_name" = "ebpf/local/init"}], | ||
) | ||
} | ||
|
||
|
||
pyroscope.write "endpoint" { | ||
endpoint { | ||
url = "http://pyroscope:4040" | ||
// url = "<Grafana Cloud URL>" | ||
// basic_auth { | ||
// username = "<Grafana Cloud User>" | ||
// password = "<Grafana Cloud Password>" | ||
// } | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters