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

Default PROMQL query syntax should not use regular expressions #178

Merged
merged 1 commit into from
Mar 8, 2022

Conversation

shijieqin
Copy link
Collaborator

NodeMemUsagePromQLFmtStr = sum(node_memory_MemTotal_bytes{instance="%s"} - node_memory_MemAvailable_bytes{instance="%s"})
NodeCpuUsagePromQLFmtStr = sum(count(node_cpu_seconds_total{mode="idle",instance="%s"}) by (mode, cpu)) - sum(irate(node_cpu_seconds_total{mode="idle",instance="%s"}[%s]))
The above two default queries use a regular expression, which will cause the query result that does not meet the expected expectations.

// NodeMemUsagePromQLFmtStr is used to query node cpu memory by promql, param is node name, node name which prometheus scrape
NodeMemUsagePromQLFmtStr = `sum(node_memory_MemTotal_bytes{instance=~"^%s.*"} - node_memory_MemAvailable_bytes{instance=~"^%s.*"})`
NodeMemUsagePromQLFmtStr = `sum(node_memory_MemTotal_bytes{instance="%s"} - node_memory_MemAvailable_bytes{instance="%s"})`
Copy link
Contributor

Choose a reason for hiding this comment

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

This regex is used to match some instance including ip:port style. And it depends on your monitoring system, so we do not assume the instance is nodename or ip only.

If we modify this prom template, we need find a more general way.

image

Copy link
Collaborator Author

@shijieqin shijieqin Mar 3, 2022

Choose a reason for hiding this comment

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

I know, so I pushed a new commit that is used to match some instance including ip:port style.
image

image

Copy link
Contributor

Choose a reason for hiding this comment

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

\LGTM

@mfanjie
Copy link
Contributor

mfanjie commented Mar 3, 2022

@shijieqin cloud you please make sure your commit messages are in English, we need to keep the project to be globalized.

@shijieqin
Copy link
Collaborator Author

@shijieqin cloud you please make sure your commit messages are in English, we need to keep the project to be globalized.

Sorry, I change the commit message.

@kitianFresh kitianFresh merged commit ae7567f into gocrane:main Mar 8, 2022
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.

Default PromQL query syntax should not use regular expressions
3 participants