grafana / alloy

OpenTelemetry Collector distribution with programmable pipelines
https://grafana.com/oss/alloy
Apache License 2.0
1.4k stars 203 forks source link

Alloy - pyroscope.ebpf: add example for localhost profile collection #324

Open tpaschalis opened 1 year ago

tpaschalis commented 1 year ago

Currently, the documentation page of pyroscope.ebpf provides examples for Docker and Kubernetes-based profile collection.

One user in the public Slack was confused as to how to collect profiles locally from a VM.

I'm guessing it's as easy as targets = [{"__address__" = "localhost", "instance" = "one"}], but wanted to a) verify that's the case and b) add this as an example to get people up and running

AS-Labs commented 11 months ago

The old pyroscope agent was very simple in its collection config. pyroscope ebpf --pid -1 --application-name $appname --server-address $serverIP:$port

Definitely would like to have a similar example from the grafana-agent to make the transition easier to profile the VM's instead of just Docker/Kubernetes, though luckily the old agent can still send the metrics to grafana-pyroscope.

AS-Labs commented 11 months ago

The old pyroscope agent was very simple in its collection config. pyroscope ebpf --pid -1 --application-name $appname --server-address $serverIP:$port

Definitely would like to have a similar example from the grafana-agent to make the transition easier to profile the VM's instead of just Docker/Kubernetes, though luckily the old agent can still send the metrics to grafana-pyroscope.

After more testing, the below river config was working fine for my use case. apologies for the previous comment.

pyroscope.ebpf "instance" {
  forward_to = [ pyroscope.write.endpoint.receiver ]
  targets_only = false
  default_target = {"service_name" = "$SERVICE_NAME"}
}
pyroscope.write "endpoint" {
  endpoint {
    url = "$URL:$PORT"
  }
}
github-actions[bot] commented 9 months ago

This issue has not had any activity in the past 30 days, so the needs-attention label has been added to it. If the opened issue is a bug, check to see if a newer release fixed your issue. If it is no longer relevant, please feel free to close this issue. The needs-attention label signals to maintainers that something has fallen through the cracks. No action is needed by you; your issue will be kept open and you do not have to respond to this comment. The label will be removed the next time this job runs if there is new activity. Thank you for your contributions!

vsxen commented 3 months ago

https://grafana.com/docs/pyroscope/latest/configure-client/grafana-agent/ebpf/setup-linux/#configure-the-grafana-agent

tigerinus commented 2 months ago

The old pyroscope agent was very simple in its collection config. pyroscope ebpf --pid -1 --application-name $appname --server-address $serverIP:$port Definitely would like to have a similar example from the grafana-agent to make the transition easier to profile the VM's instead of just Docker/Kubernetes, though luckily the old agent can still send the metrics to grafana-pyroscope.

After more testing, the below river config was working fine for my use case. apologies for the previous comment.

pyroscope.ebpf "instance" {
  forward_to = [ pyroscope.write.endpoint.receiver ]
  targets_only = false
  default_target = {"service_name" = "$SERVICE_NAME"}
}
pyroscope.write "endpoint" {
  endpoint {
    url = "$URL:$PORT"
  }
}

Can you elaborate this snippet? Like what is service_name?

Also targets is a required field according to Alloy documentation... It's missing in your snippet. May be u can explain a bit?

AS-Labs commented 2 months ago

The old pyroscope agent was very simple in its collection config. pyroscope ebpf --pid -1 --application-name $appname --server-address $serverIP:$port Definitely would like to have a similar example from the grafana-agent to make the transition easier to profile the VM's instead of just Docker/Kubernetes, though luckily the old agent can still send the metrics to grafana-pyroscope.

After more testing, the below river config was working fine for my use case. apologies for the previous comment.

pyroscope.ebpf "instance" {
  forward_to = [ pyroscope.write.endpoint.receiver ]
  targets_only = false
  default_target = {"service_name" = "$SERVICE_NAME"}
}
pyroscope.write "endpoint" {
  endpoint {
    url = "$URL:$PORT"
  }
}

Can you elaborate this snippet? Like what is service_name?

Also targets is a required field according to Alloy documentation... It's missing in your snippet. May be u can explain a bit?

service_name is just a label that can be used to differentiate between profiles. [example; "service_name" = "web-server"] This was for the river config from grafana-agent-flow, not sure if this translates to alloy configs.