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

add metrics to monitor processes by user and host #333

Merged
merged 8 commits into from
Sep 25, 2018
Merged

add metrics to monitor processes by user and host #333

merged 8 commits into from
Sep 25, 2018

Conversation

peterloeffler
Copy link
Contributor

@peterloeffler peterloeffler commented Sep 11, 2018

Added 2 new flags --collect.info_schema.processlist.processes_by_user and --collect.info_schema.processlist.processes_by_host which are needed in addition to --collect.info_schema.processlist.
By using them you get 2 new metrics:

  • mysql_info_schema_processes_by_user{src_user=""}
  • mysql_info_schema_processes_by_host{src_host=""}

Found it very useful to have this metrics and thought it could be interesting to have it in place for many people.

Closes: #334

Peter Löffler added 3 commits September 11, 2018 10:24
Signed-off-by: Peter Löffler <peter.loeffler@runtastic.com>
Signed-off-by: Peter Löffler <peter.loeffler@runtastic.com>
Signed-off-by: Peter Löffler <peter.loeffler@runtastic.com>
@@ -121,6 +147,52 @@ var (
}
)

func processesByUser(db *sql.DB, ch chan<- prometheus.Metric, query string, i int) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the i int for? It seems unused.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I don't think it's necessary to pass the package scope query string.

@SuperQ
Copy link
Member

SuperQ commented Sep 11, 2018

I'm wondering if it would be more efficient to change the exporter to dump the process list, and collate the results in Go.

This would allow the exporter to execute one query against information_schema.processlist, rather than 3.

Peter Löffler added 2 commits September 11, 2018 20:48
Signed-off-by: Peter Löffler <peter.loeffler@runtastic.com>
Signed-off-by: Peter Löffler <peter.loeffler@runtastic.com>
@peterloeffler
Copy link
Contributor Author

Only executing one query sounds like a good idea.
I'm not sure if my go skills are good enough to implement this properly.

@SuperQ
Copy link
Member

SuperQ commented Sep 12, 2018

Let's document this feature request in an issue.

@SuperQ
Copy link
Member

SuperQ commented Sep 12, 2018

Let me know if #334 is what you're looking for.

@peterloeffler
Copy link
Contributor Author

Sounds perfect!

@peterloeffler
Copy link
Contributor Author

Can you please have a look to my last commit?
Should be a huge improvement.

@SuperQ
Copy link
Member

SuperQ commented Sep 14, 2018

Nice, looks pretty good. What do you think about keeping a couple bool flags to disable host/user metrics. We can leave them on by default, but some people might have a lot of users/hosts where the cardinality would be too high, but they may still want command/state metrics.

@SuperQ
Copy link
Member

SuperQ commented Sep 14, 2018

One more request, please add a CHANGELOG entry.

@peterloeffler
Copy link
Contributor Author

Nice, looks pretty good. What do you think about keeping a couple bool flags to disable host/user metrics. We can leave them on by default, but some people might have a lot of users/hosts where the cardinality would be too high, but they may still want command/state metrics.

Good idea. Is it ok that the additional flags are not listet when calling --help?

@SuperQ
Copy link
Member

SuperQ commented Sep 14, 2018

I would probably list them in --help, like the other collector tunables are.

Peter Löffler added 2 commits September 14, 2018 12:09
- add additional exporter flags:
    collect.info_schema.processlist.disable_processes_by_user
    collect.info_schema.processlist.disable_processes_by_host

Signed-off-by: Peter Löffler <peter.loeffler@runtastic.com>
- add additional exporter flags:
    collect.info_schema.processlist.disable_processes_by_user
    collect.info_schema.processlist.disable_processes_by_host

Signed-off-by: Peter Löffler <peter.loeffler@runtastic.com>
@peterloeffler
Copy link
Contributor Author

Added the flags + a hopefully proper changelog entry.

@peterloeffler
Copy link
Contributor Author

What do you think? Can we merge it? Anything I can do?

@SuperQ
Copy link
Member

SuperQ commented Sep 25, 2018

Sorry, got lost in my review pile.

@@ -26,6 +32,14 @@ var (
"collect.info_schema.processlist.min_time",
"Minimum time a thread must be in each state to be counted",
).Default("0").Int()
processesDisableByUserFlag = kingpin.Flag(
"collect.info_schema.processlist.disable_processes_by_user",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer positive flags when possible, to avoid confusing double negatives.

Let's use collect.info_schema.processlist.processes_by_user, with a default of true. Same for by_host.

This way the disable flag will be --no-collect.info_schema.processlist.processes_by_user.

Signed-off-by: Peter Löffler <peter.loeffler@runtastic.com>
@peterloeffler
Copy link
Contributor Author

No problem. Just wanted to know...
Flags are positive now.

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@SuperQ SuperQ merged commit 410ace7 into prometheus:master Sep 25, 2018
@peterloeffler
Copy link
Contributor Author

Very nice! Thx a lot!

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

Successfully merging this pull request may close these issues.

2 participants