Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: IPC metrics #1238

Closed
tzz opened this issue Jan 28, 2019 · 11 comments
Closed

Feature request: IPC metrics #1238

tzz opened this issue Jan 28, 2019 · 11 comments

Comments

@tzz
Copy link

tzz commented Jan 28, 2019

After looking at http://www.brendangregg.com/blog/2017-05-09/cpu-utilization-is-wrong.html I wanted to calculate the Instructions Per Cycle (IPC) using node_exporter. Currently neither the instructions nor the cycles counters are available through node_exporter.

Currently I can get the data with perf stat -D 1000 -a -d -x, -c -- sleep 10 which waits 1 second, then samples for 10 seconds. I can then look for cycles and instructions in the output. I don't know what the equivalent kernel APIs are, and if they are available to node_exporter through procfs or other means.

@simonpasquier simonpasquier transferred this issue from prometheus/alertmanager Jan 28, 2019
@tzz
Copy link
Author

tzz commented Jan 30, 2019

From the command line, the counters can be retrieved without root by using echo LEVEL > /proc/sys/kernel/perf_event_paranoid

You may not have permission to collect stats.
Consider tweaking /proc/sys/kernel/perf_event_paranoid:
 -1 - Not paranoid at all
  0 - Disallow raw tracepoint access for unpriv
  1 - Disallow cpu events for unpriv
  2 - Disallow kernel profiling for unpriv

I don't see a way to get to the perf events API through procfs or sysfs right now.

@discordianfish
Copy link
Member

Interesting.. Just saw that there is this already: https://github.com/tcolgate/perfexporter

But certainly open to include that in the node-exporter, pending the implementation details. Looks like there is better support in golang in the making: golang/go#24918

@discordianfish
Copy link
Member

But looks like that needs root, which would be a problem for including it in the node-exporter.

@tzz
Copy link
Author

tzz commented Jan 30, 2019

But looks like that needs root, which would be a problem for including it in the node-exporter.

OK, I see, but see the above about /proc/sys/kernel/perf_event_paranoid? That will apply to any perf client, right? So maybe it makes the root requirement less of a problem?

@discordianfish
Copy link
Member

Ah, yeah I think if a user can run the node-exporter unprivileged by setting perf_event_paranoid, that would be a good compromise. Still need probably makes sense to wait for golang/go#24918 to land in a release.

@hodgesds
Copy link
Contributor

hodgesds commented Feb 28, 2019

I've been working on a little go library that would allow you to do that, the API is not finalized but I've been thinking of implementing this feature.

@hodgesds
Copy link
Contributor

hodgesds commented Mar 5, 2019

I think I pretty much have this implemented, if you want to test it out and have any opinions on configuration that would be helpful as well.

@tzz
Copy link
Author

tzz commented May 18, 2020

@hodgesds @discordianfish I think #1274 definitely closes the feature request here. Let me know if you agree.

@discordianfish
Copy link
Member

Good point, thanks!

@tzz
Copy link
Author

tzz commented May 19, 2020

I wanted to thank you both @hodgesds and @discordianfish for working on this feature. It's really useful and well implemented.

@hodgesds
Copy link
Contributor

No problem, glad it's useful to others!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants